F
Member
【Editorial Discussion】
An extractor can return the right substring and still supply start and end indexes that a viewer cannot use. One component may count Unicode code points, another UTF-8 bytes, another UTF-16 code units, and another tokens. The document’s layout need not have been rotated, cropped, or rescaled. The geometry can be an identity mapping, and the highlight will still slice the wrong characters because the index units disagree.
This is distinct from a PDF or image coordinate transform that places a correct box in the wrong page frame. Here the source is typically a text buffer. Testing only exact string equality of the extracted quote will miss the broken offset. It is also not a table-header reconstruction problem: the quoted sentence can be correct while its indexes are expressed in the wrong unit.
**Build a buffer whose units disagree**
Create a short synthetic document that contains at least one combining mark, one multi-byte character, and one character that is not a single UTF-16 code unit, such as a supplementary-plane symbol, together with a unique ASCII target sentence. Record the correct slice of the target in each unit: code points, UTF-8 bytes, UTF-16 code units, and, if the extractor uses it, tokens after the actual tokenizer.
Ask the extractor for the quote and its offsets, then apply those offsets as if they were each of the units above. Only one interpretation should recover the quote and nothing else. If the returned string is correct but the offsets reconstruct a different span, the contract is already broken, regardless of downstream rendering.
**Keep the unit attached to the offset**
1) Require the extractor to name the unit and the base (the full document, a page string, or a chunk). A pair of integers is not self-describing. Reject offsets that cannot be interpreted without guessing.
2) Round-trip the span: from offsets back to text, and from the returned quote back to offsets under the declared unit. Both directions should agree. Include a case in which the same visual character can be represented in more than one Unicode form, so that normalization is an explicit choice rather than a silent shift of later indexes.
3) If a tokenizer is in the path, do not assume that token boundaries coincide with user-perceived characters. A highlight that snaps to token edges can include neighboring words even when the unit is otherwise consistent. Test that case separately from a pure unit mismatch.
A typographic renderer may still fail after the offsets are correct, for reasons already discussed in coordinate-frame tests. The fixtures here do not replace those tests. They also do not determine how a mixed HTML document should count markup versus visible text; that needs its own stated rule.
What offset unit do you require extractors to declare? Which synthetic character sequence has caught a correct quote paired with an index that only made sense in a different unit?
An extractor can return the right substring and still supply start and end indexes that a viewer cannot use. One component may count Unicode code points, another UTF-8 bytes, another UTF-16 code units, and another tokens. The document’s layout need not have been rotated, cropped, or rescaled. The geometry can be an identity mapping, and the highlight will still slice the wrong characters because the index units disagree.
This is distinct from a PDF or image coordinate transform that places a correct box in the wrong page frame. Here the source is typically a text buffer. Testing only exact string equality of the extracted quote will miss the broken offset. It is also not a table-header reconstruction problem: the quoted sentence can be correct while its indexes are expressed in the wrong unit.
**Build a buffer whose units disagree**
Create a short synthetic document that contains at least one combining mark, one multi-byte character, and one character that is not a single UTF-16 code unit, such as a supplementary-plane symbol, together with a unique ASCII target sentence. Record the correct slice of the target in each unit: code points, UTF-8 bytes, UTF-16 code units, and, if the extractor uses it, tokens after the actual tokenizer.
Ask the extractor for the quote and its offsets, then apply those offsets as if they were each of the units above. Only one interpretation should recover the quote and nothing else. If the returned string is correct but the offsets reconstruct a different span, the contract is already broken, regardless of downstream rendering.
**Keep the unit attached to the offset**
1) Require the extractor to name the unit and the base (the full document, a page string, or a chunk). A pair of integers is not self-describing. Reject offsets that cannot be interpreted without guessing.
2) Round-trip the span: from offsets back to text, and from the returned quote back to offsets under the declared unit. Both directions should agree. Include a case in which the same visual character can be represented in more than one Unicode form, so that normalization is an explicit choice rather than a silent shift of later indexes.
3) If a tokenizer is in the path, do not assume that token boundaries coincide with user-perceived characters. A highlight that snaps to token edges can include neighboring words even when the unit is otherwise consistent. Test that case separately from a pure unit mismatch.
A typographic renderer may still fail after the offsets are correct, for reasons already discussed in coordinate-frame tests. The fixtures here do not replace those tests. They also do not determine how a mixed HTML document should count markup versus visible text; that needs its own stated rule.
What offset unit do you require extractors to declare? Which synthetic character sequence has caught a correct quote paired with an index that only made sense in a different unit?

