Skip to content

Add markdown-style em and strong format support#62289

Open
bacoords wants to merge 2 commits intoWordPress:trunkfrom
bacoords:add/emphasis-format-support
Open

Add markdown-style em and strong format support#62289
bacoords wants to merge 2 commits intoWordPress:trunkfrom
bacoords:add/emphasis-format-support

Conversation

@bacoords
Copy link
Copy Markdown
Contributor

@bacoords bacoords commented Jun 4, 2024

What?

In the editor, if a user types * or _ before and after a word/phrase, the text is then wrapped in <em> tags. If a user types ** or __ before and after a word/phrase, the text is then wrapped in <strong> tags.

This follows the markdown format, similar to backticks being used for <code>, hash characters for headings, lists, horizontal rule, etc.

Why?

There is inconsistent support for Markdown-style shortcuts currently.

Closes #62243

How?

Updates the format-library package to include support for italic and bold shortcuts.

Testing Instructions

  1. Open a post or page.
  2. Insert a paragraph block.
  3. Start typing and try starting/ending a phrase with *, _ to see italics and **, __ to see bold.

Testing Instructions for Keyboard

Screenshots or screencast

Screen.Recording.2024-06-04.at.8.22.39.AM.mov

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 4, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: bacoords <bacoords@git.wordpress.org>
Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. [Package] Format library /packages/format-library labels Jun 4, 2024
@Mamaduka Mamaduka self-requested a review June 4, 2024 15:42
@carolinan
Copy link
Copy Markdown
Contributor

How do users enter actual *text and **text in their content without enforcing the formatting?
(Not everyone will know about or will want to use the footnotes)

@ellatrix
Copy link
Copy Markdown
Member

ellatrix commented Jun 5, 2024

I've considered this before and we were worries about false positives, but maybe that worry is questionable. Input rules can be undone with cmd+z, Backspace, and Escape I believe.

@Mamaduka
Copy link
Copy Markdown
Member

Mamaduka commented Jun 5, 2024

Yes, the input rules can be undone via CMD+Z and Backspace.

@carolinan
Copy link
Copy Markdown
Contributor

That assumes the users knows about it.

@bacoords
Copy link
Copy Markdown
Contributor Author

bacoords commented Jun 5, 2024

I would just note that the convention of transforming text based on special characters already exists. If a user wants to start a paragraph with a hash # or a hypen - they have this same issue - the block is transformed into a heading or list and they have to learn to use backspace or cmd-z to reverse it. The same for using backticks inline (which can only be reversed with cmd-z, not backspace, I believe).

This would behave similar to the backtick character, in that if you have more than one in a paragraph, it will automatically transform the text in between, but you can undo it with cmd-z. Also it will not automatically transform any text that is copy/pasted or added out of order.

@dcalhoun dcalhoun removed their request for review August 28, 2024 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Format library /packages/format-library [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for "emphasis" markdown shortcuts

4 participants