fix: preserve code indentation and literal text in HTML exports
AF
11h ago+61+61+01234567890123456789-1-1-0123456789
Summary
HTML export currently maps CodeSnippet to a generic div, so browsers collapse its newlines, tabs and indentation as ordinary text. This changes the presentation and meaning of code in exported documents.
Render snippets as pre containing code, preserving literal code text and its whitespace. A code child also retains leading newlines through the HTML sanitizer. Explicit text_as_html remains authoritative, and ordinary text keeps its paragraph representation.
This covers the HTML conversion path; #4766 addresses Markdown export.
Validation
- On original production code, this change's regressions produce 4 failures and 2 passing controls.
- A fork validation branch containing both independent fixes runs these regressions against the pinned original production files first: 11 fail and 4 controls pass. Restoring the final source, the new regressions and existing element, base chunking, chunk dispatch and HTML conversion suites report 549 passed, 1 skipped on Python 3.12.
- Ruff 0.17.5 check and format check pass with this repository's configuration. Source-integrity checks confirm the files are restored after baseline verification.
- Validation run and JUnit artifacts.
Checklist
- The PR title is a user-facing release-note entry with a conventional commit prefix.
- Maintainer: please apply the
bugcategory label.