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

JuliaLang / julia / #37627

21 Sep 2023 02:42AM UTC coverage: 85.841% (-0.1%) from 85.948%
#37627

push

local

web-flow
move Pkg out of the sysimage (take 2) (#51189)

Co-authored-by: Jonas Schulze <jonas.schulze@st.ovgu.de>
Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com>
Co-authored-by: Tim Besard <tim.besard@gmail.com>

16 of 16 new or added lines in 1 file covered. (100.0%)

72249 of 84166 relevant lines covered (85.84%)

12728069.66 hits per line

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

84.31
/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()) =
34,901✔
8
        new(content, meta)
9
end
10

11
MD(xs...) = MD(vcat(xs...))
10,672✔
12

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

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

21
# Forward some array methods
22

23
Base.push!(md::MD, x) = push!(md.content, x)
26,658✔
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)
×
29
Base.isempty(md::MD) = isempty(md.content)
×
30
Base.copy(md::MD) = MD(copy(md.content), copy(md.meta))
×
31

32
==(a::MD, b::MD) = (html(a) == html(b))
9✔
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})
48,387✔
46
    for parser in parsers
48,387✔
47
        inner = parser(stream, md)
55,274✔
48
        inner ≡ nothing || return inner
99,769✔
49
    end
10,779✔
50
end
51

52
function parseinline(stream::IO, md::MD, config::Config)
25,396✔
53
    content = []
25,396✔
54
    buffer = IOBuffer()
25,396✔
55
    while !eof(stream)
1,807,746✔
56
        char = peek(stream, Char)
1,782,350✔
57
        if haskey(config.inner, char) &&
1,782,350✔
58
                (inner = parseinline(stream, md, config.inner[char])) !== nothing
59
            c = String(take!(buffer))
44,495✔
60
            !isempty(c) && push!(content, c)
44,495✔
61
            buffer = IOBuffer()
44,495✔
62
            push!(content, inner)
44,495✔
63
        else
64
            write(buffer, read(stream, Char))
1,737,855✔
65
        end
66
    end
1,782,350✔
67
    c = String(take!(buffer))
25,396✔
68
    !isempty(c) && push!(content, c)
25,396✔
69
    return content
25,396✔
70
end
71

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

75
parseinline(s, md::MD) = parseinline(s, md, config(md))
25,396✔
76

77
# Block parsing
78

79
function parse(stream::IO, block::MD, config::Config; breaking = false)
113,550✔
80
    skipblank(stream)
56,775✔
81
    eof(stream) && return false
56,775✔
82
    for parser in (breaking ? config.breaking : [config.breaking; config.regular])
46,355✔
83
        parser(stream, block) && return true
355,600✔
84
    end
342,959✔
85
    return false
16,857✔
86
end
87

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

91
function parse(stream::IO; flavor = julia)
20,840✔
92
    isa(flavor, Symbol) && (flavor = flavors[flavor])
78✔
93
    markdown = MD(flavor)
10,420✔
94
    while parse(stream, markdown, flavor) end
68,456✔
95
    return markdown
10,420✔
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