Skip to content

Conversation

@joshdoman
Copy link
Contributor

@joshdoman joshdoman commented Aug 17, 2025

This fixes issue #2. Previously, links, bold, and italic HTML was sometimes incorrectly applied to inline code containing a special character. For example, __init__ should not be bolded, but it currently is.

At the same time, formatting that spans across inline code should still be applied. The fix is to replace code blocks with a unique placeholder that is unlikely to appear in the text.

This PR replaces each code block with indexed private use area unicode (\uE000{index}\uE001) and then applies link, bold, and italic formatting. When finished, the placeholder is replaced with the corresponding code block.

(The PR includes comprehensive test coverage for edge cases including nested formatting, multiple code blocks, and complex spanning scenarios)

Before:

Screenshot 2025-08-17 at 6 51 14 PM Screenshot 2025-08-17 at 6 52 46 PM Screenshot 2025-08-17 at 6 54 37 PM

After:

Screenshot 2025-08-17 at 6 51 34 PM Screenshot 2025-08-17 at 6 52 26 PM Screenshot 2025-08-17 at 6 54 17 PM

Summary by cubic

Protects inline code from being formatted while still allowing bold/italic/link spans across code. Fixes incorrect styling like init being bolded inside code (fixes #2).

  • Bug Fixes
    • Wraps each rendered code block in a unique Private Use Area placeholder, parses links/bold/italic, then restores the code block.
    • Blocks formatting inside code but preserves formatting that spans across code segments.
    • Adds tests for nested formatting, multiple code blocks, and spanning scenarios.

@panphora panphora merged commit 410b2a0 into panphora:main Aug 17, 2025
@joshdoman joshdoman deleted the inline-code-fix branch August 17, 2025 23:42
panphora added a commit that referenced this pull request Aug 17, 2025
- Added Josh Doman to Contributors section for PR #6
- Enhanced comment explaining Unicode Private Use Area choice
- Added gh-report.md analyzing all issues and PRs
- Added twitter-thread.md from successful launch
panphora added a commit that referenced this pull request Aug 18, 2025
- Add Gmail/Google Docs style link tooltips for clickable URLs (#4)
- Fix tab key causing focus loss, now inserts spaces (#3)
- Fix code elements not inheriting font-size (#1)
- Merge PR #6: Fix inline code formatting (thanks @joshdoman)
- Add Limitations section to README (#5)
- Add CHANGELOG.md for version tracking

Breaking changes: None
Build size: 73KB (up from 45KB due to Floating UI)
panphora added a commit that referenced this pull request Aug 20, 2025
- Added Josh Doman to Contributors section for PR #6
- Enhanced comment explaining Unicode Private Use Area choice
- Added gh-report.md analyzing all issues and PRs
- Added twitter-thread.md from successful launch
panphora added a commit that referenced this pull request Aug 20, 2025
- Add Gmail/Google Docs style link tooltips for clickable URLs (#4)
- Fix tab key causing focus loss, now inserts spaces (#3)
- Fix code elements not inheriting font-size (#1)
- Merge PR #6: Fix inline code formatting (thanks @joshdoman)
- Add Limitations section to README (#5)
- Add CHANGELOG.md for version tracking

Breaking changes: None
Build size: 73KB (up from 45KB due to Floating UI)
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.

Incorrectly renders inline code containing an underscore

2 participants