Skip to content

Commit 407a817

Browse files
Fix LaTeXWriter with local images on Windows (JuliaDocs#2708)
1 parent 2f3a49b commit 407a817

File tree

5 files changed

+96
-38
lines changed

5 files changed

+96
-38
lines changed

.github/workflows/CI.yml

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,44 @@ jobs:
6161
path-to-lcov: lcov.info
6262

6363
latex:
64-
name: "PDF/LaTeX backend"
65-
runs-on: ubuntu-latest
64+
name: "PDF/LaTeX backend - ${{ matrix.os }}"
65+
runs-on: ${{ matrix.os }}
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
os:
70+
- ubuntu-latest
71+
- windows-latest
6672
steps:
6773
- uses: actions/checkout@v4
74+
- name: "Download and install DejaVu fonts"
75+
run: |
76+
Invoke-WebRequest "https://github.com/dejavu-fonts/dejavu-fonts/releases/download/version_2_37/dejavu-fonts-ttf-2.37.zip" -OutFile "DejaVu.zip"
77+
Expand-Archive -Path "DejaVu.zip" -DestinationPath "."
78+
$fonts = (New-Object -ComObject Shell.Application).Namespace(0x14)
79+
foreach ($file in gci -Path ".\dejavu-fonts-ttf-2.37\ttf" "*.ttf")
80+
{
81+
$fonts.CopyHere($file.fullname)
82+
}
83+
if: matrix.os == 'windows-latest'
84+
- uses: actions/setup-python@v5
85+
with:
86+
python-version: "3.13"
87+
if: matrix.os == 'windows-latest'
88+
- name: "install pygments for tectonic"
89+
run: pip install pygments
90+
if: matrix.os == 'windows-latest'
91+
- uses: teatimeguest/setup-texlive-action@v3
92+
with:
93+
packages: |
94+
scheme-medium
95+
hyperref
96+
minted
97+
newunicodechar
98+
transparent
99+
upquote
100+
tabulary
101+
tcolorbox
68102
- uses: julia-actions/setup-julia@v2
69103
with:
70104
version: '1'
@@ -74,8 +108,6 @@ jobs:
74108
run: |
75109
using Pkg
76110
Pkg.instantiate()
77-
Pkg.develop(PackageSpec(path=pwd()))
78-
Pkg.add(["IOCapture", "tectonic_jll"])
79111
- name: Run test/examples/tests_latex.jl
80112
run: julia --color=yes --project=test/examples --code-coverage test/examples/tests_latex.jl
81113
- uses: julia-actions/julia-processcoverage@v1
@@ -93,7 +125,7 @@ jobs:
93125
path-to-lcov: lcov.info
94126
- uses: actions/upload-artifact@v4
95127
with:
96-
name: PDFs
128+
name: "PDFs-${{ matrix.os }}"
97129
path: test/examples/builds/*/*.pdf
98130

99131
themes:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## Unreleased
7+
8+
### Fixed
9+
10+
* Fixed an issue when building PDFs with local images on Windows. ([#2434])
11+
612
## Version [v1.11.0] - 2025-05-09
713

814
### Added

src/latex/LaTeXWriter.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function render(doc::Documenter.Document, settings::LaTeX = LaTeX())
110110
if isempty(doc.user.sitename) # otherwise, the latex compiler will terminate with a cryptic "There's no line here to end" error
111111
error(
112112
"""
113-
LaTeXWriter needs a non-empty `sitename` passed to `makedocs`, otherwise the LaTeX build will error!
113+
LaTeXWriter needs a non-empty `sitename` passed to `makedocs`, otherwise the LaTeX build will error!
114114
Please pass e.g. `sitename = "Some Site Name"` as a keyword argument to `makedocs`.
115115
"""
116116
)
@@ -735,7 +735,7 @@ function latex(io::Context, node::Node, image::Documenter.LocalImage)
735735
wrapblock(io, "figure") do
736736
_println(io, "\\centering")
737737
wrapinline(io, "includegraphics[max width=\\linewidth]") do
738-
_print(io, image.path)
738+
_print(io, replace(image.path, "\\" => "/"))
739739
end
740740
_println(io)
741741
wrapinline(io, "caption") do

test/examples/Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[deps]
2+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
IOCapture = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
4+
tectonic_jll = "d7dd28d6-a5e6-559c-9131-7eb760cdacc5"
5+
6+
[sources]
7+
Documenter = {path = "../.."}

test/examples/tests_latex.jl

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ using Test
22

33
# DOCUMENTER_TEST_EXAMPLES can be used to control which builds are performed in
44
# make.jl, and we need to set it to the relevant LaTeX builds.
5-
ENV["DOCUMENTER_TEST_EXAMPLES"] =
6-
"latex latex_simple latex_cover_page latex_toc_style latex_simple_tectonic " *
7-
"latex_showcase"
8-
5+
if Sys.iswindows() && get(ENV, "GITHUB_ACTIONS", nothing) == "true"
6+
ENV["DOCUMENTER_TEST_EXAMPLES"] = "latex_simple_nondocker latex_simple_tectonic"
7+
else
8+
ENV["DOCUMENTER_TEST_EXAMPLES"] =
9+
"latex latex_simple latex_cover_page latex_toc_style latex_simple_nondocker latex_simple_tectonic " *
10+
"latex_showcase"
11+
end
912
# When the file is run separately we need to include make.jl which actually builds
1013
# the docs and defines a few modules that are referred to in the docs. The make.jl
1114
# has to be expected in the context of the Main module.
@@ -27,35 +30,45 @@ else
2730
end
2831

2932
@testset "Examples/LaTeX" begin
30-
@testset "PDF/LaTeX: simple" begin
31-
doc = Main.examples_latex_simple_doc
32-
@test isa(doc, Documenter.Documenter.Document)
33-
let build_dir = joinpath(examples_root, "builds", "latex_simple")
34-
@test joinpath(build_dir, "DocumenterLaTeXSimple-1.2.3.pdf") |> isfile
33+
if !(Sys.iswindows() && get(ENV, "GITHUB_ACTIONS", nothing) == "true")
34+
@testset "PDF/LaTeX: simple" begin
35+
doc = Main.examples_latex_simple_doc
36+
@test isa(doc, Documenter.Documenter.Document)
37+
let build_dir = joinpath(examples_root, "builds", "latex_simple")
38+
@test joinpath(build_dir, "DocumenterLaTeXSimple-1.2.3.pdf") |> isfile
39+
end
3540
end
36-
end
3741

38-
@testset "PDF/LaTeX" begin
39-
doc = Main.examples_latex_doc
40-
@test isa(doc, Documenter.Documenter.Document)
41-
let build_dir = joinpath(examples_root, "builds", "latex")
42-
@test joinpath(build_dir, "DocumenterLaTeX$(tagsuffix).pdf") |> isfile
42+
@testset "PDF/LaTeX" begin
43+
doc = Main.examples_latex_doc
44+
@test isa(doc, Documenter.Documenter.Document)
45+
let build_dir = joinpath(examples_root, "builds", "latex")
46+
@test joinpath(build_dir, "DocumenterLaTeX$(tagsuffix).pdf") |> isfile
47+
end
4348
end
44-
end
4549

46-
@testset "PDF/LaTeX: Custom Cover Page" begin
47-
doc = Main.examples_latex_cover_page
48-
@test isa(doc, Documenter.Documenter.Document)
49-
let build_dir = joinpath(examples_root, "builds", "latex_cover_page")
50-
@test joinpath(build_dir, "DocumenterLaTeX$(tagsuffix).pdf") |> isfile
50+
@testset "PDF/LaTeX: Custom Cover Page" begin
51+
doc = Main.examples_latex_cover_page
52+
@test isa(doc, Documenter.Documenter.Document)
53+
let build_dir = joinpath(examples_root, "builds", "latex_cover_page")
54+
@test joinpath(build_dir, "DocumenterLaTeX$(tagsuffix).pdf") |> isfile
55+
end
5156
end
52-
end
5357

54-
@testset "PDF/LaTeX: Custom TOC Style" begin
55-
doc = Main.examples_latex_toc_style
56-
@test isa(doc, Documenter.Documenter.Document)
57-
let build_dir = joinpath(examples_root, "builds", "latex_toc_style")
58-
@test joinpath(build_dir, "DocumenterLaTeX$(tagsuffix).pdf") |> isfile
58+
@testset "PDF/LaTeX: Custom TOC Style" begin
59+
doc = Main.examples_latex_toc_style
60+
@test isa(doc, Documenter.Documenter.Document)
61+
let build_dir = joinpath(examples_root, "builds", "latex_toc_style")
62+
@test joinpath(build_dir, "DocumenterLaTeX$(tagsuffix).pdf") |> isfile
63+
end
64+
end
65+
66+
@testset "PDF/LaTeX: showcase" begin
67+
doc = Main.examples_latex_showcase_doc
68+
@test isa(doc, Documenter.Documenter.Document)
69+
let build_dir = joinpath(examples_root, "builds", "latex_showcase")
70+
@test joinpath(build_dir, "DocumenterLaTeXShowcase-1.2.3.pdf") |> isfile
71+
end
5972
end
6073
end
6174

@@ -67,11 +80,11 @@ end
6780
end
6881
end
6982

70-
@testset "PDF/LaTeX: showcase" begin
71-
doc = Main.examples_latex_showcase_doc
83+
@testset "PDF/LaTeX: native" begin
84+
doc = Main.examples_latex_simple_nondocker_doc
7285
@test isa(doc, Documenter.Documenter.Document)
73-
let build_dir = joinpath(examples_root, "builds", "latex_showcase")
74-
@test joinpath(build_dir, "DocumenterLaTeXShowcase-1.2.3.pdf") |> isfile
86+
let build_dir = joinpath(examples_root, "builds", "latex_simple_nondocker")
87+
@test joinpath(build_dir, "DocumenterLaTeXSimpleNon-Docker-1.2.3.pdf") |> isfile
7588
end
7689
end
7790
end

0 commit comments

Comments
 (0)