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

Fix escaping of dollar symbols in HTMLWriter #1625

Merged
merged 6 commits into from
Jul 6, 2021

Conversation

odow
Copy link
Collaborator

@odow odow commented Jul 4, 2021

Previously, Javascript LaTeX engines got confused trying to
distinguish between inline delimiters and dollar symbols for actual
currency. This works around the problem by wrapping (currency) dollar
symbols in a span tag.

Closes #890

I could use come pointers on how to test this properly. (Is there a way to test the output of the rendered HTML?) I got confused with the structure of /test. Here's my more-involved local test:

shell> cat src/index.md
The price is \$1.

The price is \$1 or \$2.

Here is some $x^2$ math.

The pr\$ice is \$s for some $x^2$.

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.

image

Previously, Javascript LaTeX engines got confused trying to
distinguish between inline delimiters and dollar symbols for actual
currency. This works around the problem by wrapping (currency) dollar
symbols in a span tag.
@odow odow mentioned this pull request Jul 4, 2021
@mortenpi mortenpi added Format: HTML Related to the default HTML output Type: Bug labels Jul 4, 2021
test/htmlwriter.jl Outdated Show resolved Hide resolved
@mortenpi mortenpi added this to the 0.27.4 milestone Jul 4, 2021
Copy link
Member

@mortenpi mortenpi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I think this is a clever workaround. And doesn't have the potentially breaking aspect of changing the delimiter configuration.

We don't really have good integration tests of the outputs. The best we do currently are the occursins in the example builds. Potentially you could add a few tests there -- I think having your snippet in the test/examples build would be good.

Just a passing thought, beyond the scope of this PR, but in the future we could use Gumbo to parse the generated HTML and then do some sanity checks on the AST. It worked well for generating the outdated version warnings.

@odow
Copy link
Collaborator Author

odow commented Jul 5, 2021

@mortenpi how's this?

@mortenpi
Copy link
Member

mortenpi commented Jul 6, 2021

Looks good @odow, thanks!

@odow odow mentioned this pull request Jul 6, 2021
17 tasks
@mortenpi mortenpi merged commit ab73e1c into JuliaDocs:master Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Format: HTML Related to the default HTML output Type: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

$ not rendering properly
2 participants