commit 9d76b7468fb2d867cf3bf72d62447d7c39956512 parent 7e5f463f7bc1728812a4e62ac34ce51cbdc25d17 Author: Suzanne Soy <jsmaniac.github@suzanne.soy> Date: Wed, 28 Jul 2021 14:10:31 +0100 Fix the scribble links which point to the global remote documentation instead of the current page Diffstat:
| M | .github/workflows/ci.yml | | | 4 | +++- |
| A | fixlinks.sh | | | 28 | ++++++++++++++++++++++++++++ |
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml @@ -115,7 +115,9 @@ jobs: - name: (Re?)Build the Racket package run: raco setup --check-pkg-deps --no-zo --no-launcher --no-install --no-post-install --no-docs --pkgs "$(basename "$GITHUB_WORKSPACE")" - name: Generate docs - run: raco scribble ++main-xref-in --dest doc/phc-thesis --html --dest-name index --redirect-main https://docs.racket-lang.org/ --redirect https://docs.racket-lang.org/ scribblings/phc-thesis.scrbl > html.log 2>&1 || (cat html.log && exit 1) + run: | + raco scribble ++main-xref-in --dest doc/phc-thesis --html --dest-name index --redirect-main http://download.racket-lang.org/releases/7.3/doc/ --redirect https://docs.racket-lang.org/local-redirect/index.html scribblings/phc-thesis.scrbl > html.log 2>&1 || (cat html.log && exit 1) + ./fixlinks.sh - name: Generate PDF run: make - name: Patch docs diff --git a/fixlinks.sh b/fixlinks.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +set -euET -o pipefail + +# Scribble (in Racket 7.3 at least) incorrectly redirects some local links within the page to a remote server, this restores the links back to local. +# Replace "https://docs.racket-lang.org/local-redirect/index.html?doc=phc-thesis&rel=index.html%23…" +# with a single # +# and translate back the %25 escape sequences in the URL +# sed can't do a replacement within the matched pattern & and my perl is rusty… + +set -x +sed -i -e 's~X~XA~g' doc/phc-thesis/index.html +sed -i -e 's~Y~XB~g' doc/phc-thesis/index.html +tr \\n Y < doc/phc-thesis/index.html > doc/phc-thesis/index.html2 +mv doc/phc-thesis/index.html2 doc/phc-thesis/index.html +sed -i -e 's~"https://docs\.racket-lang\.org/local-redirect/index\.html[?]doc=phc-thesis&rel=index\.html%23\([^"]*"\)~"#\nXC\1\n"~g' doc/phc-thesis/index.html +sed -i -e '/^XC/s~%25~XD~g' doc/phc-thesis/index.html +if grep 'XC.*%' doc/phc-thesis/index.html; then + echo "Error: some urlencoded escape code was not properly filtered by fixlinks.sh" + exit 1 +fi +tr -d \\n < doc/phc-thesis/index.html > doc/phc-thesis/index.html2 +mv doc/phc-thesis/index.html2 doc/phc-thesis/index.html +sed -i -e 's~Y~\n~g' doc/phc-thesis/index.html +sed -i -e 's~XD~%~g' doc/phc-thesis/index.html +sed -i -e 's~XC~~g' doc/phc-thesis/index.html +sed -i -e 's~XB~Y~g' doc/phc-thesis/index.html +sed -i -e 's~XA~X~g' doc/phc-thesis/index.html