Skip to content

Conversation

@ericclemmons
Copy link

@ericclemmons ericclemmons commented Jan 30, 2026

Summary

This PR adds missing markdown stripping patterns for width calculations in concealment mode:

  • _italic_ and __bold__ (underscore variants)
  • ___bold+italic___ (underscore variant)
  • ~subscript~ (single tilde)
  • ^superscript^ (caret)

Problem

When using markdown like **_Bold Italic_** or Sub~script~, the underscore and single-tilde patterns were not being stripped during width calculation. This caused misaligned table columns because the concealed characters were still being counted toward the display width.

Screenshot 2026-01-29 at 7 33 49 PM

Example

Before this fix, a table with these cells would be misaligned:

| Style | Example |
|-------|---------|
| **_Bold Italic_** | combined |
| Sub~script~ | H~2~O |

Changes

Added 5 new regex patterns to getStringWidth() in the markdown stripping loop:

.replace(/___(.+?)___/g, "$1") // ___bold+italic___ -> text
.replace(/__(.+?)__/g, "$1")   // __bold__ -> bold
.replace(/_(.+?)_/g, "$1")     // _italic_ -> italic
.replace(/~(.+?)~/g, "$1")     // ~subscript~ -> subscript
.replace(/\^(.+?)\^/g, "$1")   // ^superscript^ -> superscript

@ericclemmons ericclemmons force-pushed the fix/underscore-and-subscript-markdown branch 3 times, most recently from 963e75f to 3078e0b Compare January 30, 2026 01:52
Add missing markdown stripping patterns for width calculation:
- _italic_ and __bold__ (underscore variants)
- ___bold+italic___ (underscore variant)
- ~subscript~ (single tilde)
- ^superscript^ (caret)

Also adds bun tests for the new patterns.
@ericclemmons ericclemmons force-pushed the fix/underscore-and-subscript-markdown branch from 3078e0b to bb8dbd6 Compare January 30, 2026 01:57
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.

1 participant