reorder WeaveFormat field defs

pull/350/head
Shuhei Kadowaki 2020-06-02 15:31:18 +09:00
parent 0bdab33630
commit 19b4a7974f
4 changed files with 76 additions and 68 deletions

View File

@ -5,20 +5,21 @@ abstract type HTMLFormat <: WeaveFormat end
Base.@kwdef mutable struct JMarkdown2HTML <: HTMLFormat
description = "Julia markdown to html"
extension = "html"
codestart = "\n"
codeend = "\n"
outputstart = "<pre class=\"output\">"
outputend = "</pre>\n"
fig_ext = ".png"
mimetypes = ["image/png", "image/jpg", "image/svg+xml",
"text/html", "text/markdown", "text/plain"]
extension = "html"
termstart = codestart
termend = codeend
outputstart = "<pre class=\"output\">"
outputend = "</pre>\n"
mimetypes = ["image/png", "image/jpg", "image/svg+xml",
"text/html", "text/markdown", "text/plain"]
fig_ext = ".png"
out_width = nothing
out_height = nothing
fig_pos = nothing
fig_env = nothing
# specials
template = nothing
stylesheet = nothing
highlight_theme = nothing
@ -39,16 +40,16 @@ get_stylesheet(path::AbstractString) = read(path, String)
Base.@kwdef mutable struct Pandoc2HTML <: HTMLFormat
description = "Markdown to HTML (requires Pandoc 2)"
extension = "md"
codestart = "\n"
codeend = "\n"
outputstart = "\n"
outputend = "\n"
fig_ext = ".png"
extension = "md"
mimetypes = ["image/png", "image/svg+xml", "image/jpg",
"text/html", "text/markdown", "text/plain"]
termstart = codestart
termend = codeend
outputstart = "\n"
outputend = "\n"
mimetypes = ["image/png", "image/svg+xml", "image/jpg",
"text/html", "text/markdown", "text/plain"]
fig_ext = ".png"
out_width = nothing
out_height = nothing
fig_pos = nothing

View File

@ -5,20 +5,22 @@ abstract type MarkdownFormat <: WeaveFormat end
Base.@kwdef mutable struct GitHubMarkdown <: MarkdownFormat
description = "GitHub markdown"
extension = "md"
codestart = "````julia"
codeend = "````\n\n"
termstart = codestart
termend = codeend
outputstart = "````"
outputend = "````\n\n"
fig_ext = ".png"
extension = "md"
mimetypes = ["image/png", "image/svg+xml", "image/jpg",
"text/markdown", "text/plain"]
termstart = codestart
termend = codeend
out_width = nothing
out_height = nothing
fig_pos = nothing
fig_env = nothing
# specials
preserve_header = true
end
register_format!("github", GitHubMarkdown())
@ -49,20 +51,22 @@ end
Base.@kwdef mutable struct Hugo <: MarkdownFormat
description = "Hugo markdown (using shortcodes)"
extension = "md"
codestart = "````julia"
codeend = "````\n\n"
outputstart = "````"
outputend = "````\n\n"
fig_ext = ".png"
extension = "md"
uglyURLs = false # if `false`, prepend figure path by `..`
mimetypes = default_mime_types
termstart = codestart
termend = codeend
outputstart = "````"
outputend = "````\n\n"
mimetypes = default_mime_types
fig_ext = ".png"
out_width = nothing
out_height = nothing
fig_pos = nothing
fig_env = nothing
# specials
preserve_header = true
uglyURLs = false # if `false`, prepend figure path by `..`
end
register_format!("hugo", Hugo())
@ -85,19 +89,21 @@ end
Base.@kwdef mutable struct MultiMarkdown <: MarkdownFormat
description = "MultiMarkdown"
extension = "md"
codestart = "````julia"
codeend = "````\n\n"
outputstart = "````"
outputend = "````\n\n"
fig_ext = ".png"
extension = "md"
termstart = codestart
termend = codeend
outputstart = "````"
outputend = "````\n\n"
mimetypes = default_mime_types
fig_ext = ".png"
out_width = nothing
out_height = nothing
fig_pos = nothing
fig_env = nothing
mimetypes = default_mime_types
# specials
preserve_header = true
end
register_format!("multimarkdown", MultiMarkdown())
@ -137,17 +143,17 @@ end
Base.@kwdef mutable struct Pandoc <: MarkdownFormat
description = "Pandoc markdown"
extension = "md"
codestart = "~~~~{.julia}"
codeend = "~~~~~~~~~~~~~\n\n"
termstart = codestart
termend = codeend
outputstart = "~~~~"
outputend = "~~~~\n\n"
fig_ext = ".png"
extension = "md"
# Prefer png figures for markdown conversion, svg doesn't work with latex
mimetypes = ["image/png", "image/jpg", "image/svg+xml",
"text/markdown", "text/plain"]
termstart = codestart
termend = codeend
fig_ext = ".png"
out_width = nothing
out_height = nothing
fig_pos = nothing

View File

