outline / rich-markdown-editor

The open source React and Prosemirror based markdown editor that powers Outline. Want to try it out? Create an account:
https://www.getoutline.com
BSD 3-Clause "New" or "Revised" License
2.87k stars 589 forks source link

Allows intra-word emphasis using `_` #452

Closed charlesharries closed 3 years ago

charlesharries commented 3 years ago

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:

  1. Download the repo, install dependencies, and yarn start to start up Storybook
  2. Navigate to Marks in the left sidebar.
  3. After the text a link in the Canvas, add a new line, and type testing_some_text.
  4. 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 markdown

Desktop (please complete the following information):

Smartphone (please complete the following information):