Repository navigation
Preserve XML and HTML text between elements - #205
Open
Shaisolaris wants to merge 1 commit into
Open
Shaisolaris wants to merge 1 commit into
Shaisolaris wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #80.
XML and HTML diffs drop text between tags because the model ignores
ElementTree.tail. AddingTAIL_ONLY_NEWin<r><a>x</a>TAIL_ONLY_NEW<b>y</b></r>produces a zero-cost match with that text missing from the diff.Adds tails to
XMLElementandXMLElementObj, including traversal, equality, size, copying and compound edits. XML prints tails after the closing tag and preserves whitespace, including trailing newlines. JSON adds atailfield and shows insertions, removals and changes. Its view copies nodes without changing their parents and keeps the edits visible.The ElementTree parser stays unchanged; #106's HTML parser work is separate. This branch starts from current
master, independently of #189 and #190. The JSON node-copying fix overlaps #190, with edit state retained here. The broader format support in #190 and inserted attribute/child fixes in #189 are outside this change.Tests cover tail-only changes; inserted, removed, changed and unchanged tails in XML and JSON; mixed-content round-trips; whitespace-only tails; escaping and Unicode; nested and root tails; traversal, size and deep copies; edit costs and completion; repeated JSON rendering without changing parents; and inserted/removed children with tails. The issue's example is tested as both XML and HTML. The new regressions fail against unmodified upstream.
Validation:
GRAPHTAGE_TEST_SEED=80 pytest -q: 283 passed, 1,796 subtests passed.uv sync --frozen --extra dev: same 283 tests and 1,796 subtests passed.ruff check graphtage test docs bindist: clean, including CI's locked Ruff version.make -C docs html SPHINXOPTS="-W --keep-going": passed with both development and locked Sphinx versions.python -m build --no-isolation: sdist and wheel built.uv lock --check --offlineandgit diff --check: passed.TAIL_ONLY_NEWwith insertion markers and return the expected diff exit status.