Skip to content

Conversation

@joshdoman
Copy link
Contributor

@joshdoman joshdoman commented Aug 18, 2025

This PR fixes issue #15 with two changes:

  1. A code fence may not have subsequent backticks after any text
  2. Inline code may be surrounded by multiple backticks of equal count

Strictly speaking, standard markdown also allows a code fence to begin with more than 3 backticks, provided it is closed by a code fence of equal or greater count (with no non-backtick characters), but given the complexity of implementation with the current architecture, it's probably best to leave that for a future PR.

Example 1

__init__
Not a code block

This is a code block

Before:
Screenshot 2025-08-18 at 4 56 16 PM

After:
Screenshot 2025-08-18 at 4 56 51 PM

Example 2

``This is not inline code with backticks in it`

`Nor this``

But this is inline code with `backticks` in it

Not a code block

Before:
Screenshot 2025-08-18 at 5 15 56 PM

After:
Screenshot 2025-08-18 at 5 16 16 PM


Summary by cubic

Standardized inline code parsing to support multi-backtick delimiters and prevent inline code from being treated as a code fence. This fixes false code blocks and lets inline code include backticks safely.

  • Bug Fixes
    • Treat a code fence only when the line starts with ``` and contains no other backticks (language hints allowed).
    • Parse inline code using equal-length backtick pairs (`, ``, ```), so content can include backticks.
    • Added tests for fence rejection and multi-backtick inline code, including unmatched cases.

joshdoman and others added 9 commits August 17, 2025 19:41
Fixes panphora#2. Protects inline code from being formatted while still allowing bold/italic/link spans across code. 

Uses Unicode Private Use Area placeholders to temporarily replace code blocks during formatting, then restores them afterward.

Co-authored-by: Josh Doman <joshdoman@users.noreply.github.com>
- Added Josh Doman to Contributors section for PR panphora#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
- Add Gmail/Google Docs style link tooltips for clickable URLs (panphora#4)
- Fix tab key causing focus loss, now inserts spaces (panphora#3)
- Fix code elements not inheriting font-size (panphora#1)
- Merge PR panphora#6: Fix inline code formatting (thanks @joshdoman)
- Add Limitations section to README (panphora#5)
- Add CHANGELOG.md for version tracking

Breaking changes: None
Build size: 73KB (up from 45KB due to Floating UI)
- Better naming convention for embedded diagram
- Update index.html iframe reference
- Gmail-style link tooltips
- Tab key support
- Critical bug fixes
- Ready for npm publish
panphora added a commit that referenced this pull request Aug 19, 2025
- Accepts PR #19's more comprehensive fix for inline code parsing
- Supports multi-backtick delimiters (e.g., ``code with `backticks` inside``)
- Stricter code fence detection prevents inline triple backticks from being treated as fences
- Includes comprehensive test coverage for edge cases
- Thanks to @joshdoman for the improved implementation
@panphora
Copy link
Owner

Thanks for this more comprehensive fix! The multi-backtick support and improved regex is a much better solution than our quick fix. Merging this now with the conflicts resolved in favor of your implementation.

panphora added a commit that referenced this pull request Aug 19, 2025
- Add stricter code fence detection to prevent inline code from being treated as fences
- Support multi-backtick inline code delimiters (e.g., ``code with `backtick` inside``)
- Uses negative lookbehind/lookahead regex for proper backtick matching
- Fixes issue where triple backticks with trailing content were incorrectly parsed as code fences

Co-authored-by: PR #19 contributor
panphora added a commit that referenced this pull request Aug 20, 2025
- Add stricter code fence detection to prevent inline code from being treated as fences
- Support multi-backtick inline code delimiters (e.g., ``code with `backtick` inside``)
- Uses negative lookbehind/lookahead regex for proper backtick matching
- Fixes issue where triple backticks with trailing content were incorrectly parsed as code fences

Co-authored-by: PR #19 contributor
panphora added a commit that referenced this pull request Aug 20, 2025
- Add stricter code fence detection using regex pattern
- Support multi-backtick inline code delimiters
- Prevent inline code from being interpreted as code fences
- Uses negative lookbehind/lookahead for proper backtick matching
@panphora
Copy link
Owner

Thank you for this excellent fix! Your changes were merged in commit 75e5015.

The improvements you made are now in the codebase:

  • Stricter code fence detection to prevent inline code from being treated as fences
  • Support for multi-backtick inline code delimiters

Your contribution has been credited in the README. Thanks again for fixing this important parsing issue!

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