diff --git a/Project.toml b/Project.toml index 0140be1..4b03e56 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "QuizQuestions" uuid = "612c44de-1021-4a21-84fb-7261cf5eb2d4" authors = ["jverzani and contributors"] -version = "0.3.20" +version = "0.3.21" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/docs/make.jl b/docs/make.jl index 52c5add..0840c38 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,6 +1,8 @@ using Documenter using QuizQuestions +ENV["QQ_LaTeX_dollar_delimiters"] = true + makedocs(sitename="QuizQuestions documentation", format = Documenter.HTML(ansicolor=true) ) diff --git a/docs/src/index.md b/docs/src/index.md index 726d54d..6ad90c5 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -59,6 +59,11 @@ numericq(answer, tol, hint="you need to be within 1/1000") ``` +!!! note "Using Documenter adjustment" + + Math markup using ``\LaTeX`` in Markdown may be done with different delimiters. There are paired dollar signs (or double dollar signs); paired `\(` and `\)` (or `\[`, `\]`) delimiters; double backticks (which require no escaping); or even `math` flavors for triple backtick blocks. When displaying ``\LaTeX`` in HTML, the paired parentheses are used. **However** with `Documenter` paired dollar signs are needed for markup used by `QuizQuestions`. + As of `v"0.3.21"`, placing the line `ENV["QQ_LaTeX_dollar_delimiters"] = true` in `make.jl` will instruct that. This package documentation illustrates. + ## Examples of question types diff --git a/src/show_methods.jl b/src/show_methods.jl index 2379392..529e1bf 100644 --- a/src/show_methods.jl +++ b/src/show_methods.jl @@ -1,7 +1,14 @@ # This is called when converting radio button labels from LaTeX -# adjust by setting ENV["QQ_LaTeX_delimiters"] +# adjust to $ by setting ENV["QQ_LaTeX_dollar_delimiters"] = true +# type piracy is being taken here!! +# Quarto --> ("\\(", "\\)") +# Weave --> ("\\(", "\\)") +# Documenter --> ("\$", "\$") +# Pluto --> ? + function Markdown.tohtml(io::IO, l::Markdown.LaTeX) - o, c = get(ENV, "QQ_LaTeX_delimiters", ("\$", "\$")) #("\\(", "\\)")) + dollars = get(ENV, "QQ_LaTeX_dollar_delimiters", "false") + o,c = dollars == "true" ? ("\$", "\$") : ("\\(", "\\)") print(io, o) # not print(io, '$', '$') print(io, l.formula) print(io, c) @@ -17,7 +24,7 @@ function _markdown_to_html(x) length(x) == 0 && return("") x = Markdown.parse(x) x = sprint(io -> Markdown.html(io, x)) - x = replace(x, r"^

"=>"", r"

$"=>"") + x = replace(x, r"\n

"=>" ", r"

$"=>" ") return x end