mirror of https://github.com/mpastell/Weave.jl
revert improvements to tex rendering
parent
9875bc10f7
commit
b5477d27ff
|
@ -22,7 +22,6 @@ Base.@kwdef mutable struct JMarkdown2tex <: TexFormat
|
|||
fig_env = nothing
|
||||
highlight_theme = nothing
|
||||
template = normpath(TEMPLATE_DIR, "md2pdf.tpl")
|
||||
tex_deps = ""
|
||||
end
|
||||
register_format!("md2tex", JMarkdown2tex())
|
||||
register_format!("md2pdf", JMarkdown2tex())
|
||||
|
@ -45,7 +44,6 @@ Base.@kwdef mutable struct Tex <: TexFormat
|
|||
out_height = nothing
|
||||
highlight_theme = nothing
|
||||
template = normpath(TEMPLATE_DIR, "md2pdf.tpl")
|
||||
tex_deps = ""
|
||||
end
|
||||
register_format!("tex", Tex())
|
||||
|
||||
|
@ -70,27 +68,21 @@ Base.@kwdef mutable struct TexMinted <: TexFormat
|
|||
fig_pos = "htpb"
|
||||
highlight_theme = nothing
|
||||
template = normpath(TEMPLATE_DIR, "md2pdf.tpl")
|
||||
tex_deps = "\\usepackage{minted}"
|
||||
end
|
||||
register_format!("texminted", TexMinted())
|
||||
|
||||
|
||||
highlight_str(docformat::TexFormat) = ""
|
||||
highlight_str(docformat::JMarkdown2tex) =
|
||||
get_highlight_stylesheet(MIME("text/latex"), docformat.highlight_theme)
|
||||
|
||||
function render_doc(docformat::TexFormat, body, doc, _)
|
||||
function render_doc(docformat::JMarkdown2tex, body, doc, _)
|
||||
return Mustache.render(
|
||||
get_tex_template(docformat.template);
|
||||
body = body,
|
||||
highlight = highlight_str(docformat),
|
||||
tex_deps = docformat.tex_deps,
|
||||
highlight = get_highlight_stylesheet(MIME("text/latex"), docformat.highlight_theme),
|
||||
[Pair(Symbol(k), v) for (k, v) in doc.header]...,
|
||||
)
|
||||
end
|
||||
|
||||
# very similar to export to html
|
||||
function format_chunk(chunk::DocChunk, docformat::TexFormat)
|
||||
function format_chunk(chunk::DocChunk, docformat::JMarkdown2tex)
|
||||
out = IOBuffer()
|
||||
io = IOBuffer()
|
||||
for inline in chunk.content
|
||||
|
@ -110,7 +102,7 @@ function format_chunk(chunk::DocChunk, docformat::TexFormat)
|
|||
return docformat.keep_unicode ? out : uc2tex(out)
|
||||
end
|
||||
|
||||
function format_output(result, docformat::TexFormat)
|
||||
function format_output(result, docformat::JMarkdown2tex)
|
||||
# Highligts has some extra escaping defined, eg of $, ", ...
|
||||
result_escaped = sprint(
|
||||
(io, x) ->
|
||||
|
@ -121,14 +113,8 @@ function format_output(result, docformat::TexFormat)
|
|||
return result_escaped
|
||||
end
|
||||
|
||||
|
||||
# Highlight code is currently only compatible with lstlistings (JMarkdown2tex)
|
||||
highlight_code(code, docformat::TexFormat) = code
|
||||
highlight_code(code, docformat::JMarkdown2tex) =
|
||||
highlight_code(MIME("text/latex"), code, docformat.highlight_theme)
|
||||
|
||||
function format_code(code, docformat::TexFormat)
|
||||
ret = highlight_code(code, docformat)
|
||||
function format_code(code, docformat::JMarkdown2tex)
|
||||
ret = highlight_code(MIME("text/latex"), code, docformat.highlight_theme)
|
||||
docformat.keep_unicode || return uc2tex(ret)
|
||||
return ret
|
||||
end
|
||||
|
@ -147,11 +133,7 @@ function uc2tex(s, escape = false)
|
|||
end
|
||||
|
||||
|
||||
# return "\\begin{minted}[mathescape, fontsize=\\small, xleftmargin=0.5em]{julia}\n$result\n\\end{minted}\n"
|
||||
format_termchunk(chunk, docformat::TexFormat) =
|
||||
string(docformat.termstart, chunk.output, docformat.termend, '\n')
|
||||
|
||||
#should_render(chunk) ? highlight_term(MIME("text/latex"), , docformat.highlight_theme) : ""
|
||||
#should_render(chunk) ? highlight_term(MIME("text/latex"), , docformat.highlight_theme) : ""
|
||||
format_termchunk(chunk, docformat::JMarkdown2tex) =
|
||||
should_render(chunk) ? highlight_term(MIME("text/latex"), chunk.output, docformat.highlight_theme) : ""
|
||||
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
\usepackage{graphicx}
|
||||
\usepackage{microtype}
|
||||
\usepackage{hyperref}
|
||||
{{#:tex_deps}}
|
||||
{{{ :tex_deps }}}
|
||||
{{/:tex_deps}}
|
||||
|
||||
\setlength{\parindent}{0pt}
|
||||
\setlength{\parskip}{1.2ex}
|
||||
|
|
Loading…
Reference in New Issue