Skip to content

Commit d949a2b

Browse files
domenicsideshowbarker
authored andcommitted
Fix relative links in the PDF version
Closes whatwg/html#9097. Also contains a drive-by fix to remove the step which pulls down pdfsizeopt, which we no longer use after 18b6e24.
1 parent 0ba7ee1 commit d949a2b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

ci-build/docker-build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ function main {
2727
# Build the Docker image, using Docker Hub as a cache. (This will be fast if nothing has changed
2828
# in html-build or its dependencies).
2929
docker pull whatwg/wattsi
30-
docker pull ptspts/pdfsizeopt
3130
docker pull "$docker_hub_repo" || true
3231
docker build --cache-from "$docker_hub_repo" --tag "$docker_hub_repo" .
3332
}

ci-build/inside-container.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ echo "Running conformance checker..."
1414
java -Xmx1g -jar ./vnu.jar --skip-non-html "$HTML_OUTPUT"
1515
echo ""
1616

17+
# The build output contains some relative links, which will end up pointing to
18+
# "https://0.0.0.0:$PDF_SERVE_PORT/" in the built PDF. That's undesirable; see
19+
# https://github.com/whatwg/html/issues/9097. Our hack is to replace such
20+
# relative links like so. Note: we can't just insert a <base> or use Prince's
21+
# --baseurl option, because that would cause Prince to crawl the actual live
22+
# files for subresources, missing any updates to them we made as part of this
23+
# change.
24+
sed 's| href=/| href=https://html.spec.whatwg.org/|g' "$HTML_OUTPUT/index.html" > "$HTML_OUTPUT/print.html"
25+
1726
# Serve the built output so that Prince can snapshot it
1827
# The nohup/sleep incantations are necessary because normal & does not work inside Docker:
1928
# https://stackoverflow.com/q/50211207/3191
@@ -24,4 +33,6 @@ echo ""
2433

2534
echo ""
2635
echo "Building PDF..."
27-
PATH=/whatwg/prince/bin:$PATH prince --verbose --output "$HTML_OUTPUT/print.pdf" "http://0.0.0.0:$PDF_SERVE_PORT/"
36+
PATH=/whatwg/prince/bin:$PATH prince --verbose --output "$HTML_OUTPUT/print.pdf" "http://0.0.0.0:$PDF_SERVE_PORT/print.html"
37+
38+
rm "$HTML_OUTPUT/print.html"

0 commit comments

Comments
 (0)