Underscores within a word currently generate emphasis tags, but according to a couple of accepted Markdown specs (GitHub-flavoured, CommonMark), they shouldn't. Crucially, however, this behaviour should only apply to _ characters; intraword emphasis using * is allowed.
For example: this_is_some_text currently yields this<em>is</em>some_text, which is incorrect; it should yield this_is_some_text.
Earlier work
It looks like a sort of related issue was addressed in #298, allowing intraword underscores within code blocks. The issue here is that this behaviour doesn't catch a couple of (what seem to me) common ways of typing up code blocks (see screenshots below).
Fix
Getting this up to full CommonMark compliance is probably a pretty serious task, but I think that changing Italic.inputRules() to accept intraword underscores would be a pretty simple way to get this up and running.
I'll take a swing at this one and aim open a PR with the fix this weekend.
To Reproduce
Steps to reproduce the behavior:
Download the repo, install dependencies, and yarn start to start up Storybook
Navigate to Marks in the left sidebar.
After the text a link in the Canvas, add a new line, and type testing_some_text.
The three underscore-separated words should merge into a single word, with the fragment "some" being italicised.
Expected behavior
I'd expect the three underscore-separated words to remain underscore-separated, without being formatted.
Version
11.8.1
Screenshots
Desktop (please complete the following information):
OS: macOS
Browser: Chromium 90/Firefox 89/Safari 14.1
Smartphone (please complete the following information):
I haven't tested on mobile but I assume that the behaviour exists here too.
Underscores within a word currently generate emphasis tags, but according to a couple of accepted Markdown specs (GitHub-flavoured, CommonMark), they shouldn't. Crucially, however, this behaviour should only apply to
_
characters; intraword emphasis using*
is allowed.For example:
this_is_some_text
currently yieldsthis<em>is</em>some_text
, which is incorrect; it should yieldthis_is_some_text
.Earlier work It looks like a sort of related issue was addressed in #298, allowing intraword underscores within code blocks. The issue here is that this behaviour doesn't catch a couple of (what seem to me) common ways of typing up code blocks (see screenshots below).
Fix Getting this up to full CommonMark compliance is probably a pretty serious task, but I think that changing
Italic.inputRules()
to accept intraword underscores would be a pretty simple way to get this up and running.I'll take a swing at this one and aim open a PR with the fix this weekend.
To Reproduce Steps to reproduce the behavior:
yarn start
to start up Storybooktesting_some_text
.Expected behavior I'd expect the three underscore-separated words to remain underscore-separated, without being formatted.
Version 11.8.1
Screenshots
Desktop (please complete the following information):
Smartphone (please complete the following information):