mirror of https://github.com/mpastell/Weave.jl
Fix \bf and \frak symbols in md2tex. Improves #181
parent
12f829a0ca
commit
bad5650027
|
@ -238,14 +238,31 @@ end
|
|||
function uc2tex(s, escape=false)
|
||||
for key in keys(latex_symbols)
|
||||
if escape
|
||||
s = replace(s, latex_symbols[key] => "(*@\\ensuremath{$key}@*)")
|
||||
s = replace(s, latex_symbols[key] => "(*@\\ensuremath{$(texify(key))}@*)")
|
||||
else
|
||||
s = replace(s, latex_symbols[key] => "\\ensuremath{$key}")
|
||||
s = replace(s, latex_symbols[key] => "\\ensuremath{$(texify(key))}")
|
||||
end
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
# Make julia symbols (\bf* etc.) valid latex
|
||||
function texify(s)
|
||||
ts = ""
|
||||
if occursin(r"^\\bf[A-Z]$", s)
|
||||
ts = replace(s, "\\bf" => "\\bm{\\mathrm{") * "}}"
|
||||
elseif startswith(s, "\\bfrak")
|
||||
ts = replace(s, "\\bfrak" => "\\bm{\\mathfrak{") * "}}"
|
||||
elseif startswith(s, "\\bf")
|
||||
ts = replace(s, "\\bf" => "\\bm{\\") * "}"
|
||||
elseif startswith(s, "\\frak")
|
||||
ts = replace(s, "\\frak" => "\\mathfrak{") * "}"
|
||||
else
|
||||
ts = s
|
||||
end
|
||||
return ts
|
||||
end
|
||||
|
||||
function format_code(result::AbstractString, docformat::JMarkdown2HTML)
|
||||
return highlight(MIME("text/html"), strip(result),
|
||||
Highlights.Lexers.JuliaLexer, docformat.formatdict[:theme])
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
\usepackage[a4paper,text={16.5cm,25.2cm},centering]{geometry}
|
||||
\usepackage{lmodern}
|
||||
\usepackage{amssymb,amsmath}
|
||||
\usepackage{bm}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{microtype}
|
||||
\usepackage{hyperref}
|
||||
|
|
|
@ -94,3 +94,8 @@ wcows = Weave.wrapline(cows)
|
|||
@test wcows == testcows
|
||||
@test length(split(wcows, "\n")[1]) == 75
|
||||
@test length(split(wcows, "\n")[2]) == 25
|
||||
|
||||
|
||||
tfied = "\\ensuremath{\\bm{\\mathrm{L}}} \\ensuremath{\\bm{\\mathfrak{F}}} \\ensuremath{\\bm{\\iota}} \\ensuremath{\\mathfrak{A}} \\ensuremath{\\bm{\\varTheta}}"
|
||||
|
||||
@test Weave.uc2tex("𝐋 𝕱 𝛊 𝔄 𝚹") == tfied
|
||||
|
|
Loading…
Reference in New Issue