Conversation
Contributor
|
✅ DCO Check Passed Thanks @eren-YU, all your commits are properly signed off. 🎉 |
… runs Signed-off-by: alan <erenyu@163.com>
eren-YU
force-pushed
the
fix/doclang-778-duplicate-layer-token
branch
from
September 16, 2026 08:53
c965282 to
6f52381
Compare
Contributor
Merge Protections🔴 1 of 2 protections blocking · waiting on 👀 reviews
🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
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 #778.
What changed
DocLangInlineSerializermerges an inline group's children and then wraps the merged text in a single<text>element. Each child is serialized independently beforehand, and every child whosecontent_layeris notBODYemits its own<layer/>element-head token. The merged wrapper therefore carried one<layer/>per child, while the DocLangelement_headsequence permits exactly one — so the exported document failed XSD validation:The merged text now keeps the first leading
<layer/>and drops the rest.This is the shape produced by a Word page footer, where a group of adjacent runs is classified as
furniture.Why not the other approach
The issue lists a second option — compute one
<layer/>for the group and tell children not to emit their own. That changes the child serializers' contract and touches more code. Dropping the duplicates at the merge point is the smaller change and keeps each child's output intact.Only leading tokens are touched, so a text run that happens to contain a literal
<layer value="..."/>string is left alone.How I checked
doclang 0.7.3's bundleddoclang.xsd, validating the serializer output directly:furnitureruns<layer/>, invalid<layer/>, validfurniture+BODY+furniture<layer/>, invalid<layer/>, validBODY<layer/><layer/>, unchangedThree tests added to
tests/test_serialization_doclang.py; two of them fail without the fix and all three pass with it. The third is a guard against over-correcting the all-BODYcase.ruff checkandruff format --checkare clean.Scope note
DocLangInlineSerializeralso produces invalid output when the parentTextItemcarries text of its own andshould_wrapisFalse— the runs then land outside any wrapper. That is a separate defect with its own report and is deliberately not touched here.