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

JuliaLang / julia / #37844

20 Jul 2024 12:09AM UTC coverage: 85.368% (-2.2%) from 87.523%
#37844

push

local

web-flow
Compat for `Base.@nospecializeinfer` (#55178)

This macro was added in v1.10 but was missing a compat notice.

75349 of 88264 relevant lines covered (85.37%)

15222940.81 hits per line

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

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

3
"""
4
    MD
5

6
`MD` represents a Markdown document. Note that the `MD` constructor should not generally be
7
used directly, since it constructs the internal data structures. Instead, you can construct
8
`MD` objects using the exported macros [`@md_str`](@ref) and [`@doc_str`](@ref).
9
"""
10
mutable struct MD
11
    content::Vector{Any}
12
    meta::Dict{Symbol, Any}
13

14
    MD(content::AbstractVector, meta::Dict = Dict()) =
33,950✔
15
        new(content, meta)
16
end
17

18
public MD
19

20
MD(xs...) = MD(vcat(xs...))
10,353✔
21

22
function MD(cfg::Config, xs...)
23
    md = MD(xs...)
10,084✔
24
    md.meta[:config] = cfg
10,084✔
25
    return md
10,084✔
26
end
27

28
config(md::MD) = md.meta[:config]::Config
43,674✔
29

30
# Forward some array methods
31

32
Base.push!(md::MD, x) = push!(md.content, x)
26,516✔
33
Base.getindex(md::MD, args...) = md.content[args...]
×
34
Base.setindex!(md::MD, args...) = setindex!(md.content, args...)
×
35
Base.lastindex(md::MD) = lastindex(md.content)
×
36
Base.firstindex(md::MD) = firstindex(md.content)
×
37
Base.length(md::MD) = length(md.content)
×
38
Base.isempty(md::MD) = isempty(md.content)
×
39
Base.copy(md::MD) = MD(copy(md.content), copy(md.meta))
×
40

41
==(a::MD, b::MD) = (html(a) == html(b))
9✔
42

43
# Parser functions:
44
#   md – should be modified appropriately
45
#   return – basically, true if parse was successful
46
#     false uses the next parser in the queue, true
47
#     goes back to the beginning
48
#
49
# Inner parsers:
50
#   return – element to use or nothing
51

52
# Inner parsing
53

54
function parseinline(stream::IO, md::MD, parsers::Vector{Function})
48,698✔
55
    for parser in parsers
48,698✔
56
        inner = parser(stream, md)
55,915✔
57
        inner ≡ nothing || return inner
100,739✔
58
    end
11,091✔
59
end
60

61
function parseinline(stream::IO, md::MD, config::Config)
25,668✔
62
    content = []
25,668✔
63
    buffer = IOBuffer()
25,668✔
64
    while !eof(stream)
1,751,916✔
65
        char = peek(stream, Char)
1,726,248✔
66
        if haskey(config.inner, char) &&
3,452,496✔
67
                (inner = parseinline(stream, md, config.inner[char])) !== nothing
68
            c = String(take!(buffer))
80,674✔
69
            !isempty(c) && push!(content, c)
44,824✔
70
            buffer = IOBuffer()
44,824✔
71
            push!(content, inner)
44,824✔
72
        else
73
            write(buffer, read(stream, Char))
1,681,424✔
74
        end
75
    end
1,726,248✔
76
    c = String(take!(buffer))
43,992✔
77
    !isempty(c) && push!(content, c)
25,668✔
78
    return content
25,668✔
79
end
80

81
parseinline(s::AbstractString, md::MD, c::Config) =
7,720✔
82
    parseinline(IOBuffer(s), md, c)
83

84
parseinline(s, md::MD) = parseinline(s, md, config(md))
25,668✔
85

86
# Block parsing
87

88
function parse(stream::IO, block::MD, config::Config; breaking = false)
111,024✔
89
    skipblank(stream)
55,512✔
90
    eof(stream) && return false
55,512✔
91
    for parser in (breaking ? config.breaking : [config.breaking; config.regular])
45,428✔
92
        parser(stream, block) && return true
350,197✔
93
    end
320,940✔
94
    return false
16,171✔
95
end
96

97
parse(stream::IO, block::MD; breaking = false) =
33,252✔
98
    parse(stream, block, config(block), breaking = breaking)
99

100
function parse(stream::IO; flavor = julia)
20,168✔
101
    isa(flavor, Symbol) && (flavor = flavors[flavor])
80✔
102
    markdown = MD(flavor)
10,084✔
103
    while parse(stream, markdown, flavor) end
38,886✔
104
    return markdown
10,084✔
105
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

© 2026 Coveralls, Inc