MarkdownAST.jl

Abstract syntax tree representation of Markdown documents in Julia
Author JuliaDocs
Popularity
13 Stars
Updated Last
1 Year Ago
Started In
May 2022

MarkdownAST

Version Documentation GitHub Actions CI CodeCov PkgEval

A Julia package for working with Markdown documents in an abstract syntax tree representation. As an example, the following Markdown

# Markdown document Hello [world](https://example.com/)!

can be represented as the following tree (in the @ast macro DSL) using MarkdownAST

using MarkdownAST: @ast, Document, Heading, Paragraph, Link ast = @ast Document() do Heading(1) do "Markdown document" end Paragraph() do "Hello " Link("https://example.com/", "") do "world" end "!" end end

and the resulting Node object that contains information about the whole tree can be accessed, traversed, and, if need be, modified, e.g.

julia> for node in ast.children println("$(node.element) with $(length(node.children)) child nodes") end Heading(1) with 1 child nodes Paragraph() with 3 child nodes

See the documentation for the full descriptions of the APIs that are available.

Credits

The core parts of this package heavily derive from the CommonMark.jl package. Also, this packages does not provide a parser, and the users are encouraged to check out CommonMark.jl for that purpose.