mirror of https://github.com/mpastell/Weave.jl
Format inline chunks
parent
e10f27b26f
commit
a7cd923e27
|
@ -105,22 +105,32 @@ function get_titleblock(doc::WeaveDoc)
|
|||
end
|
||||
|
||||
function strip_header(chunk::DocChunk)
|
||||
if ismatch(r"^---$(?<header>.+)^---$"ms, chunk.content)
|
||||
chunk.content = lstrip(replace(chunk.content, r"^---$(?<header>.+)^---$"ms, ""))
|
||||
if ismatch(r"^---$(?<header>.+)^---$"ms, chunk.content[1].content)
|
||||
chunk.content[1].content = lstrip(replace(chunk.content[1].content, r"^---$(?<header>.+)^---$"ms, ""))
|
||||
end
|
||||
return chunk
|
||||
end
|
||||
|
||||
function format_chunk(chunk::DocChunk, formatdict, docformat)
|
||||
return chunk.content
|
||||
return join([format_inline(c) for c in chunk.content], "")
|
||||
end
|
||||
|
||||
function format_inline(inline::InlineText)
|
||||
return inline.content
|
||||
end
|
||||
|
||||
function format_inline(inline::InlineCode)
|
||||
isempty(inline.rich_output) || return inline.rich_output
|
||||
isempty(inline.figures) || return inline.figures[end]
|
||||
isempty(inline.output) || return inline.output
|
||||
end
|
||||
|
||||
function format_chunk(chunk::DocChunk, formatdict, docformat::JMarkdown2HTML)
|
||||
m = Base.Markdown.parse(chunk.content)
|
||||
text = format_chunk(chunk, formatdict, nothing)
|
||||
m = Base.Markdown.parse(text)
|
||||
return string(Documenter.Writers.HTMLWriter.mdconvert(m))
|
||||
end
|
||||
|
||||
|
||||
#Fixes to Base latex writer
|
||||
function Base.Markdown.latex(io::IO, md::Base.Markdown.Paragraph)
|
||||
println(io)
|
||||
|
@ -144,7 +154,8 @@ end
|
|||
|
||||
|
||||
function format_chunk(chunk::DocChunk, formatdict, docformat::JMarkdown2tex)
|
||||
m = Base.Markdown.parse(chunk.content)
|
||||
text = format_chunk(chunk, formatdict, nothing)
|
||||
m = Base.Markdown.parse(text)
|
||||
return Base.Markdown.latex(m)
|
||||
end
|
||||
|
||||
|
|
|
@ -300,11 +300,10 @@ function parse_inline(text::AbstractString, inline_ex::Regex)
|
|||
|
||||
for ic in inline_chunks
|
||||
s = ic.offset
|
||||
doc = InlineText(text[e:s], e, s)
|
||||
doc = InlineText(text[e:(s-1)], e, s-1)
|
||||
push!(res, doc)
|
||||
e = s + length(ic.match)
|
||||
push!(res, InlineCode(ic.captures[1], s, e))
|
||||
|
||||
end
|
||||
push!(res, InlineText(text[e:end], e, length(text)))
|
||||
|
||||
|
|
Loading…
Reference in New Issue