# Ignoring document portion during parsing

**URL:** <https://discuss.codemirror.net/t/ignoring-document-portion-during-parsing/9864>\
**Category:** Lezer\
**Created:** [August 14, 2026, 10:35am UTC](https://discuss.codemirror.net/t/ignoring-document-portion-during-parsing/9864 "2026-08-14T10:35:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hrjakobsen](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/h/a587f6/32.png) [@hrjakobsen](https://discuss.codemirror.net/u/hrjakobsen)\
**Post date:** [August 14, 2026, 10:35am UTC](https://discuss.codemirror.net/t/ignoring-document-portion-during-parsing/9864/1 "2026-08-14T10:35:51Z")

</div>

Hi!

We have a document that contains inline suggested-deletions. Something like “foo̶b̶a̶r̶baz”. In our editor we hide the deleted range completely, so it just looks like “foobaz”. This avoids awkward position mapping for all edits where you’d otherwise have to map changes late in the document past all previous “deleted” ranges.

Hiding the ranges via decorations generally works well, but one of the things that fall over is syntax highlighting as that works on the underlying text rather than the visible text. Here’s an example that hides some ranges via atomic decorations: [Try CodeMirror](https://codemirror.net/try/#c=aW1wb3J0IHtEZWNvcmF0aW9uLCBFZGl0b3JWaWV3LGxpbmVOdW1iZXJzfSBmcm9tICJAY29kZW1pcnJvci92aWV3IgppbXBvcnQge21pbmltYWxTZXR1cH0gZnJvbSAiY29kZW1pcnJvciIKaW1wb3J0IHtqYXZhc2NyaXB0fSBmcm9tICJAY29kZW1pcnJvci9sYW5nLWphdmFzY3JpcHQiCmltcG9ydCB7RWRpdG9yU3RhdGUsIFN0YXRlRmllbGR9IGZyb20gJ0Bjb2RlbWlycm9yL3N0YXRlJwoKY29uc3QgUkFOR0VTID0gW1syLCA5XSwgWzQ3LCA1NF1dCgpjb25zdCBoaWRlID0gRGVjb3JhdGlvbi5yZXBsYWNlKHt9KQpjb25zdCBidWlsZERlY29yYXRpb25zID0gKHN0YXRlKSA9PiB7CiAgY29uc3QgZGVjb3JhdGlvbnMgPSBSQU5HRVMubWFwKChbZnJvbSwgdG9dKSA9PiB7CiAgICBjb25zdCB0b0NsYW1wZWQgPSBNYXRoLm1pbih0bywgc3RhdGUuZG9jLmxlbmd0aCkKICAgIGlmICh0b0NsYW1wZWQgPD0gZnJvbSkgewogICAgICByZXR1cm4gRGVjb3JhdGlvbi5ub25lCiAgICB9CiAgICByZXR1cm4gaGlkZS5yYW5nZShmcm9tLCB0bykKICB9KQogIHJldHVybiBEZWNvcmF0aW9uLnNldChkZWNvcmF0aW9ucykKfQoKZXhwb3J0IGNvbnN0IGhpZGRlblJhbmdlcyA9ICgpID0+IFN0YXRlRmllbGQuZGVmaW5lKHsKICBjcmVhdGU6IGJ1aWxkRGVjb3JhdGlvbnMsCiAgdXBkYXRlOiAoZGVjb3JhdGlvbnMsIHRyYW5zYWN0aW9uKSA9PiAKICAgIGJ1aWxkRGVjb3JhdGlvbnModHJhbnNhY3Rpb24uc3RhdGUpLAogIHByb3ZpZGU6IGZpZWxkID0+IFsKICAgIEVkaXRvclZpZXcuZGVjb3JhdGlvbnMuZnJvbShmaWVsZCksIAogICAgRWRpdG9yVmlldy5hdG9taWNSYW5nZXMuZnJvbShmaWVsZCkKICBdLAp9KQoKY29uc3QgZG9jID0gCmBmb2lnbm9yZWRyIChjb25zdCB4IG9mIFsxLCAyLCAzXSkgewogIGNvbnNvbGUubGlnbm9yZWRvZyh4KQp9CmAKCm5ldyBFZGl0b3JWaWV3KHsKICBkb2MsCiAgZXh0ZW5zaW9uczogW2hpZGRlblJhbmdlcygpLCBtaW5pbWFsU2V0dXAsIGphdmFzY3JpcHQoKSwgbGluZU51bWJlcnMoKV0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5Cn0pCg==) . Here `for` is incorrectly highlighted due to the underlying text being `foignoredr`.

Is there a way to affect how the text is passed to the Lezer system, or would it be better keeping the ranges external, and do the position mapping manually as required?

All the best, Mathias

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [August 14, 2026, 11:06am UTC](https://discuss.codemirror.net/t/ignoring-document-portion-during-parsing/9864/2 "2026-08-14T11:06:46Z")

</div>

There’s no support CodeMirror library for controlling what gets parsed. If these aren’t visible in the editor at all, it might be a good idea to, as you say, strip them out before putting them in the editor, and track their position externally.
