• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #37477

pending completion
#37477

push

local

web-flow
Allow external lattice elements to properly union split (#49030)

Currently `MustAlias` is the only lattice element that is allowed
to widen to union types. However, there are others in external
packages. Expand the support we have for this in order to allow
union splitting of lattice elements.

Co-authored-by: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>

26 of 26 new or added lines in 5 files covered. (100.0%)

71476 of 82705 relevant lines covered (86.42%)

34756248.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.2
/stdlib/Markdown/src/parse/parse.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
mutable struct MD
4
    content::Vector{Any}
5
    meta::Dict{Symbol, Any}
6

7
    MD(content::AbstractVector, meta::Dict = Dict()) =
35,883✔
8
        new(content, meta)
9
end
10

11
MD(xs...) = MD(vcat(xs...))
11,003✔
12

13
function MD(cfg::Config, xs...)
×
14
    md = MD(xs...)
10,705✔
15
    md.meta[:config] = cfg
10,705✔
16
    return md
10,705✔
17
end
18

19
config(md::MD) = md.meta[:config]::Config
44,912✔
20

21
# Forward some array methods
22

23
Base.push!(md::MD, x) = push!(md.content, x)
27,198✔
24
Base.getindex(md::MD, args...) = md.content[args...]
×
25
Base.setindex!(md::MD, args...) = setindex!(md.content, args...)
×
26
Base.lastindex(md::MD) = lastindex(md.content)
×
27
Base.firstindex(md::MD) = firstindex(md.content)
×
28
Base.length(md::MD) = length(md.content)
4✔
29
Base.isempty(md::MD) = isempty(md.content)
1✔
30
Base.copy(md::MD) = MD(copy(md.content), copy(md.meta))
1✔
31

32
==(a::MD, b::MD) = (html(a) == html(b))
50✔
33

34
# Parser functions:
35
#   md – should be modified appropriately
36
#   return – basically, true if parse was successful
37
#     false uses the next parser in the queue, true
38
#     goes back to the beginning
39
#
40
# Inner parsers:
41
#   return – element to use or nothing
42

43
# Inner parsing
44

45
function parseinline(stream::IO, md::MD, parsers::Vector{Function})
49,825✔
46
    for parser in parsers
49,825✔
47
        inner = parser(stream, md)
56,862✔
48
        inner ≡ nothing || return inner
102,456✔
49
    end
11,268✔
50
end
51

52
function parseinline(stream::IO, md::MD, config::Config)
26,146✔
53
    content = []
26,146✔
54
    buffer = IOBuffer()
26,146✔
55
    while !eof(stream)
1,849,241✔
56
        char = peek(stream, Char)
1,823,095✔
57
        if haskey(config.inner, char) &&
1,823,095✔
58
                (inner = parseinline(stream, md, config.inner[char])) !== nothing
59
            c = String(take!(buffer))
45,594✔
60
            !isempty(c) && push!(content, c)
45,594✔
61
            buffer = IOBuffer()
45,594✔
62
            push!(content, inner)
45,594✔
63
        else
64
            write(buffer, read(stream, Char))
1,777,501✔
65
        end
66
    end
1,823,095✔
67
    c = String(take!(buffer))
26,146✔
68
    !isempty(c) && push!(content, c)
26,146✔
69
    return content
26,146✔
70
end
71

72
parseinline(s::AbstractString, md::MD, c::Config) =
7,520✔
73
    parseinline(IOBuffer(s), md, c)
74

75
parseinline(s, md::MD) = parseinline(s, md, config(md))
26,146✔
76

77
# Block parsing
78

79
function parse(stream::IO, block::MD, config::Config; breaking = false)
116,174✔
80
    skipblank(stream)
58,087✔
81
    eof(stream) && return false
58,087✔
82
    for parser in (breaking ? config.breaking : [config.breaking; config.regular])
47,382✔
83
        parser(stream, block) && return true
363,327✔
84
    end
350,401✔
85
    return false
17,228✔
86
end
87

88
parse(stream::IO, block::MD; breaking = false) =
35,386✔
89
  parse(stream, block, config(block), breaking = breaking)
90

91
function parse(stream::IO; flavor = julia)
21,410✔
92
    isa(flavor, Symbol) && (flavor = flavors[flavor])
193✔
93
    markdown = MD(flavor)
10,705✔
94
    while parse(stream, markdown, flavor) end
70,083✔
95
    return markdown
10,705✔
96
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc