text highlight in markdown

SyntaxMarkdown

Syntax Problem Overview


Within a Markdown editor I want to support text highlight, not in the sense of code highlighting, but the type of highlighting people do on books.

In code oriented sites people can use backquotes for a grey background, normally inline code within a paragraph. However on books there is the marker pen for normal text within a paragraph. That is the classical black text on yellow background.

Is there any syntax within Markdown (or its variants) to specify that the user want that type of highlight? I want to preserve the backquotes syntax for code related marking, but also want a way to enable highlighted user text

My first thought is just using double backquotes, since triple backquotes are reserved for code blocks. I am just wondering if other implementations have already decided a syntax for it... I would also appreciate if someone could justify if this is a very bad idea.

Syntax Solutions


Solution 1 - Syntax

As the markdown documentation states, it is fine to use HTML if you need a feature that is not part of Markdown.

HTML5 supports

<mark>Marked text</mark>

Else you can use span as suggested by Rad Lexus

<span style="background-color: #FFFF00">Marked text</span>

Solution 2 - Syntax

I'm late to the party but it seems like a couple of markdown platforms (Quilt & iA Writer) are using a double equal to show highlighting.

==highlight==

Solution 3 - Syntax

Typora is also using double equal for highlighting. It would be nice it that becomes a CommonMark standard, as mentioned by DirtyF. It would be nice for those who use it frequently, since it is only 4 repeated chars: ==highlight==

If you want the option to use multiple editors, it may be best to stick with <mark>highlight</mark> for now, as answered by Matthias.

Here is the latest spec from CommonMark, "which attempts to specify Markdown syntax unambiguously". Currently "highlighting" is not included.

Editors using ==highlight== from comments mentioned previously:

  • Typora
  • Obsidian
  • Quilt
  • IA Writer

Feel free to add to this list.

Solution 4 - Syntax

Grey-colored Higlighting Solution

A possible solution is to use the <code> element:
This solution works really well on git/github, because git/github doesn't allow css styling.

OBS!:
Using the code-element for highlighting is not semantic.
However, it is a possible solution for adding grey-colored highlighting to text in markdown.

Markdown/HTML

<code> <i>This text will be italic</i> <b>this text will be bold</b> </code>

Output

This text will be italic this text will be bold

Solution 5 - Syntax

Roam markdown uses double-caret: ^^highlight^^. Andrew Shell's answer mentions double-equals.

The accepted and clearly correct answer is <mark> from Matthias above, but I thought I had seen carets in some other flavor of markdown. Maybe not. I want to transform my ^^highlights^^ to <mark>highlights</mark> in pandoc conversion to html, and somehow ended up here...

Solution 6 - Syntax

You can use the Grave accent (backtick) ` to highlight text in markdown

Highlighted text

Also works with VS Code extension markdownlint

Solution 7 - Syntax

Probably best bet is just use html e.g

<pre><b>Hello</b> is higlighted</pre>

Hello is higlighted

Remember nearly all html is valid in markdown too.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSystematicFrankView Question on Stackoverflow
Solution 1 - SyntaxMatthiasView Answer on Stackoverflow
Solution 2 - SyntaxAndrew ShellView Answer on Stackoverflow
Solution 3 - SyntaxBenjamin AwerkampView Answer on Stackoverflow
Solution 4 - SyntaxAugust JelemsonView Answer on Stackoverflow
Solution 5 - SyntaxSigfriedView Answer on Stackoverflow
Solution 6 - Syntaxsofien jbaliView Answer on Stackoverflow
Solution 7 - SyntaxShaneQfulView Answer on Stackoverflow