Skip to content

fix whitespace edge cases in migrate - #228

Merged
vagenas merged 1 commit into
mainfrom
fix-migration-trailing-newline
Oct 30, 2026
Merged

vagenas merged 1 commit into
mainfrom
fix-migration-trailing-newline

Conversation

@vagenas

@vagenas vagenas commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Three places in doclang migrate (and version handling) used Python's notion of whitespace or of the end of a string, not XML's. The spec defines whitespace as space, tab, CR and LF only.

  • 0.8 to 0.9: a <content> ending in a line break was unwrapped, because ^…$ also matches before a trailing \n. The line break was lost:
    <text>one<content> two
    </content>three</text>
    migrated to <text>one two\nthree</text>, which 0.9 reads as one two three. It now keeps the <content>.
  • Down steps (0.9 to 0.8, 0.8 to 0.7): removing a dropped element used a bare .strip(), which also strips a non-breaking space. A &#160; between a dropped element and whitespace was lost. Only XML whitespace is stripped now.
  • Version and name checks (_schemas, _api, _plan, _archive) use fullmatch instead of ^…$. E.g. version="0.8&#10;" is now rejected as an invalid declared version, rather than failing later with a confusing "No schema for the document's version 0.8⏎".

Regression tests for each case; full test suite, ruff and mypy pass.

Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
@vagenas
vagenas requested a review from cau-git October 30, 2026 16:29
@vagenas
vagenas merged commit 6275e62 into main Oct 30, 2026
10 checks passed
@vagenas
vagenas deleted the fix-migration-trailing-newline branch October 30, 2026 16:36
@vagenas vagenas mentioned this pull request Oct 30, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants