120

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.

2
  • I agree. I'd like to implement something like the back tick. Something simple for data entry/end users (that doesn't involve writing html)
    – Mitkins
    Sep 29, 2016 at 0:04
  • 1
    Did you end up settling on anything?
    – Mitkins
    Sep 29, 2016 at 0:05

7 Answers 7

Reset to default

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

163

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>

6
  • 9
    Note that Github does not render the inline style correctly.
    – Ini
    Sep 24, 2018 at 9:13
  • 11
    The mark tag can also take a different background color (default is bright yellow). That is--<mark style="background-color: lightblue">Marked text</mark> also works :)
    – Shan Dou
    Jan 6, 2019 at 22:29
  • 1
    The <mark> one is the only one that works in Google Colaboratory since it drops all styles from inline HTML for whatever reason... Mar 7, 2019 at 2:23
  • @Ini so what is the correct syntax for github markdown then?
    – pcko1
    Oct 1, 2020 at 11:09
  • @pcko1: Idk, maybe it is simply not supported
    – Ini
    Oct 1, 2020 at 13:38
26

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==
2
  • 9
    obsidian.md also use the ==higlight== syntax, which is quiet handy, hope it makes it to the CommonMark spec.
    – DirtyF
    Nov 1, 2020 at 19:12
  • 1
    also works on vscode for markdowns
    – Dexter
    Jan 7 at 14:53
15

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.

1
  • 3
    Note: In Typora you must enable double equals for highlighting in Preferences -> Markdown Mar 2, 2021 at 17:24
5

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

4

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

Highlighted text

Also works with VS Code extension markdownlint

3

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...

-6

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.

1
  • 3
    Then using a span with a background would make more sense ... Bold is already in Markdown.
    – Jongware
    Aug 3, 2014 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.