remarkjs / remark

markdown processor powered by plugins part of the @unifiedjs collective
https://remark.js.org
MIT License
7.56k stars 352 forks source link

Consider adding syntax support for <mark> higlighting #659

Closed iljapanic closed 3 years ago

iljapanic commented 3 years ago

Subject of the feature

Many popular markdown editors such as iA Writer, Typora, Obsidian use == to denote highlighted text and wrap the output in <mark> tags.

It now seems to have become a standard notation for highlighting. See discussion on CommonMark forum for more details. I.e. Remark supports the highlighting syntax.

Here are details on the <mark> HTML element:

The HTML Mark Text element () represents text which is marked or highlighted for reference or notation purposes, due to the marked passage's relevance or importance in the enclosing context.

Full <mark> spec

Expected behavior

Markdown

Vestibulum id ==ligula porta felis=== euismod semper.

HTML output

Vestibulum id <mark>ligula porta felis</mark> euismod semper.

HTML default rendering

Snapshot 2021-03-15 at 16 33 40@2x
wooorm commented 3 years ago

Syntax extensions and other things in remark happen through plugins from community members.

Here’s an example of a remark plugin that adds supported for a new syntax, in this case math: https://github.com/remarkjs/remark-math/blob/main/packages/remark-math/index.js.

It defers to two other things. A micromark extension, which handles the tokenizing, and an mdast utility, which handles tokens -> ast, and ast -> string. Most of the work for marks would be close to how strikethrough works: https://github.com/micromark/micromark-extension-gfm-strikethrough/blob/main/index.js.