@ -7,23 +7,24 @@ set_rendering_options!(docformat::TexFormat; keep_unicode = false, kwargs...) =
Base.@kwdef mutable struct JMarkdown2tex <: TexFormat
description = "Julia markdown to latex"
extension = "tex"
codestart = ""
codeend = ""
outputstart = "\\begin{lstlisting}"
outputend = "\\end{lstlisting}\n"
fig_ext = ".pdf"
extension = "tex"
mimetypes = ["application/pdf", "image/png", "image/jpg",
"text/latex", "text/markdown", "text/plain"]
keep_unicode = false
termstart = codestart
termend = codeend
outputstart = "\\begin{lstlisting}"
outputend = "\\end{lstlisting}\n"
mimetypes = ["application/pdf", "image/png", "image/jpg",
"text/latex", "text/markdown", "text/plain"]
fig_ext = ".pdf"
out_width = "\\linewidth"
out_height = nothing
fig_pos = nothing
fig_env = nothing
# specials
highlight_theme = nothing
template = normpath(TEMPLATE_DIR, "md2pdf.tpl")
template = nothing
keep_unicode = false
end
register_format!("md2tex", JMarkdown2tex())
register_format!("md2pdf", JMarkdown2tex())
@ -48,42 +49,41 @@ end
Base.@kwdef mutable struct Tex <: TexFormat
description = "Latex with custom code environments"
extension = "tex"
codestart = "\\begin{juliacode}"
codeend = "\\end{juliacode}"
outputstart = "\\begin{juliaout}"
outputend = "\\end{juliaout}"
termstart = "\\begin{juliaterm}"
termend = "\\end{juliaterm}"
fig_ext = ".pdf"
extension = "tex"
fig_env = "figure"
fig_pos = "htpb"
outputstart = "\\begin{juliaout}"
outputend = "\\end{juliaout}"
mimetypes = ["application/pdf", "image/png", "text/latex", "text/plain"]
keep_unicode = false
fig_ext = ".pdf"
out_width = "\\linewidth"
out_height = nothing
fig_pos = "htpb"
fig_env = "figure"
# specials
keep_unicode = false
end
register_format!("tex", Tex())
Base.@kwdef mutable struct TexMinted <: TexFormat
description = "Latex using minted for highlighting"
codestart =
"\\begin{minted}[mathescape, fontsize=\\small, xleftmargin=0.5em]{julia}"
codeend = "\\end{minted}"
outputstart =
"\\begin{minted}[fontsize=\\small, xleftmargin=0.5em, mathescape, frame = leftline]{text}"
outputend = "\\end{minted}"
fig_ext = ".pdf"
extension = "tex"
mimetypes = ["application/pdf", "image/png", "text/latex", "text/plain"]
keep_unicode = false
termstart =
"\\begin{minted}[fontsize=\\footnotesize, xleftmargin=0.5em, mathescape]{jlcon}"
codestart = "\\begin{minted}[mathescape, fontsize=\\small, xleftmargin=0.5em]{julia}"
codeend = "\\end{minted}"
termstart = "\\begin{minted}[fontsize=\\footnotesize, xleftmargin=0.5em, mathescape]{jlcon}"
termend = "\\end{minted}"
outputstart = "\\begin{minted}[fontsize=\\small, xleftmargin=0.5em, mathescape, frame = leftline]{text}"
outputend = "\\end{minted}"
mimetypes = ["application/pdf", "image/png", "text/latex", "text/plain"]
fig_ext = ".pdf"
out_width = "\\linewidth"
out_height = nothing
fig_env = "figure"
fig_pos = "htpb"
fig_env = "figure"
# specials
keep_unicode = false
end
register_format!("texminted", TexMinted())

View File

@ -3,20 +3,21 @@
Base.@kwdef mutable struct Rest <: WeaveFormat
description = "reStructuredText and Sphinx"
extension = "rst"
codestart = ".. code-block:: julia\n"
codeend = "\n\n"
outputstart = "::\n"
outputend = "\n\n"
indent = 4
fig_ext = ".png"
extension = "rst"
termstart = codestart
termend = codeend
outputstart = "::\n"
outputend = "\n\n"
mimetypes = default_mime_types
fig_ext = ".png"
out_width = "15 cm"
out_height = nothing
fig_pos = nothing
fig_env = nothing
mimetypes = default_mime_types
# specials
indent = 4
end
register_format!("rst", Rest())
@ -49,19 +50,19 @@ end
# asciidoc -b html5 -a source-highlighter=pygments ...
Base.@kwdef mutable struct AsciiDoc <: WeaveFormat
description = "AsciiDoc"
extension = "txt"
codestart = "[source,julia]\n--------------------------------------"
codeend = "--------------------------------------\n\n"
outputstart = "--------------------------------------"
outputend = "--------------------------------------\n\n"
fig_ext = ".png"
extension = "txt"
termstart = codestart
termend = codeend
outputstart = "--------------------------------------"
outputend = "--------------------------------------\n\n"
mimetypes = default_mime_types
fig_ext = ".png"
out_width = "600"
out_height = nothing
fig_pos = nothing
fig_env = nothing
mimetypes = default_mime_types
end
register_format!("asciidoc", AsciiDoc())