Skip to content

Commit

Permalink
clean up diff output for this change
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisfenner committed Sep 9, 2024
1 parent 4cb2aad commit 661c04c
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ ENV PATH="/usr/local/texlive/bin/aarch64-linux:/usr/local/texlive/bin/x86_64-lin
# Packages that are needed despite not being used explicitly by the template:
# bigfoot, catchfile, fancyvrb, footmisc, hardwrap, lineno, ltablex, latexmk, needspace, pgf, zref
# Package dependencies introduced by latexdiff:
# changebar, datetime2, latexdiff, listings, marginnote, pdfcomment, soulpos, ulem
# changebar, datetime2, latexdiff, listings, marginnote, pdfcomment, soulpos
RUN tlmgr update --self && tlmgr install \
accsupp \
adjustbox \
Expand Down
24 changes: 15 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,14 @@ do_md_fixups() {
}
do_tex_fixups() {
local input=$1
# We have a "code" enviroment that displays everything, including comments.
# Sometimes latexdiff injects comments that it thinks won't be displayed.
# Delete those latexdiff comments.
sed -i.bak 's/%DIFDELCMD.*//g' "${input}"
# latexdiff is appending its own generated preamble to our custom one
# (in apparent contradiction of the documentation). Strip it out.
sed -i.bak '/^% End Custom TCG/,/^%DIF END PREAMBLE EXTENSION/d' "${input}"

# latexdiff uses %DIF < and %DIF > to prefix changed lines in code environments
# prefix these lines with + and -
sed -i.bak 's/^%DIF < /%DIF <- /g' "${input}"
sed -i.bak 's/^%DIF > /%DIF >+ /g' "${input}"
}

