docs(formal): make doxygen builds -- the Unicode fix-up keeps newunicodechar's characters

fix-doxygen-unicode.py protected the first argument of each
\doxynewunicodechar{...} from its replacements, then turned every
non-ASCII character left in the file -- the protected ones too -- into
"?" and wrote the file as ASCII. refman.tex's \doxynewunicodechar{⁻},
{²} and {³} became \doxynewunicodechar{?}, and newunicodechar stopped
the build: "ASCII character requested".

The "?" fallback now applies to the unprotected parts of each line
only, and the file is written as UTF-8.

make -C docs/formal doxygen, from clean, with doxygen 1.9.8: exit 0,
build/doxygen/StarForth-API-Reference.pdf, 3561 pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
This commit is contained in:
rajames
2026-11-06 02:21:21 +00:00
co-authored by Claude Opus 5.5
parent 2a8ad9f439
commit 5b58b0b16e
+6 -3
View File
@@ -115,6 +115,11 @@ def fix_line(line):
else:
for char, replacement in REPLACEMENTS:
part = part.replace(char, replacement)
# Replace any remaining non-ASCII with ? placeholder -- here, and
# not over the whole file, so that the protected tokens keep their
# Unicode: a \doxynewunicodechar{?} is an ASCII character, which
# newunicodechar refuses ("ASCII character requested").
part = part.encode('ascii', errors='replace').decode('ascii')
result.append(part)
return ''.join(result)
@@ -124,10 +129,8 @@ def fix_file(path):
original = ''.join(lines)
fixed_lines = [fix_line(l) for l in lines]
content = ''.join(fixed_lines)
# Replace any remaining non-ASCII with ? placeholder
content = content.encode('ascii', errors='replace').decode('ascii')
if content != original:
with open(path, 'w', encoding='ascii') as f:
with open(path, 'w', encoding='utf-8') as f:
f.write(content)
return True
return False