A general markdown cheat sheet can be found here. This file only documents site specific quirks and extensions.
LaTeX can be used between $
signs:
$E = mc^2$
renders to $E = mc^2$.
Displayed equations can be done with $$
$$
\frac{1}{2 \pi i} \oint \frac{ f(z) }{\zeta - z} \, dz = f(\zeta)
$$
Labeled equations using \begin{equation}
etc. environments:
\begin{equation}\label{eq1}
-\lap u = 0 \quad\text{in } \Omega
\end{equation}
can be referred to using \eqref{eq1}
: \eqref{eq1}.
[[file]]
generates a link to file
.[[/index.md|Test]]
, which links to /index.html
and says Test
.
This renders like this: Testmarkdown
files, an extension of .md
is replaced with .html
.
Also, if the link text is omitted the title of the linked file is used instead.
E.g. [[markdown.md]]
renders like this: Markdown test./
will be prefixed with site_prefix
.The code highlight extension is enabled.
Code blocks should be automatically highlighted.
Begin the code block with :::language
to specify the language.
For instance
:::html <p class='lead'>This is <em>html</em></p>
renders as
<p class='lead'>This is <em>html</em></p>
You can also use the fenced code blocks ```…```
style.
All markdown files are rendered by Jinja2
before being passed to a
python-markdown
.
All Jinja2
commands need to be escaped accordingly.
{{title}}
renders as Local Extensions and site specific details
{{1 + 1}}
renders as 2
{{ markdown("*hello*") }}
expands to <p><em>hello</em></p>
.
Mark a block as raw using
{% raw %} Raw block. No Jinja commands will work here. {{ 1 + a }} {% hello %} world {% endraw %}
Alternately, escape using {{'{{'}}
.
All markdown files have a YAML metadata block at the top (until the first newline). A few fields used in the current layouts are:
title
: Document titlebreadcrumb
: List of navigation breadcrumbs.summary
: Summary of file (used in the index).tags
: Tags. Listed in the index, but nothing fancy is done as of now.layout
: Change the default template layout.comments
: Set to disabled
disable comments (see below).Metadata from a file can be accessed using the function get_meta( file_name, field)
. Omit field
to get the whole metadata block.
name
: Path of the markdown file (e.g. blog/20171021-setup/local-extensions.md
)dirname
: Path of directory containing current file (e.g. blog/20171021-setup
)basename
: Name of markdown file (e.g. local-extensions.md
).filesdir
: Name of markdown file with extension stripped (e.g. local-extensions
). This can be used as a directory to store images, etc.site.cfg
.path_exists
. It returns None
if it doesn’t exist, or the full path name from the root directory if it does (e.g. blog/20171021-setup/local-extensions.md
).glob
function.
For instance, the following will list the 5 most recent markdown files in the current directory and their titles:{% set files = glob( '/blog/[0-9]*.md' ) | sort( reverse=True ) -%} {% for f in files[:5] -%} * File: {{f}}. Title: {{get_meta( f, 'title' )}} {% endfor %}
Comments require a CGI script on the server.
This script simply takes the contents of the comment, and mails it to the webmaster as a mime attachment.
If you decide its not spam, save it (with the recommended filename) in the directory blog/_comments
and it will appear on the right post.
If you want comments disabled use the comments: disabled
field in the YAML meta data.
By default markdown files have the layout md-default.j2
which links to md-right-nav-affix.j2
.
This shows the table of contents on the right on large screens, which highlights the current section and sticks to the top of the window.
(Look here for more information on the layouts.)
The layout can be changed using
layout: md-right-nav.j2
as meta-data.
The contents of _sidenav.md
in the same directory is included below the table of contents in some layouts.
For class pages (using md-class.j2
layout) contents of _hw.md
and _handouts.md
are used in the side panel navigation.
Various custom macros are in the includes/macros.j2
file and can be used in markdown documents.
A few are listed here.