Skip to content

Commit 1614e11

Browse files
authored
Styled markdown, with a few tweaks (#51928)
With `StyledStrings` and `JuliaSyntaxHighlighting` we can make the rendering of `Markdown.MD`: - prettier - customisable - more composable Let's do so!
2 parents a267cec + ada49c3 commit 1614e11

File tree

20 files changed

+249
-165
lines changed

20 files changed

+249
-165
lines changed

deps/checksums/StyledStrings-ac472083359dde956aed8c61d43b8158ac84d9ce.tar.gz/md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

deps/checksums/StyledStrings-ac472083359dde956aed8c61d43b8158ac84d9ce.tar.gz/sha512

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a02cd2c8bedd83b74917cf3821c89f46
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2e86daa832533f0369e66e359d7d8f47002f93525f83233c809007a13dfd05a201bcd273b3cb4f3eba2586e98cc9afa43c242f67dc18b91fc898d98a0bd8fde9

doc/Manifest.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2
114114
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
115115
version = "8.6.0+0"
116116

117+
[[deps.JuliaSyntaxHighlighting]]
118+
deps = ["StyledStrings"]
119+
uuid = "dc6e5ff7-fb65-4e79-a425-ec3bc9c03011"
120+
117121
[[deps.LibGit2]]
118122
deps = ["LibGit2_jll", "NetworkOptions", "Printf", "SHA"]
119123
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
@@ -145,7 +149,7 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
145149
version = "1.11.0"
146150

147151
[[deps.Markdown]]
148-
deps = ["Base64"]
152+
deps = ["Base64", "JuliaSyntaxHighlighting", "StyledStrings"]
149153
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
150154
version = "1.11.0"
151155

stdlib/Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ uuid = "3a97d323-0669-5f0c-9066-3539efd106a3"
140140
version = "4.2.1+0"
141141

142142
[[deps.Markdown]]
143-
deps = ["Base64"]
143+
deps = ["Base64", "JuliaSyntaxHighlighting", "StyledStrings"]
144144
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
145145
version = "1.11.0"
146146

stdlib/Markdown/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ version = "1.11.0"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
7+
StyledStrings = "f489334b-da3d-4c2e-b8f0-e476e12c162b"
8+
JuliaSyntaxHighlighting = "dc6e5ff7-fb65-4e79-a425-ec3bc9c03011"
79

810
[extras]
911
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

stdlib/Markdown/src/Common/Common.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
abstract type MarkdownElement end
4+
35
include("block.jl")
46
include("inline.jl")
57

stdlib/Markdown/src/Common/block.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Paragraphs
55
# ––––––––––
66

7-
mutable struct Paragraph
7+
mutable struct Paragraph <: MarkdownElement
88
content
99
end
1010

@@ -39,7 +39,7 @@ end
3939
# Headers
4040
# –––––––
4141

42-
mutable struct Header{level}
42+
mutable struct Header{level} <: MarkdownElement
4343
text
4444
end
4545

@@ -95,7 +95,7 @@ end
9595
# Code
9696
# ––––
9797

98-
mutable struct Code
98+
mutable struct Code <: MarkdownElement
9999
language::String
100100
code::String
101101
end
@@ -124,7 +124,7 @@ end
124124
# Footnote
125125
# --------
126126

127-
mutable struct Footnote
127+
mutable struct Footnote <: MarkdownElement
128128
id::String
129129
text
130130
end
@@ -159,7 +159,7 @@ end
159159
# Quotes
160160
# ––––––
161161

162-
mutable struct BlockQuote
162+
mutable struct BlockQuote <: MarkdownElement
163163
content
164164
end
165165

@@ -188,7 +188,7 @@ end
188188
# Admonitions
189189
# -----------
190190

191-
mutable struct Admonition
191+
mutable struct Admonition <: MarkdownElement
192192
category::String
193193
title::String
194194
content::Vector
@@ -246,7 +246,7 @@ end
246246
# Lists
247247
# –––––
248248

249-
mutable struct List
249+
mutable struct List <: MarkdownElement
250250
items::Vector{Any}
251251
ordered::Int # `-1` is unordered, `>= 0` is ordered.
252252
loose::Bool # TODO: Renderers should use this field
@@ -332,7 +332,7 @@ pushitem!(list, buffer) = push!(list.items, parse(String(take!(buffer))).content
332332
# HorizontalRule
333333
# ––––––––––––––
334334

335-
mutable struct HorizontalRule
335+
mutable struct HorizontalRule <: MarkdownElement
336336
end
337337

338338
function horizontalrule(stream::IO, block::MD)

stdlib/Markdown/src/Common/inline.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Emphasis
55
# ––––––––
66

7-
mutable struct Italic
7+
mutable struct Italic <: MarkdownElement
88
text
99
end
1010

@@ -20,7 +20,7 @@ function underscore_italic(stream::IO, md::MD)
2020
return result === nothing ? nothing : Italic(parseinline(result, md))
2121
end
2222

23-
mutable struct Bold
23+
mutable struct Bold <: MarkdownElement
2424
text
2525
end
2626

@@ -66,7 +66,7 @@ end
6666
# Images & Links
6767
# ––––––––––––––
6868

69-
mutable struct Image
69+
mutable struct Image <: MarkdownElement
7070
url::String
7171
alt::String
7272
end
@@ -85,7 +85,7 @@ function image(stream::IO, md::MD)
8585
end
8686
end
8787

88-
mutable struct Link
88+
mutable struct Link <: MarkdownElement
8989
text
9090
url::String
9191
end
@@ -156,7 +156,7 @@ end
156156
# Punctuation
157157
# –––––––––––
158158

159-
mutable struct LineBreak end
159+
mutable struct LineBreak <: MarkdownElement end
160160

161161
@trigger '\\' ->
162162
function linebreak(stream::IO, md::MD)

0 commit comments

Comments
 (0)