rename files and include location + move texify

pull/350/head
Jonas Isensee 2020-05-31 18:04:40 +02:00
parent b5477d27ff
commit 543f99a915
4 changed files with 31 additions and 27 deletions

View File

@ -341,12 +341,7 @@ include("display_methods.jl")
include("reader/reader.jl")
include("run.jl")
include("cache.jl")
include("rendering/format.jl")
include("rendering/common.jl")
include("rendering/htmlformats.jl")
include("rendering/markdownformats.jl")
include("rendering/texformats.jl")
include("rendering/variousformats.jl")
include("rendering/rendering.jl")
include("pandoc.jl")
include("converter.jl")

View File

@ -113,21 +113,6 @@ format_code(code, docformat) = code
format_output(result, docformat) = result
# Make julia symbols (\bf* etc.) valid latex
function texify(s)
return if occursin(r"^\\bf[A-Z]$", s)
replace(s, "\\bf" => "\\bm{\\mathrm{") * "}}"
elseif startswith(s, "\\bfrak")
replace(s, "\\bfrak" => "\\bm{\\mathfrak{") * "}}"
elseif startswith(s, "\\bf")
replace(s, "\\bf" => "\\bm{\\") * "}"
elseif startswith(s, "\\frak")
replace(s, "\\frak" => "\\mathfrak{") * "}"
else
s
end
end
function format_termchunk(chunk, docformat)
return if should_render(chunk)
string(docformat.termstart, chunk.output, '\n', docformat.termend, '\n')

View File

@ -1,7 +1,11 @@
# TODO:
# - 1. do assertions for definition mandatory fields in `@define_format` macro
# - 2. implement fallback format/rendering functions in format.jl
# - 3. export this as public API
# - 1. Improve argument handling
# - 2. Update code to use UnPack.jl to make it more readable
# - 3. Export new interface
# - 4. Document Interface
using Mustache, Highlights, .WeaveMarkdown, Markdown, Dates, Pkg
using REPL.REPLCompletions: latex_symbols
const FORMATS = Dict{String,WeaveFormat}()
@ -10,9 +14,6 @@ const FORMATS = Dict{String,WeaveFormat}()
register_format!(format_name::AbstractString, format::WeaveFormat) = push!(FORMATS, format_name => format)
register_format!(_,format) = error("Format needs to be a subtype of WeaveFormat.")
using Mustache, Highlights, .WeaveMarkdown, Markdown, Dates, Pkg
using REPL.REPLCompletions: latex_symbols
function format(doc; css = nothing)
docformat = doc.format
@ -46,3 +47,10 @@ get_highlight_stylesheet(mime, highlight_theme) =
get_highlight_stylesheet(mime, get_highlight_theme(highlight_theme))
get_highlight_stylesheet(mime, highlight_theme::Type{<:Highlights.AbstractTheme}) =
sprint((io, x) -> Highlights.stylesheet(io, mime, x), highlight_theme)
include("common.jl")
include("htmlformats.jl")
include("texformats.jl")
include("variousformats.jl")
include("markdownformats.jl")

View File

@ -206,3 +206,19 @@ function md_length_to_latex(def, reference)
end
return def
end
# Make julia symbols (\bf* etc.) valid latex
function texify(s)
return if occursin(r"^\\bf[A-Z]$", s)
replace(s, "\\bf" => "\\bm{\\mathrm{") * "}}"
elseif startswith(s, "\\bfrak")
replace(s, "\\bfrak" => "\\bm{\\mathfrak{") * "}}"
elseif startswith(s, "\\bf")
replace(s, "\\bf" => "\\bm{\\") * "}"
elseif startswith(s, "\\frak")
replace(s, "\\frak" => "\\mathfrak{") * "}"
else
s
end
end