Markdown

Wed, 28 Sep 2022 21:43:31 +0200

Let's face it: Writing content for the Web is tiresome. WYSIWYG editors help alleviate this task, but they generally result in horrible code, or worse yet, ugly web pages.

Markdown is a better way to write HTML, without all the complexities and ugliness that usually accompanies it.

Some of the key benefits are:

1. Markdown is simple to learn, with minimal extra characters so it's also quicker to write content.

2. Less chance of errors when writing in markdown.

3. Produces valid XHTML output.

4. Keeps the content and the visual display separate, so you cannot mess up the look of your site.

5. Write in any text editor or Markdown application you like.

6. Markdown is a joy to use!

John Gruber, the author of Markdown, puts it like this:

The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions. While Markdown’s syntax has been influenced by several existing text-to-HTML filters, the single biggest source of inspiration for Markdown’s syntax is the format of plain text email. -- John Gruber

Grav ships with built-in support for Markdown and Markdown Extra. You must enable Markdown Extra in your system.yaml configuration file

Without further delay, let us go over the main elements of Markdown and what the resulting HTML looks like:

Bookmark this page for easy future reference!

Headings

Headings from h1 through h6 are constructed with a # for each level:

# h1 Heading
## h2 Heading
### h3 Heading
#### h4 Heading
##### h5 Heading
###### h6 Heading

Renders to:

h1 Heading

h2 Heading

h3 Heading

h4 Heading

h5 Heading

h6 Heading

HTML:

h1 Heading
h2 Heading
h3 Heading
h4 Heading
h5 Heading
h6 Heading

Comments

Comments should be HTML compatible

<!--
This is a comment
-->

Comment below should NOT be seen:

Horizontal Rules

The HTML element is for creating a "thematic break" between paragraph-level elements. In markdown, you can create a with any of the following:

___: three consecutive underscores

---: three consecutive dashes

***: three consecutive asterisks

renders to:

Body Copy

Body copy written as normal, plain text will be wrapped with tags in the rendered HTML.

So this body copy:

Lorem ipsum dolor sit amet, graecis denique ei vel, at duo primis mandamus. Et legere ocurreret pri, animal tacimates complectitur ad cum. Cu eum inermis inimicus efficiendi. Labore officiis his ex, soluta officiis concludaturque ei qui, vide sensibus vim ad.

renders to this HTML:

Lorem ipsum dolor sit amet, graecis denique ei vel, at duo primis mandamus. Et legere ocurreret pri, animal tacimates complectitur ad cum. Cu eum inermis inimicus efficiendi. Labore officiis his ex, soluta officiis concludaturque ei qui, vide sensibus vim ad.

Emphasis

Bold

For emphasizing a snippet of text with a heavier font-weight.

The following snippet of text is rendered as bold text.

**rendered as bold text**...