DIT-13504: XLIFF source text is dropped when it carries an inline placeholder - #8
Merged
laurakoye merged 2 commits intoAug 19, 2026
Conversation
laurakoye
changed the base branch from
laura/dit-13480-capture-the-raw-literal-snapshot_text-in-resource-file
to
laura/dit-13503-candidate-ids-hash-the-line-number-instead-of-the-occurrence
August 18, 2026 21:39
laurakoye
changed the base branch from
laura/dit-13503-candidate-ids-hash-the-line-number-instead-of-the-occurrence
to
laura/dit-13480-capture-the-raw-literal-snapshot_text-in-resource-file
August 18, 2026 21:41
laurakoye
force-pushed
the
laura/dit-13504-xliff-source-text-is-dropped-when-it-carries-an-inline
branch
from
August 18, 2026 21:41
9c807f4 to
3a66a54
Compare
jholiga
approved these changes
Aug 19, 2026
laurakoye
merged commit Aug 19, 2026
3c1132d
into
laura/dit-13480-capture-the-raw-literal-snapshot_text-in-resource-file
3 checks passed
laurakoye
deleted the
laura/dit-13504-xliff-source-text-is-dropped-when-it-carries-an-inline
branch
August 19, 2026 15:37
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.
Closes DIT-13504.
An XLIFF
<source>holding an inline placeholder produced no candidate. The<target>beside it extracted fine, so a unit kept its translation and silently lost its original.Why: we parse with ast-grep's HTML grammar, where
<source>is a void element — it can't hold children. The grammar closes it at the placeholder and orphans</source>, soinnerTextfinds noend_tagand returnsnull.Fix: when an element has no
end_tag,innerTextfinds the closing tag in the raw source and takes the span from there.It lives in
xml.ts, notxliff.ts—innerTextis where every XML-family extractor bails, so one guard covers all callers.stringsdict.tscalls it without the source argument and is unaffected.emitTextHitalso now rejects a span containing<![CDATA[. The old CDATA guard reads the element's range, which the broken parse cuts short — without it, a CDATA<source>would fire on both the AST path and the CDATA sweep.Tests
New
xliff.test.ts:<g>/<ph>/<x/>/<xliff:g>in 1.2 and<g>in 2.0, plus the cases that shouldn't move — CDATA stays a single hit, plain<source>unchanged, a genuinely unclosed<source>still dropped.In
snapshot-text.test.ts, the pinned "yields no hit at all" test inverts, and the XLIFF fixture gains a placeholder unit so theXML_FAMILYboundary sweep covers a recovered span.Note
A self-closing placeholder leaves a double space in the value (
Hello <x/> there→"Hello there"). Existing behaviour for stripped markup, unchanged here.Verify locally
From the repo root on this branch:
The script has to sit in the repo root — the relative import resolves from there.
Expected — 7 candidates:
MISSINGin the first column is the acceptance criterion — every span must be findable verbatim in the file. The CDATA unit is the one to watch for double-emission: it appears once, not twice.Before the fix — 4 candidates. Swap in the base version of the one file and rerun:
Every
<source>carrying a placeholder disappears —named,androidandvoid— while their<target>siblings come through fine. That's the silent partial failure this fixes.Cleanup:
rm xliff-check.ts && rm -rf /tmp/xliffdemo