if test "${DO_GITVERSION}" == "yes"; then
Expand Down Expand Up @@ -567,6 +571,7 @@ analyze_latex_logs() {
do_latex() {
local input=$1
local output=$2
local extra_pandoc_options=$3
mkdir -p "$(dirname ${output})"

# TODO: https://github.com/TrustedComputingGroup/pandoc/issues/164
Expand Down Expand Up @@ -605,7 +610,7 @@ do_latex() {
--metadata=colorlinks:true
--metadata=contact:[email protected]
--from=${FROM}
${EXTRA_PANDOC_OPTIONS}
${extra_pandoc_options}
--to=latex
--output="'${output}'"
"'${input}'")
Expand Down Expand Up @@ -762,7 +767,7 @@ do_html() {
readonly TEMP_TEX_FILE="${BUILD_DIR}/${INPUT_FILE}.tex"
if [ -n "${PDF_OUTPUT}" -o -n "${LATEX_OUTPUT}" -o -n "${DIFFPDF_OUTPUT}" -o -n "${DIFFTEX_OUTPUT}" ]; then
do_md_fixups "${BUILD_DIR}/${INPUT_FILE}"
do_latex "${BUILD_DIR}/${INPUT_FILE}" "${TEMP_TEX_FILE}"
do_latex "${BUILD_DIR}/${INPUT_FILE}" "${TEMP_TEX_FILE}" "${EXTRA_PANDOC_OPTIONS}"
fi
if [ -n "${LATEX_OUTPUT}" ]; then
cp "${TEMP_TEX_FILE}" "${SOURCE_DIR}/${LATEX_OUTPUT}"
Expand Down Expand Up @@ -798,14 +803,15 @@ readonly TEMP_DIFF_TEX_FILE="${BUILD_DIR}/${INPUT_FILE}.diff.tex"
readonly TEMP_LATEXDIFF_LOG="${BUILD_DIR}/latexdiff.log"
export MERMAID_FILTER_FORMAT="pdf"
if [ -n "${DIFFPDF_OUTPUT}" -o -n "${DIFFTEX_OUTPUT}" ]; then
git fetch --unshallow --quiet && git reset --hard ${DIFFBASE}
git fetch --unshallow --quiet 2>/dev/null
git reset --hard ${DIFFBASE}
if [ $? -ne 0 ]; then
FAILED=true
echo "diff output failed"
else
do_md_fixups "${BUILD_DIR}/${INPUT_FILE}"
do_latex "${BUILD_DIR}/${INPUT_FILE}" "${TEMP_DIFFBASE_TEX_FILE}"
latexdiff --type PDFCOMMENT --driver "${PDF_ENGINE}" "${TEMP_DIFFBASE_TEX_FILE}" "${TEMP_TEX_FILE}" > "${TEMP_DIFF_TEX_FILE}" 2>"${TEMP_LATEXDIFF_LOG}"
do_latex "${BUILD_DIR}/${INPUT_FILE}" "${TEMP_DIFFBASE_TEX_FILE}" "${EXTRA_PANDOC_OPTIONS} -V keepstaleimages=true"
latexdiff --preamble /resources/templates/latexdiff.tex --config /resources/templates/latexdiff.cfg --append-safecmd /resources/templates/latexdiff.safe "${TEMP_DIFFBASE_TEX_FILE}" "${TEMP_TEX_FILE}" > "${TEMP_DIFF_TEX_FILE}" 2>"${TEMP_LATEXDIFF_LOG}"
do_tex_fixups "${TEMP_DIFF_TEX_FILE}"
if [ -n "${DIFFTEX_OUTPUT}" ]; then
mkdir -p "$(dirname ${SOURCE_DIR}/${DIFFTEX_OUTPUT})"
Expand Down
5 changes: 4 additions & 1 deletion filter/convert-images.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ function Image (img)
elseif converter(img.src, new_filename) then
print(string.format(" converted %s to %s", img.src, new_filename))
-- Delete stale copies of this file. This makes it easier to cache only the latest converted pdfs
deleteFilesExcept(img.src .. ".*.convert.pdf", new_filename)
-- Don't do this if the "keepstaleimages" variable is set.
if not PANDOC_WRITER_OPTIONS.variables["keepstaleimages"] then
deleteFilesExcept(img.src .. ".*.convert.pdf", new_filename)
end
img.src = new_filename
end
else
Expand Down
22 changes: 11 additions & 11 deletions guide.tcg
Original file line number Diff line number Diff line change
Expand Up @@ -673,18 +673,20 @@ Table: Shapes {#tbl:shapes}

| Shape | Number of sides |
| ------------ | --------------- |
| Pentagon | 5 |
| Square | 4 |
| Triangle | 3 |
| Möbius strip | 1 |
| Mobius strip | 1 |
```

Table: Shapes {#tbl:shapes}

| Shape | Number of sides |
| ------------ | --------------- |
| Pentagon | 5 |
| Square | 4 |
| Triangle | 3 |
| Möbius strip | 1 |
| Mobius strip | 1 |

Note the table caption and cross-reference in curly braces above the table.

Expand All @@ -698,18 +700,16 @@ Table: Shapes {#tbl:simple-shapes}

Shape Number of sides
------------ ---------------
Square 4
Triangle 3
Möbius strip 1
Mobius strip 1
```

Table: Shapes {#tbl:simple-shapes}

Shape Number of sides
------------ ---------------
Square 4
Triangle 3
Möbius strip 1
Mobius strip 1

### Multiline Markdown Tables {#sec:multiline-markdown-tables}

Expand Down Expand Up @@ -1014,14 +1014,14 @@ Sometimes, you just need a little inline math in the middle of a sentence, like
## Words in equations

To typeset complex equations with multi-character identifiers (such as the function "HMAC" or the word "OPAD") in @eq:hmac-iso,
we recommend using the functions `\mathbf` (for functions) and `\mathit` (for identifiers).
we recommend using the functions `\mathbf` (for functions) and `\mathit` (for variables). For constants, we recommend `\mathrm`.
This avoids strange kerning issues where a string is treated as a product of single-character symbols, like in @eq:hmac-iso-bad-kerning:

```md
$$ \mathbf{HMAC}(K, \mathit{someTEXT}) \coloneq H((\bar{K} \oplus \mathit{OPAD}) \parallel H((\bar{K} \oplus \mathit{IPAD}) \parallel \mathit{someTEXT})) $$ {#eq:hmac-iso}
$$ \mathbf{HMAC}(K, \mathit{someTEXT}) \coloneq \mathbf{H}((\bar{K} \oplus \mathrm{OPAD}) \parallel \mathbf{H}((\bar{K} \oplus \mathrm{IPAD}) \parallel \mathit{someTEXT})) $$ {#eq:hmac-iso}
```

$$ \mathbf{HMAC}(K, \mathit{someTEXT}) \coloneq H((\bar{K} \oplus \mathit{OPAD}) \parallel H((\bar{K} \oplus \mathit{IPAD}) \parallel \mathit{someTEXT})) $$ {#eq:hmac-iso}
$$ \mathbf{HMAC}(K, \mathit{someTEXT}) \coloneq \mathbf{H}((\bar{K} \oplus \mathrm{OPAD}) \parallel \mathbf{H}((\bar{K} \oplus \mathrm{IPAD}) \parallel \mathit{someTEXT})) $$ {#eq:hmac-iso}

```md
$$ HMAC(K, someTEXT) \coloneq H((\bar{K} \oplus OPAD) \parallel H((\bar{K} \oplus IPAD) \parallel someTEXT)) $$ {#eq:hmac-iso-bad-kerning}
Expand All @@ -1032,10 +1032,10 @@ $$ HMAC(K, someTEXT) \coloneq H((\bar{K} \oplus OPAD) \parallel H((\bar{K} \oplu
You can use Unicode characters to make equations a little more readable in plain-text:

```md
$$ \mathbf{HMAC}(K, \mathit{someTEXT}) := H((\bar{K} ⊕ \mathit{OPAD}) \parallel H((\bar{K} ⊕ \mathit{IPAD}) \parallel \mathit{someTEXT})) $$ {#eq:hmac-unicode}
$$ \mathbf{HMAC}(K, \mathit{someTEXT}) := H((\bar{K} ⊕ \mathrm{OPAD}) \parallel H((\bar{K} ⊕ \mathrm{IPAD}) \parallel \mathit{someTEXT})) $$ {#eq:hmac-unicode}
```

$$ \mathbf{HMAC}(K, \mathit{someTEXT}) := H((\bar{K} ⊕ \mathit{OPAD}) \parallel H((\bar{K} ⊕ \mathit{IPAD}) \parallel \mathit{someTEXT})) $$ {#eq:hmac-unicode}
$$ \mathbf{HMAC}(K, \mathit{someTEXT}) := \mathbf{H}((\bar{K} ⊕ \mathrm{OPAD}) \parallel \mathbf{H}((\bar{K} ⊕ \mathrm{IPAD}) \parallel \mathit{someTEXT})) $$ {#eq:hmac-unicode}

# Advanced Features

Expand Down
Loading

0 comments on commit 661c04c

Please sign in to comment.