You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An abstract syntax tree representation of Markdown documents in Julia.
8
+
A Julia package for working with Markdown documents in an [abstract syntax tree][ast-wiki] representation.
9
+
As an example, the following Markdown
10
+
11
+
```markdown
12
+
# Markdown document
13
+
14
+
Hello [world](https://example.com/)!
15
+
```
16
+
17
+
can be represented as the following tree (in the [`@ast` macro DSL][mdast-astmacro]) using MarkdownAST
18
+
19
+
```julia
20
+
using MarkdownAST:@ast, Document, Heading, Paragraph, Link
21
+
ast =@astDocument() do
22
+
Heading(1) do
23
+
"Markdown document"
24
+
end
25
+
Paragraph() do
26
+
"Hello "
27
+
Link("https://example.com/", "") do
28
+
"world"
29
+
end
30
+
"!"
31
+
end
32
+
end
33
+
```
34
+
35
+
and the resulting [`Node` object][mdast-node] that contains information about the whole tree can be accessed, traversed, and, if need be, modified, e.g.
36
+
37
+
```julia-repl
38
+
julia> for node in ast.children
39
+
println("$(node.element) with $(length(node.children)) child nodes")
40
+
end
41
+
Heading(1) with 1 child nodes
42
+
Paragraph() with 3 child nodes
43
+
```
44
+
45
+
See the [documentation][docs-stable-url] for the full descriptions of the APIs that are available.
46
+
47
+
## Credits
48
+
49
+
The core parts of this package heavily derive from the [CommonMark.jl](https://github.com/MichaelHatherly/CommonMark.jl) package.
50
+
Also, this packages does not provide a parser, and the users are encouraged to check out CommonMark.jl for that purpose.
0 commit comments