Skip to content

Commit 1b47feb

Browse files
committed
Introduce MarkdownElement abstract type
It's convenient for dispatch.
1 parent 98542d7 commit 1b47feb

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

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)