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

JuliaLang / julia / 1554

08 Jan 2026 06:52PM UTC coverage: 76.664% (+0.04%) from 76.623%
1554

push

buildkite

web-flow
[JuliaLowering] Fix-up always-defined check in `is_valid_body_ir_argument` (#60602)

This was slightly mis-translated from the flisp side:
```scheme
    (define (valid-body-ir-argument? aval)
      (or (valid-ir-argument? aval)
          (and (symbol? aval) ; Arguments are always defined slots
               (or (memq aval (lam:args lam))
                   (let ((vi (get vinfo-table aval #f)))
                     (and vi (vinfo:never-undef vi)))))))
```

Noticed in
https://github.com/JuliaLang/julia/pull/60567#discussion_r2672556146

62618 of 81679 relevant lines covered (76.66%)

23088815.22 hits per line

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

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

3
include("rich.jl")
4

5
# Utils
6

7

8
# Handle URI encoding, poorly. The code here was initially copied from
9
# Base.Filesystem, then modified. The original code implements RFC3986 Section
10
# 2.1 and 2.2.
11
#
12
# We changed encode_uri_component to not encode characters declared as
13
# "reserved" by RFC3986 Section 2.2 (i.e., those from the gen-delims and
14
# sub-delims sets). Instead the user is expected to percent encode these (or
15
# not) as needed -- the alternative would be implement full URI parsing, which
16
# is non-trivial. That said, it would be better to do that, by e.g. using the
17
# URIs.jl package, but that is not an option for us, as it is not a stdlib...
18
#
19
# As a special affordance, we deviate from the "reserved" list in one way: we
20
# do *not* exclude '[' and ']' from percent encoding, even though they are in
21
# the gen-delims set. They are only used to encode IPv6 literal addresses in
22
# the URI, which is (still) rare. But they do occur in query strings and
23
# indeed in the CommonMark spec tests.
24

25
percent_escape(s) = '%' * join(map(b -> uppercase(string(b, base=16)), codeunits(s)), '%')
423✔
26
encode_uri_component(s::AbstractString) = replace(s, r"[^A-Za-z0-9\-_.~/:?#@!$&'()*+,;=]+" => percent_escape)
282✔
27
encode_uri_component(s::Symbol) = encode_uri_component(string(s))
×
28

29
function withtag(f, io::IO, tag, attrs...)
6,489✔
30
    print(io, "<$tag")
6,630✔
31
    for (attr, value) in attrs
6,630✔
32
        print(io, " ", attr, "=\"")
669✔
33
        htmlesc(io, value)
687✔
34
        print(io, "\"")
669✔
35
    end
723✔
36
    f === nothing && return print(io, " />")
6,630✔
37

38
    print(io, ">")
6,459✔
39
    f()
6,804✔
40
    print(io, "</$tag>")
6,459✔
41
end
42

43
tag(io::IO, tag, attrs...) = withtag(nothing, io, tag, attrs...)
171✔
44

45
function htmlesc(io::IO, s::AbstractString)
46
    replace(io, s, '<'=>"&lt;", '>'=>"&gt;", '"'=>"&quot;", '&'=>"&amp;")
6,243✔
47
end
48
function htmlesc(io::IO, s::Symbol)
3✔
49
    htmlesc(io, string(s))
3✔
50
end
51
function htmlesc(io::IO, xs::Union{AbstractString,Symbol}...)
×
52
    for s in xs
×
53
        htmlesc(io, s)
×
54
    end
×
55
end
56
function htmlesc(s::Union{AbstractString,Symbol})
×
57
    sprint(htmlesc, s)
×
58
end
59

60
# Block elements
61

62
function html(io::IO, content::Vector)
3,189✔
63
    for md in content
3,189✔
64
        html(io, md)
4,317✔
65
        println(io)
4,317✔
66
    end
4,317✔
67
end
68

69
html(io::IO, md::MD) = html(io, md.content)
2,427✔
70

71
function html(io::IO, header::Header{l}) where l
300✔
72
    withtag(io, "h$l") do
300✔
73
        htmlinline(io, header.text)
300✔
74
    end
75
end
76

77
function html(io::IO, code′::Code)
312✔
78
    if code′.language == "styled"
312✔
79
        code′ = Code("", String(styled(code′.code)))
×
80
    end
81
    code = code′
312✔
82
    withtag(io, :pre) do
312✔
83
        maybe_lang = !isempty(code.language) ? Any[:class=>"language-$(code.language)"] : []
546✔
84
        withtag(io, :code, maybe_lang...) do
312✔
85
            htmlesc(io, code.code)
369✔
86
            !isempty(code.code) && println(io)
312✔
87
        end
88
    end
89
end
90

91
function html(io::IO, md::Paragraph)
2,910✔
92
    withtag(io, :p) do
2,910✔
93
        htmlinline(io, md.content)
2,910✔
94
    end
95
end
96

97
function html(io::IO, md::BlockQuote)
180✔
98
    withtag(io, :blockquote) do
180✔
99
        println(io)
180✔
100
        html(io, md.content)
180✔
101
    end
102
end
103

104
function html(io::IO, f::Footnote)
12✔
105
    withtag(io, :div, :class => "footnote", :id => "footnote-$(f.id)") do
12✔
106
        withtag(io, :p, :class => "footnote-title") do
12✔
107
            print(io, f.id)
12✔
108
        end
109
        html(io, f.text)
12✔
110
    end
111
end
112

113
function html(io::IO, md::Admonition)
15✔
114
    withtag(io, :div, :class => "admonition $(md.category)") do
15✔
115
        withtag(io, :p, :class => "admonition-title") do
15✔
116
            print(io, md.title)
15✔
117
        end
118
        html(io, md.content)
15✔
119
    end
120
end
121

122
function html(io::IO, md::List)
381✔
123
    maybe_attr = md.ordered > 1 ? Any[:start => string(md.ordered)] : []
726✔
124
    withtag(io, isordered(md) ? :ol : :ul, maybe_attr...) do
381✔
125
        for item in md.items
381✔
126
            println(io)
555✔
127
            withtag(io, :li) do
1,110✔
128
                html(io, item)
555✔
129
            end
130
        end
555✔
131
        println(io)
381✔
132
    end
133
end
134

135
function html(io::IO, md::HorizontalRule)
111✔
136
    tag(io, :hr)
111✔
137
end
138

139
html(io::IO, x) = tohtml(io, x)
18✔
140

141
# Inline elements
142

143
function htmlinline(io::IO, content::Vector)
4,089✔
144
    for x in content
4,089✔
145
        htmlinline(io, x)
5,952✔
146
    end
5,952✔
147
end
148

149
function htmlinline(io::IO, code′::Code)
312✔
150
    if code′.language == "styled"
312✔
151
        code′ = Code("", String(styled(code′.code)))
×
152
    end
153
    code = code′
312✔
154
    withtag(io, :code) do
312✔
155
        htmlesc(io, code.code)
333✔
156
    end
157
end
158

159
function htmlinline(io::IO, md::Union{Symbol,AbstractString})
4,686✔
160
    htmlesc(io, md)
4,737✔
161
end
162

163
function htmlinline(io::IO, md::Bold)
186✔
164
    withtag(io, :strong) do
186✔
165
        htmlinline(io, md.text)
186✔
166
    end
167
end
168

169
function htmlinline(io::IO, md::Italic)
429✔
170
    withtag(io, :em) do
429✔
171
        htmlinline(io, md.text)
429✔
172
    end
173
end
174

175
function htmlinline(io::IO, md::Strikethrough)
18✔
176
    withtag(io, :s) do
18✔
177
        htmlinline(io, md.text)
18✔
178
    end
179
end
180

181
function htmlinline(io::IO, md::Image)
30✔
182
    tag(io, :img, :src=>encode_uri_component(md.url), :alt=>md.alt)
30✔
183
end
184

185

186
function htmlinline(io::IO, f::Footnote)
12✔
187
    withtag(io, :a, :href => "#footnote-$(f.id)", :class => "footnote") do
12✔
188
        print(io, "[", f.id, "]")
12✔
189
    end
190
end
191

192
function htmlinline(io::IO, link::Link)
252✔
193
    withtag(io, :a, :href=>encode_uri_component(link.url)) do
252✔
194
        htmlinline(io, link.text)
252✔
195
    end
196
end
197

198
function htmlinline(io::IO, br::LineBreak)
30✔
199
    tag(io, :br)
30✔
200
    println(io)
30✔
201
end
202

203
htmlinline(io::IO, x) = tohtml(io, x)
99✔
204

205
# API
206

207
export html
208

209
"""
210
    html([io::IO], md)
211

212
Output the contents of the Markdown object `md` in HTML format, either
213
writing to an (optional) `io` stream or returning a string.
214

215
One can alternatively use `show(io, "text/html", md)` or `repr("text/html", md)`, which
216
differ in that they wrap the output in a `<div class="markdown"> ... </div>` element.
217

218
# Examples
219
```jldoctest
220
julia> html(md"hello _world_")
221
"<p>hello <em>world</em></p>\\n"
222
```
223
"""
224
html(md) = sprint(html, md)
2,214✔
225

226
function show(io::IO, ::MIME"text/html", md::MD)
3✔
227
    withtag(io, :div, :class=>"markdown") do
3✔
228
        html(io, md)
3✔
229
    end
230
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