-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathmarkdown.jl
36 lines (32 loc) · 996 Bytes
/
markdown.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
format_md(text::AbstractString; style::AbstractStyle = DefaultStyle(), kwargs...)
Normalizes the Markdown source and formats Julia code blocks.
See [`format_text`](@ref) for description of formatting options.
"""
function format_md(text::AbstractString; style::AbstractStyle = DefaultStyle(), kwargs...)
return format_md(text, style; kwargs...)
end
function format_md(text::AbstractString, style::AbstractStyle; kwargs...)
if isempty(text)
return text
end
opts = Options(; merge(options(style), kwargs)...)
return format_md(text, style, opts)
end
function format_md(text::AbstractString, style::AbstractStyle, opts::Options)
markdown(
enable!(
Parser(),
[
AdmonitionRule(),
FootnoteRule(),
MathRule(),
TableRule(),
FrontMatterRule(),
FormatRule(style, opts),
],
)(
text,
),
)
end