diff --git a/whitepaper/PUBLISHER_CONTEXT.md b/whitepaper/PUBLISHER_CONTEXT.md index 0f201a83..3877ae6f 100644 --- a/whitepaper/PUBLISHER_CONTEXT.md +++ b/whitepaper/PUBLISHER_CONTEXT.md @@ -171,6 +171,7 @@ After any change: 2. Check for errors in output 3. Verify PDF generates correctly 4. Spot-check web navigation +5. Check PDF geometry, not only glyphs: `pdftotext -bbox` and count words whose xMax exceeds page width − 36 pt (baseline 1 since 2026-10-31, a plain-text table cell on page 6). Long inline code breaks via `pdf-breakable-code.lua`; a rise means a new unbreakable construct. **Never commit changes that break the build.** diff --git a/whitepaper/make-pdf.sh b/whitepaper/make-pdf.sh index 9449ada9..762c09f2 100755 --- a/whitepaper/make-pdf.sh +++ b/whitepaper/make-pdf.sh @@ -149,6 +149,7 @@ pandoc "$TEMP_MD" -o "$PDF_FILE" \ -V toccolor=black \ -V colorlinks=true \ -H pdf-glyphs.tex \ + --lua-filter=pdf-breakable-code.lua \ 2> "$PANDOC_LOG" PANDOC_RC=$? # xelatex drops glyphs its font lacks and only says so on stderr — surface them diff --git a/whitepaper/pdf-breakable-code.lua b/whitepaper/pdf-breakable-code.lua new file mode 100644 index 00000000..cc6dc24b --- /dev/null +++ b/whitepaper/pdf-breakable-code.lua @@ -0,0 +1,41 @@ +-- Long inline code in the PDF gets break points. +-- +-- pandoc sets inline code as \texttt{...}, which TeX never breaks: the mono +-- font has no hyphen character and a path has no spaces. The provenance this +-- paper cites inline (Research/proposals/.md, +-- synchronism-site/explorer/findings/, scripts) therefore ran +-- straight off the page. Measured 2026-10-31: 98 words on 55 of 293 pages +-- ended past the 1in margin, most of them clipped at the physical page edge, +-- so the reader could not see the end of the path. +-- +-- For inline code of MIN_LEN characters or more, this emits the \texttt +-- itself and puts \allowbreak after each / _ - . so a line can end there. Nothing +-- is inserted into the text, so the text layer is unchanged. Short code +-- (1/Ω_m, B_max) is left to pandoc, since a break there would split a symbol. +-- PDF only: make-pdf.sh passes this filter, and the HTML builds do not. + +local MIN_LEN = 20 + +local escapes = { + ['\\'] = '\\textbackslash{}', + ['{'] = '\\{', ['}'] = '\\}', + ['#'] = '\\#', ['$'] = '\\$', ['%'] = '\\%', ['&'] = '\\&', ['_'] = '\\_', + ['~'] = '\\textasciitilde{}', ['^'] = '\\^{}', + ['`'] = '\\textasciigrave{}', ["'"] = '\\textquotesingle{}', + [' '] = '\\ ', +} +local breakafter = { ['/'] = true, ['_'] = true, ['-'] = true, ['.'] = true } + +function Code(el) + if not FORMAT:match('latex') then return nil end + if utf8.len(el.text) == nil or utf8.len(el.text) < MIN_LEN then return nil end + local out = {} + for _, cp in utf8.codes(el.text) do + local ch = utf8.char(cp) + out[#out + 1] = escapes[ch] or ch + -- '-' gets '{}' first so a following '-' cannot form a ligature + if ch == '-' then out[#out + 1] = '{}' end + if breakafter[ch] then out[#out + 1] = '\\allowbreak{}' end + end + return pandoc.RawInline('latex', '\\texttt{' .. table.concat(out) .. '}') +end