-
Notifications
You must be signed in to change notification settings - Fork 482
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
$ not rendering properly #890
Comments
The escaping seems to be correct. My guess is that the problem is that we're outputting literal |
This continues to bite me. shell> cat src/index.md
The price is \$1.
The price is \$1 or \$2.
julia> using Documenter
julia> Documenter.makedocs(sitename = "Bug", pages = ["index.md"])
[ Info: SetupBuildDirectory: setting up build directory.
[ Info: Doctest: running doctests.
[ Info: ExpandTemplates: expanding markdown templates.
[ Info: CrossReferences: building cross-references.
[ Info: CheckDocument: running document checks.
[ Info: Populate: populating indices.
[ Info: RenderDocument: rendering document.
[ Info: HTMLWriter: rendering HTML pages. yields My motivation to fix it is now high. Any pointers on where I should go looking? |
If my original guess in #890 (comment) is correct, I think it might be enough to do the relevant escaping here Documenter.jl/src/Writers/HTMLWriter.jl Line 1649 in 6c8679b
|
So I tried the escaping thing. It was sufficient to go function mdconvert(text::AbstractString, parent; kwargs...)
if text == "\$"
return DOM.Node("$")
end
return DOM.Node(text)
end and I had to modify Documenter.jl/src/Utilities/DOM.jl Lines 271 to 290 in 6c8679b
to prevent it being escaped. But... it seems that the math engines treat The upstream issue for all of this is really: KaTeX/KaTeX#437 An easier solve is just to not use diff --git a/src/Writers/HTMLWriter.jl b/src/Writers/HTMLWriter.jl
index 4f52d9b6..c9f0c250 100644
--- a/src/Writers/HTMLWriter.jl
+++ b/src/Writers/HTMLWriter.jl
@@ -164,8 +164,8 @@ struct KaTeX <: MathEngine
function KaTeX(config::Union{Dict,Nothing} = nothing, override=false)
default = Dict(
:delimiters => [
- Dict(:left => raw"$", :right => raw"$", display => false),
- Dict(:left => raw"$$", :right => raw"$$", display => true),
+ Dict(:left => raw"\(", :right => raw"\)", display => false),
+ Dict(:left => raw"$$", :right => raw"$$", display => true),
Dict(:left => raw"\[", :right => raw"\]", display => true),
]
)
@@ -1686,7 +1686,7 @@ function mdconvert(m::Markdown.LaTeX, ::MDBlockContext; kwargs...)
@tags p
p[".math-container"](string("\\[", m.formula, "\\]"))
end
-mdconvert(m::Markdown.LaTeX, parent; kwargs...) = Tag(:span)(string('$', m.formula, '$'))
+mdconvert(m::Markdown.LaTeX, parent; kwargs...) = Tag(:span)(string("\\(", m.formula, "\\)"))
mdconvert(::Markdown.LineBreak, parent; kwargs...) = Tag(:br)()
This seems to work okay: julia> Documenter.makedocs(sitename = "Bug", pages = ["index.md"])
[ Info: SetupBuildDirectory: setting up build directory.
[ Info: Doctest: running doctests.
[ Info: ExpandTemplates: expanding markdown templates.
[ Info: CrossReferences: building cross-references.
[ Info: CheckDocument: running document checks.
[ Info: Populate: populating indices.
[ Info: RenderDocument: rendering document.
[ Info: HTMLWriter: rendering HTML pages.
shell> cat src/index.md
The price is \$1.
The price is \$1 or \$2.
Here is some $x^2$ math.
And some more \\(\sqrt x\\).
And \$1 is more than $x^2$ but \\(\sqrt x\\) is less than \$2. Is changing the inline math escape breaking? It's a change on the HTML side, so user's shouldn't see any differences. Edit: the span trick was easier: #1625 |
Hello, as of Documenter v0.27.15 this is still a problem.
|
ok, escaping with |
@sylvaticus I think you are running into #1020, which is slightly different from this issue. |
The advised way to add dollar signs to a docstring is to double escape them, but the example docstring,
renders to :
I have yet to find a nice way to get dollar signs to show up properly in both the repl and the rendered docs.
The text was updated successfully, but these errors were encountered: