Browse Source

add support for quarto Callout Blocks

pull/268/head
David Métivier 11 months ago
parent
commit
f100043b07
  1. 20
      src/Literate.jl

20
src/Literate.jl

@ -227,6 +227,25 @@ function replace_default( @@ -227,6 +227,25 @@ function replace_default(
push!(repls, r"\[([^]]+?)\]\(@id .*?\)"s => s"\1") # [foo](@id bar) => foo
# Convert Documenter admonitions to markdown quotes
r = r"^# !!! (?<type>\w+)(?: \"(?<title>.+)\")?(?<lines>(\v^# .*$)+)"m
if config["flavor"] isa QuartoFlavor
adm_to_quote = function (s)
m = match(r, s)::RegexMatch
io = IOBuffer()
print(io, "# ::: {.callout-") # to open the callout
print(io, string(m[:type]))
if (title = m[:title]; title !== nothing)
print(io, s""" title=\"""")
print(io, title)
print(io, s"""\"""")
end
print(io, "}") # not sure how to detect the Quarto `collapse` option if any
for l in eachline(IOBuffer(m[:lines]); keep = true)
print(io, replace(l, r"^# " => "# "))
end
print(io, "\n# :::") # to close the callout
return String(take!(io))
end
else
adm_to_quote = function (s)
m = match(r, s)::RegexMatch
io = IOBuffer()
@ -243,6 +262,7 @@ function replace_default( @@ -243,6 +262,7 @@ function replace_default(
end
return String(take!(io))
end
end
push!(repls, r => adm_to_quote)
end

Loading…
Cancel
Save