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

[LaTeXWriter] fix escaping in header titles #2134

Merged
merged 8 commits into from
May 26, 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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* `deploydocs` now correctly handles version symlinks where the destination directory has been deleted. (#2012)

* Page headings are now correctly escaped in `LaTeXWriter`. (#2134)

### Other

* Documenter now uses [MarkdownAST](https://github.com/JuliaDocs/MarkdownAST.jl) to internally represent Markdown documents. While this change should not lead to any visible changes to the user, it is a major refactoring of the code. Please report any novel errors or unexpected behavior you encounter when upgrading to 0.28 on the [Documenter issue tracker](https://github.com/JuliaDocs/Documenter.jl/issues). (#1892), (#1912), (#1924), (#1948)
Expand Down
4 changes: 3 additions & 1 deletion src/latex/LaTeXWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Context(io, doc) = Context{typeof(io)}(io, false, Dict(), 1, "", doc)

_print(c::Context, args...) = Base.print(c.io, args...)
_println(c::Context, args...) = Base.println(c.io, args...)
_print(io, args...) = Base.print(io, args...)
mortenpi marked this conversation as resolved.
Show resolved Hide resolved

# Labels in the TeX file are hashes of plain text labels.
# To keep the plain text label (for debugging), say _hash(x) = x
Expand Down Expand Up @@ -118,7 +119,8 @@ function render(doc::Documenter.Document, settings::LaTeX=LaTeX())
empty!(context.footnotes)
if 1 <= depth <= length(DOCUMENT_STRUCTURE)
header_type = DOCUMENT_STRUCTURE[depth]
header_text = "\n\\$(header_type){$(title)}\n"
title_text = latexesc("$title")
header_text = "\n\\$(header_type){$title_text}\n"
if isempty(filename)
_println(context, header_text)
else
Expand Down
5 changes: 3 additions & 2 deletions test/examples/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,8 @@ examples_latex_doc = if "latex" in EXAMPLE_BUILDS
"latex.md",
"unicode.md",
hide("hidden.md"),
"example-output.md",
# The title override tests that we escape headings correctly
"`@example_output`" => "example-output.md",
],
# SVG images nor code blocks in footnotes are allowed in LaTeX
# "Manual" => [
Expand Down Expand Up @@ -593,7 +594,7 @@ examples_latex_texonly_doc = if "latex_texonly" in EXAMPLE_BUILDS
sitename = "Documenter LaTeX",
root = examples_root,
build = "builds/latex_texonly",
pages = htmlbuild_pages = Any[
pages = Any[
"General" => [
"index.md",
"latex.md",
Expand Down