Skip to content

Fix Typst label handling in diff output#8

Open
kjgoodrick wants to merge 1 commit into
sou1118:mainfrom
kjgoodrick:main
Open

Fix Typst label handling in diff output#8
kjgoodrick wants to merge 1 commit into
sou1118:mainfrom
kjgoodrick:main

Conversation

@kjgoodrick
Copy link
Copy Markdown

Summary

Fix Typst label handling in generated diff output.

This change treats Typst labels like <sample-anchor> as atomic syntax during
inline diffing. It prevents diff markup from being inserted inside label syntax,
and keeps unchanged labels outside added/deleted wrappers so references can
continue to resolve.

Closes #7.

Changes

  • Parse labels at the start of a paragraph as their own block.
  • Treat label-only blocks as atomic so they are not word-diffed internally.
  • Tokenize <label> syntax as a single token during mixed-granularity diffing.
  • Render inserted labels bare, and suppress deleted label spans to avoid invalid
    or duplicate labels.
  • Add regression tests for renamed labels and unchanged labels near inserted
    content.

Treat Typst labels as atomic syntax during tokenization and avoid word-level diffing label-only blocks. Keep labels at paragraph starts as separate blocks so unchanged labels remain attached to nearby content, and render inserted labels bare while suppressing deleted label spans.

Add regressions for renamed labels and unchanged labels near inserted text.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

typdiff can generate invalid Typst when diffing labels and cross-references

1 participant