[EuiMarkdownFormat] Fix intraword underscore emphasis rendering#9408
Draft
acstll wants to merge 2 commits intoelastic:mainfrom
Draft
[EuiMarkdownFormat] Fix intraword underscore emphasis rendering#9408acstll wants to merge 2 commits intoelastic:mainfrom
acstll wants to merge 2 commits intoelastic:mainfrom
Conversation
…tic#9404) Add a remark AST transformer plugin that reverses incorrectly applied emphasis/strong nodes when underscore delimiters are flanked by alphanumeric characters on both sides (intraword context), matching the CommonMark specification behavior that remark-parse v8 does not implement. This prevents Salesforce-style identifiers like SBQQ__OrderProductBookings__c from being rendered with bold formatting. Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
💚 Build Succeededcc @acstll |
Collaborator
💚 Build Succeeded
cc @acstll |
tkajtoch
reviewed
Feb 24, 2026
Member
tkajtoch
left a comment
There was a problem hiding this comment.
I was initially thinking we'd handle that outside remark but having it as a plugin is also a valid solution :D So far the changes look good. Let me know when the PR is ready for final review!
Contributor
Author
nice! i'll go through it again and add a small unit test, and then i'll open 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a remark AST transformer plugin (
remark_intraword_underscore) that reverses incorrectly appliedemphasis/strongnodes when underscore delimiters are flanked by alphanumeric characters on both sides (intraword context).remark-parsev8 does not implement the CommonMark specification rule that underscore delimiters which are both left-flanking and right-flanking (i.e. surrounded by word characters) cannot open or close emphasis. This plugin walks the parsed AST post-parse, detects these cases by checking sibling text nodes and verifying the delimiter is_(not*) via source position, and flattens the nodes back to plain text with underscores restored.This is a temporary workaround until
remark-parseis upgraded to a version that natively handles this rule.Why are we making this change?
Closes #9404
Salesforce API identifiers use underscores and double underscores extensively (e.g.
SBQQ__OrderProductBookings__c,Custom_Field__c).EuiMarkdownFormatrenders these with bold/italic formatting instead of preserving them verbatim, making the text unreadable and unusable for copy-paste.Impact to users
🟢 Intraword underscore sequences that were previously (incorrectly) rendered as bold or italic will now display as plain text, matching CommonMark spec behavior. Legitimate emphasis using
__bold__or_italic_with whitespace boundaries continues to work as expected. Asterisk-based emphasis (**bold**,*italic*) is completely unaffected.QA
Remove or strikethrough items that do not apply to your PR.
General checklist
Docs site QAAdded documentationProps have proper autodocsChecked Code Sandbox works for any docs examplesUpdated visual regression testsIf applicable, added the breaking change issue labelIf the changes unblock an issue in a different repo, smoke tested carefullyDesigner checklistMade with Cursor