Skip to content

[EuiMarkdownFormat] Fix intraword underscore emphasis rendering#9408

Draft
acstll wants to merge 2 commits intoelastic:mainfrom
acstll:fix/markdown-intraword-underscore-emphasis
Draft

[EuiMarkdownFormat] Fix intraword underscore emphasis rendering#9408
acstll wants to merge 2 commits intoelastic:mainfrom
acstll:fix/markdown-intraword-underscore-emphasis

Conversation

@acstll
Copy link
Contributor

@acstll acstll commented Feb 24, 2026

Summary

Adds a remark AST transformer plugin (remark_intraword_underscore) that reverses incorrectly applied emphasis/strong nodes when underscore delimiters are flanked by alphanumeric characters on both sides (intraword context).

remark-parse v8 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-parse is 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). EuiMarkdownFormat renders 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

  • Browser QA
    • Checked in both light and dark modes
    • Checked in both MacOS and Windows high contrast modes
    • Checked in mobile
    • Checked in Chrome, Safari, Edge, and Firefox
    • Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA
  • Code quality checklist
  • Release checklist
    • A changelog entry exists and is marked appropriately
    • If applicable, added the breaking change issue label
    • If the changes unblock an issue in a different repo, smoke tested carefully
  • Designer checklist

Made with Cursor

…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>
@acstll acstll requested a review from a team as a code owner February 24, 2026 13:06
@acstll acstll self-assigned this Feb 24, 2026
@acstll acstll added the skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) label Feb 24, 2026
@acstll acstll marked this pull request as draft February 24, 2026 13:07
@acstll acstll added support-duty-flywheel Label for PRs, see eui-private #310 and removed skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) labels Feb 24, 2026
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

cc @acstll

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

cc @acstll

Copy link
Member

@tkajtoch tkajtoch left a comment

Choose a reason for hiding this comment

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

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!

@acstll
Copy link
Contributor Author

acstll commented Feb 25, 2026

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!

nice! i'll go through it again and add a small unit test, and then i'll open 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

support-duty-flywheel Label for PRs, see eui-private #310

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[EuiMarkdownFormat] Renderer misinterprets Salesforce API object

3 participants