Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better means to adjust latex delimiters #41

Merged
merged 1 commit into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QuizQuestions"
uuid = "612c44de-1021-4a21-84fb-7261cf5eb2d4"
authors = ["jverzani <[email protected]> and contributors"]
version = "0.3.20"
version = "0.3.21"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
2 changes: 2 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Documenter
using QuizQuestions

ENV["QQ_LaTeX_dollar_delimiters"] = true

makedocs(sitename="QuizQuestions documentation",
format = Documenter.HTML(ansicolor=true)
)
Expand Down
5 changes: 5 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 10 additions & 3 deletions src/show_methods.jl
Original file line number Diff line number Diff line change
@@ -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" ? ("\$", "\$") : ("\\(", "\\)")

Check warning on line 11 in src/show_methods.jl

View check run for this annotation

Codecov / codecov/patch

src/show_methods.jl#L10-L11

Added lines #L10 - L11 were not covered by tests
print(io, o) # not print(io, '$', '$')
print(io, l.formula)
print(io, c)
Expand All @@ -17,7 +24,7 @@
length(x) == 0 && return("")
x = Markdown.parse(x)
x = sprint(io -> Markdown.html(io, x))
x = replace(x, r"^<p>"=>"", r"</p>$"=>"")
x = replace(x, r"\n<p>"=>" ", r"</p>$"=>" ")
return x
end

Expand Down
Loading