Skip to content

fix: normalize tag names to lowercase for case-insensitive matching#371

Merged
BugenZhao merged 1 commit intomainfrom
bz/fix-uppercase-tags
Mar 14, 2026
Merged

fix: normalize tag names to lowercase for case-insensitive matching#371
BugenZhao merged 1 commit intomainfrom
bz/fix-uppercase-tags

Conversation

@BugenZhao
Copy link
Owner

Summary

  • Uppercase BBCode tags like [DEL][/DEL] or mixed-case [DEL][/del] were not rendered correctly — they fell through to the default branch and displayed as plain text.
  • Root cause: the Rust parser preserved original tag case, while the Swift renderer (ContentCombiner.swift) only matched lowercase names in its switch statement.
  • Fix: normalize tag names to lowercase at parse time with to_ascii_lowercase() in content.rs.

Test plan

  • Added test_uppercase_tags_normalized covering all-uppercase, mixed-case, and mismatched open/close tag cases
  • All 21 existing text crate tests pass with no regressions

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 14, 2026 14:18
@BugenZhao BugenZhao enabled auto-merge (squash) March 14, 2026 14:19
Uppercase BBCode tags like [DEL][/DEL] were not rendered correctly because
the parser preserved the original case while the Swift renderer only
matched lowercase tag names. Normalize tag names to lowercase at parse
time with `to_ascii_lowercase()`.
@BugenZhao BugenZhao force-pushed the bz/fix-uppercase-tags branch from 4215ee3 to 62522da Compare March 14, 2026 14:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes case-insensitive BBCode tag handling by normalizing parsed tag names to lowercase so downstream renderers (notably the Swift ContentCombiner switch on lowercase tags) match tags consistently.

Changes:

  • Normalize parsed BBCode tag names to lowercase (to_ascii_lowercase()) when building Span_Tagged.
  • Add a unit test covering uppercase, mixed-case, and open/close case-mismatch tags to ensure normalization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@BugenZhao BugenZhao merged commit 32252ee into main Mar 14, 2026
2 checks passed
@BugenZhao BugenZhao deleted the bz/fix-uppercase-tags branch March 14, 2026 14:26
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.

2 participants