Author: lgn

Contact: lars-g.nilsson@01space.net

Markdown examples

Syntax highlighting

GFM, or "GitHub Flavored Markdown" also supports syntax highlighting. To activate it, simply add the file extension of the language you want to use directly after the first code "fence", ```js, and syntax highlighting will automatically be applied in the rendered HTML. For example, to apply syntax highlighting to JavaScript code:

JS
grunt.initConfig({
  assemble: {
    options: {
      assets: 'docs/assets',
      data: 'src/data/*.{json,yml}',
      helpers: 'src/custom-helpers.js',
      partials: ['src/partials/**/*.{hbs,md}']
    },
    pages: {
      options: {
        layout: 'default.hbs'
      },
      files: {
        './': ['src/templates/pages/index.hbs']
      }
    }
  }
};

Tables

Tables are created by adding pipes as dividers between each cell, and by adding a line of dashes (also separated by bars) beneath the header. Note that the pipes do not need to be vertically aligned. MARKDOWN

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

Right aligned text

Adding a colon on the right side of the dashes below any heading will right align text for that column. MARKDOWN

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

Enhanced Tables

Grav 2.0 adds five opt-in table extensions. They are all off by default, so a standard table is never changed unless you turn one on — globally under Configuration, or per page in the page's front mattet. See front matter above

Colspan

Leave a cell empty and it merges into the cell on its left, increasing that cell's colspan (the MultiMarkdown convention). MARKDOWN

Item Jan Feb Mar
Widgets 10 12 9
Total for the quarter 57

Header-less

Start a table directly at the divider row to produce a

-only table with no header. MARKDOWN
Mercury Closest to the Sun
Neptune Furthest from the Sun

Captions

A [Caption] line immediately after a table becomes a

(rendered as the table's first child). Inline Markdown inside the caption is parsed. MARKDOWN
The first two elements of the periodic table
Symbol Element
H Hydrogen
He Helium

Attributes

A {.class #id} line immediately after a table sets the class and id on the

element — handy for CSS frameworks that style classes like .striped or .responsive. The kramdown-style {:.class} form (with a leading colon) is accepted too. Only class and id are recognized; any other token leaves the line untouched. MARKDOWN
Name Role
Ada Engineer
Grace Architect

Multi-line cells

End a row with a backslash () and the next line continues it: the following line's cells are merged column-wise into the row above, each joined with a
. An empty continuation cell adds nothing, so you can carry just one column onto the next line.

Feature Description
Tables Alignment, escaped pipes,
and inline cell content
Lists Ordered, unordered and task lists

Assemble

Add a title

01space File Vault

HTML Link:

nc.01space.net

Named Anchors

Named anchors enable you to jump to the specified anchor point on the same page. For example, each of these chapters:

Table of Contents

Chapter 1

Content for chapter one.

Chapter 2

Content for chapter one.

Chapter 3

Content for chapter one.

NOTE that specific placement of the anchor tag seems to be arbitrary. They are placed inline here since it seems to be unobtrusive, and it works.

Note

Autolinking of bare www. URLs and email addresses is new in Grav 2.0 (GitHub Flavored Markdown autolinks) and is enabled by default. Bare http(s):// URLs are handled separately by the Auto URL Links option, which remains off by default.

Visit www.getgrav.org or email hello@getgrav.org.

Or, check this out! email support@01space.net

HTML links:

Visit www.getgrav.org or email hello@getgrav.org.

Images

Images have a similar syntax to links but include a preceding exclamation point.

Minion

Code for the image:

MARKDOWN
![Minion](https://octodex.github.com/images/minion.png)

Another example:

Alt text

Code:

MD
![Alt text](https://octodex.github.com/images/stormtroopocat.jpg "The Stormtroopocat")

Hovering text: "The Stormtroopocat"

Like links, images also have a footnote style syntax:

MARKDOWN
![Alt text][id] # e.g. [bild1]

Alt text

With a reference later in the document defining the URL location:

TXT
[id]: https://octodex.github.com/images/dojocat.jpg  "The Dojocat"

Configuration

Markdown rendering is configured under Configuration → System → Markdown in the Admin panel, or in user/config/system.yaml under the pages.markdown key. Any option can also be overridden per page in the page's front matter under a markdown: key. The defaults are:

YAML
pages:
  markdown:
    extra: false              # Enable Markdown Extra
    auto_line_breaks: false   # Treat a single newline as a <br>
    auto_url_links: false     # Autolink bare http(s):// URLs
    escape_markup: false      # Escape inline HTML into entities
    gfm:                      # GitHub Flavored Markdown - on by default
      task_lists: true        # - [ ] / - [x] checkboxes
      marks: true             # ==highlight==, ~subscript~, ^superscript^
      tagfilter: true         # Escape disallowed raw HTML tags
      autolinks: true         # Autolink bare www. URLs and emails
    tables:                   # Enhanced table extensions - off by default
      colspan: false          # Empty cell merges into the cell on its left
      headerless: false       # Table may start at the divider row
      captions: false         # [Caption] line after a table becomes <caption>
      attributes: false       # {.class #id} line after a table sets attributes
      multiline: false        # Row ending in \ continues onto the next line

The gfm options change how existing content renders (checkboxes, <mark>/<sub>/<sup>, autolinked URLs, escaped raw HTML), so each can be switched off individually if you need the previous behavior. The tables extensions are all off by default and never affect a standard table unless you opt in.

Tip

Plugin developers can add their own Markdown syntax — custom blocks and inline marks — through the Markdown Extensions API

Twig in Content

You can also process Twig inside a page's Markdown content. In Grav 2.0 this is off by default and, when enabled, runs inside a security sandbox — a change from earlier versions, where process.twig: true on a page ran content Twig with no restrictions. See Twig in Content for how it works, how to enable it, and the recommended alternatives (page templates and shortcodes).