Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply color in Markdown?

Tags:

markdown

I want to use Markdown to store textual information. But quick googling says Markdown does not support color. Also StackOverflow does not support color. Same as in case of GitHub markdown.

Is there any flavor of markdown that allows colored text?

like image 827
Mahesha999 Avatar asked Feb 17 '16 19:02

Mahesha999


People also ask

Can you add color in Markdown?

Markdown doesn't support color but you can inline HTML inside Markdown, e.g.: <span style="color:blue">some *blue* text</span>. As the original/official syntax rules state (emphasis added): Markdown's syntax is intended for one purpose: to be used as a format for writing for the web.

How do I add color to a readme file?

You can however add color to code samples with the tags below. To do this just add tags such as these samples to your README.md file: ```json // code for coloring ``` ```html // code for coloring ``` ```js // code for coloring ``` ```css // code for coloring ``` // etc.

How do I change the text color in markup?

Right click on the highlighted text, select Properties, and pick a color in the Appearance tab.

How do you highlight in Markdown?

“Markdown is a simple language that is utilized to add formatting to a plain text document. Using “==” in this language gives us a simple way to highlight text. These “==” double equals are used in markdown to highlight the text.


2 Answers

TL;DR

Markdown doesn't support color but you can inline HTML inside Markdown, e.g.:

<span style="color:blue">some *blue* text</span>. 

Longer answer

As the original/official syntax rules state (emphasis added):

Markdown’s syntax is intended for one purpose: to be used as a format for writing for the web.

Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is not to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert. The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a publishing format; Markdown is a writing format. Thus, Markdown’s formatting syntax only addresses issues that can be conveyed in plain text.

For any markup that is not covered by Markdown’s syntax, you simply use HTML itself.

As it is not a "publishing format," providing a way to color your text is out-of-scope for Markdown. That said, it is not impossible as you can include raw HTML (and HTML is a publishing format). For example, the following Markdown text (as suggested by @scoa in a comment):

Some Markdown text with <span style="color:blue">some *blue* text</span>. 

Would result in the following HTML:

<p>Some Markdown text with <span style="color:blue">some <em>blue</em> text</span>.</p> 

Now, StackOverflow (and probably GitHub) will strip the raw HTML out (as a security measure) so you lose the color here, but it should work on any standard Markdown implementation.

Another possibility is to use the non-standard Attribute Lists originally introduced by the Markuru implementation of Markdown and later adopted by a few others (there may be more, or slightly different implementations of the same idea, like div and span attributes in pandoc). In that case, you could assign a class to a paragraph or inline element, and then use CSS to define a color for a class. However, you absolutely must be using one of the few implementations which actually support the non-standard feature and your documents are no longer portable to other systems.

like image 57
Waylan Avatar answered Sep 24 '22 17:09

Waylan


When you want to use pure Markdown (without nested HTML), you can use Emojis to draw attention to some fragment of the file, i.e. ⚠️WARNING⚠️, 🔴IMPORTANT❗🔴 or 🔥NEW🔥.

like image 31
TeWu Avatar answered Sep 21 '22 17:09

TeWu