Overview
This package allows Plone users to include MultiMarkdown syntax in their Plone sites. MultiMarkdown is a derivative of John Gruber’s original Markdown project. To see the improved MultiMarkdown syntax, check out the Syntax Guide. CriticMarkup is a way for authors and editors to track changes to documents in plain text. As with Markdown, small groups of distinctive characters allow you to highlight insertions, deletions, substitutions and comments, all without the overhead of heavy, proprietary office suites.
Nearly all Markdown applications support the basic syntax outlined in John Gruber’s original design document. There are minor variations and discrepancies between Markdown processors — those are noted inline wherever possible.
Headings
To create a heading, add number signs (#
) in front of a word or phrase. The number of number signs you use should correspond to the heading level. For example, to create a heading level three (<h3>
), use three number signs (e.g., ### My Header
).
Markdown | HTML | Rendered Output |
---|---|---|
# Heading level 1 | <h1>Heading level 1</h1> | |
## Heading level 2 | <h2>Heading level 2</h2> | Heading level 2 |
### Heading level 3 | <h3>Heading level 3</h3> | Heading level 3 |
#### Heading level 4 | <h4>Heading level 4</h4> | Heading level 4 |
##### Heading level 5 | <h5>Heading level 5</h5> | Heading level 5 |
###### Heading level 6 | <h6>Heading level 6</h6> | Heading level 6 |
Alternate Syntax
Alternatively, on the line below the text, add any number of characters for heading level 1 or --
characters for heading level 2.
Markdown | HTML | Rendered Output |
---|---|---|
Heading level 1 | <h1>Heading level 1</h1> | |
Heading level 2 | <h2>Heading level 2</h2> | Heading level 2 |
Heading Best Practices
Markdown applications don’t agree on how to handle a missing space between the number signs (#
) and the heading name. For compatibility, always put a space between the number signs and the heading name.
✅ Do this | ❌ Don't do this |
---|---|
# Here's a Heading | #Here's a Heading |
Paragraphs
To create paragraphs, use a blank line to separate one or more lines of text.
Markdown | HTML | Rendered Output |
---|---|---|
I really like using Markdown. | <p>I really like using Markdown.</p> | I really like using Markdown. I think I'll use it to format all of my documents from now on. |
Paragraph Best Practices
Unless the paragraph is in a list, don’t indent paragraphs with spaces or tabs.
✅ Do this | ❌ Don't do this |
---|---|
Don't put tabs or spaces in front of your paragraphs. | This can result in unexpected formatting problems. |
Line Breaks
To create a line break (<br>
), end a line with two or more spaces, and then type return.
Markdown | HTML | Rendered Output |
---|---|---|
This is the first line. | <p>This is the first line.<br> | This is the first line. |
Line Break Best Practices
You can use two or more spaces (commonly referred to as “trailing whitespace”) for line breaks in nearly every Markdown application, but it’s controversial. It’s hard to see trailing whitespace in an editor, and many people accidentally or intentionally put two spaces after every sentence. For this reason, you may want to use something other than trailing whitespace for line breaks. Fortunately, there is another option supported by nearly every Markdown application: the <br>
HTML tag.
For compatibility, use trailing white space or the <br>
HTML tag at the end of the line.
There are two other options I don’t recommend using. CommonMark and a few other lightweight markup languages let you type a backslash () at the end of the line, but not all Markdown applications support this, so it isn’t a great option from a compatibility perspective. And at least a couple lightweight markup languages don’t require anything at the end of the line — just type return and they’ll create a line break.
✅ Do this | ❌ Don't do this |
---|---|
First line with two spaces after. | First line with a backslash after. |
Emphasis
You can add emphasis by making text bold or italic.
Bold
To bold text, add two asterisks or underscores before and after a word or phrase. To bold the middle of a word for emphasis, add two asterisks without spaces around the letters.
Markdown | HTML | Rendered Output |
---|---|---|
I just love **bold text**. | I just love <strong>bold text</strong>. | I just love bold text. |
I just love __bold text__. | I just love <strong>bold text</strong>. | I just love bold text. |
Love**is**bold | Love<strong>is</strong>bold | Loveisbold |
Bold Best Practices
Markdown applications don’t agree on how to handle underscores in the middle of a word. For compatibility, use asterisks to bold the middle of a word for emphasis.
✅ Do this | ❌ Don't do this |
---|---|
Love**is**bold | Love__is__bold |
Italic
To italicize text, add one asterisk or underscore before and after a word or phrase. To italicize the middle of a word for emphasis, add one asterisk without spaces around the letters.
Markdown | HTML | Rendered Output |
---|---|---|
Italicized text is the *cat's meow*. | Italicized text is the <em>cat's meow</em>. | Italicized text is the cat’s meow. |
Italicized text is the _cat's meow_. | Italicized text is the <em>cat's meow</em>. | Italicized text is the cat’s meow. |
A*cat*meow | A<em>cat</em>meow | Acatmeow |
Italic Best Practices
Markdown applications don’t agree on how to handle underscores in the middle of a word. For compatibility, use asterisks to italicize the middle of a word for emphasis.
✅ Do this | ❌ Don't do this |
---|---|
A*cat*meow | A_cat_meow |
Multimarkdown Table Syntax
Bold and Italic
To emphasize text with bold and italics at the same time, add three asterisks or underscores before and after a word or phrase. To bold and italicize the middle of a word for emphasis, add three asterisks without spaces around the letters.
Markdown | HTML | Rendered Output |
---|---|---|
This text is ***really important***. | This text is <strong><em>really important</em></strong>. | This text is really important. |
This text is ___really important___. | This text is <strong><em>really important</em></strong>. | This text is really important. |
This text is __*really important*__. | This text is <strong><em>really important</em></strong>. | This text is really important. |
This text is **_really important_**. | This text is <strong><em>really important</em></strong>. | This text is really important. |
This is really***very***important text. | This is really<strong><em>very</em></strong>important text. | This is reallyveryimportant text. |
Bold and Italic Best Practices
Markdown applications don’t agree on how to handle underscores in the middle of a word. For compatibility, use asterisks to bold and italicize the middle of a word for emphasis.
✅ Do this | ❌ Don't do this |
---|---|
This is really***very***important text. | This is really___very___important text. |
Blockquotes
To create a blockquote, add a >
in front of a paragraph.
The rendered output looks like this:
Dorothy followed her through many of the beautiful rooms in her castle.
Blockquotes with Multiple Paragraphs
Blockquotes can contain multiple paragraphs. Add a >
on the blank lines between the paragraphs.
The rendered output looks like this:
Dorothy followed her through many of the beautiful rooms in her castle.
The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
Nested Blockquotes
Blockquotes can be nested. Add a >>
in front of the paragraph you want to nest.
The rendered output looks like this:
Dorothy followed her through many of the beautiful rooms in her castle.
The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
Blockquotes with Other Elements
Blockquotes can contain other Markdown formatted elements. Not all elements can be used — you’ll need to experiment to see which ones work.
The rendered output looks like this:
The quarterly results look great!
- Revenue was off the chart.
- Profits were higher than ever.
Everything is going according to plan.
Lists
You can organize items into ordered and unordered lists.
Ordered Lists
To create an ordered list, add line items with numbers followed by periods. The numbers don’t have to be in numerical order, but the list should start with the number one.
Markdown | HTML | Rendered Output |
---|---|---|
1. First item | <ol> |
|
1. First item | <ol> |
|
1. First item | <ol> |
|
1. First item | <ol> |
|
Ordered List Best Practices
CommonMark and a few other lightweight markup languages let you use a parenthesis ()
) as a delimiter (e.g., 1) First item
), but not all Markdown applications support this, so it isn’t a great option from a compatibility perspective. For compatibility, use periods only.
✅ Do this | ❌ Don't do this |
---|---|
1. First item | 1) First item |
Unordered Lists
To create an unordered list, add dashes (-
), asterisks (*
), or plus signs (+
) in front of line items. Indent one or more items to create a nested list.
Markdown | HTML | Rendered Output |
---|---|---|
- First item | <ul> |
|
* First item | <ul> |
|
+ First item | <ul> |
|
- First item | <ul> |
|
Starting Unordered List Items With Numbers
If you need to start an unordered list item with a number followed by a period, you can use a backslash () to escape the period.
Markdown | HTML | Rendered Output |
---|---|---|
- 1968. A great year! | <ul> |
|
Unordered List Best Practices
Markdown applications don’t agree on how to handle different delimiters in the same list. For compatibility, don’t mix and match delimiters in the same list — pick one and stick with it.
✅ Do this | ❌ Don't do this |
---|---|
- First item | + First item |
Adding Elements in Lists
To add another element in a list while preserving the continuity of the list, indent the element four spaces or one tab, as shown in the following examples.
Paragraphs
The rendered output looks like this:
- This is the first list item.
Here’s the second list item.
I need to add another paragraph below the second list item.
- And here’s the third list item.
Blockquotes
The rendered output looks like this:
- This is the first list item.
Here’s the second list item.
A blockquote would look great below the second list item.
- And here’s the third list item.
Code Blocks
Code blocks are normally indented four spaces or one tab. When they’re in a list, indent them eight spaces or two tabs.
The rendered output looks like this:
- Open the file.
Find the following code block on line 21:
- Update the title to match the name of your website.
Images
The rendered output looks like this:
- Open the file containing the Linux mascot.
Marvel at its beauty.
- Close the file.
Lists
You can nest an unordered list in an ordered list, or vice versa.
The rendered output looks like this:
- First item
- Second item
- Third item
- Indented item
- Indented item
- Fourth item
Code
To denote a word or phrase as code, enclose it in backticks (`
).
Markdown | HTML | Rendered Output |
---|---|---|
At the command prompt, type `nano`. | At the command prompt, type <code>nano</code>. | At the command prompt, type nano . |
Escaping Backticks
If the word or phrase you want to denote as code includes one or more backticks, you can escape it by enclosing the word or phrase in double backticks (``
).
Markdown | HTML | Rendered Output |
---|---|---|
``Use `code` in your Markdown file.`` | <code>Use `code` in your Markdown file.</code> | Use `code` in your Markdown file. |
Code Blocks
To create code blocks, indent every line of the block by at least four spaces or one tab.
The rendered output looks like this:
Multimarkdown Syntax Cheat Sheet
Horizontal Rules
To create a horizontal rule, use three or more asterisks (***
), dashes (---
), or underscores (___
) on a line by themselves.
The rendered output of all three looks identical:
Horizontal Rule Best Practices
For compatibility, put blank lines before and after horizontal rules.
✅ Do this | ❌ Don't do this |
---|---|
Try to put a blank line before... | Without blank lines, this would be a heading. |
Links
To create a link, enclose the link text in brackets (e.g., [Duck Duck Go]
) and then follow it immediately with the URL in parentheses (e.g., (https://duckduckgo.com)
).
The rendered output looks like this:
My favorite search engine is Duck Duck Go.
Adding Titles
You can optionally add a title for a link. This will appear as a tooltip when the user hovers over the link. To add a title, enclose it in parentheses after the URL.
The rendered output looks like this:
My favorite search engine is Duck Duck Go.
URLs and Email Addresses
To quickly turn a URL or email address into a link, enclose it in angle brackets.
The rendered output looks like this:
https://www.markdownguide.org
fake@example.com
Formatting Links
To emphasize links, add asterisks before and after the brackets and parentheses. To denote links as code, add backticks in the brackets.
The rendered output looks like this:
I love supporting the EFF.
This is the Markdown Guide.
See the section on code
.
Reference-style Links
Reference-style links are a special kind of link that make URLs easier to display and read in Markdown. Reference-style links are constructed in two parts: the part you keep inline with your text and the part you store somewhere else in the file to keep the text easy to read.
Formatting the First Part of the Link
The first part of a reference-style link is formatted with two sets of brackets. The first set of brackets surrounds the text that should appear linked. The second set of brackets displays a label used to point to the link you’re storing elsewhere in your document.
Although not required, you can include a space between the first and second set of brackets. The label in the second set of brackets is not case sensitive and can include letters, numbers, spaces, or punctuation.
This means the following example formats are roughly equivalent for the first part of the link:
[hobbit-hole][1]
[hobbit-hole] [1]
Formatting the Second Part of the Link
The second part of a reference-style link is formatted with the following attributes:
- The label, in brackets, followed immediately by a colon and at least one space (e.g.,
[label]:
). - The URL for the link, which you can optionally enclose in angle brackets.
- The optional title for the link, which you can enclose in double quotes, single quotes, or parentheses.
This means the following example formats are all roughly equivalent for the second part of the link:
[1]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle
[1]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle 'Hobbit lifestyles'
[1]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle 'Hobbit lifestyles'
[1]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle (Hobbit lifestyles)
[1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> 'Hobbit lifestyles'
[1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> 'Hobbit lifestyles'
[1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> (Hobbit lifestyles)
You can place this second part of the link anywhere in your Markdown document. Some people place them immediately after the paragraph in which they appear while other people place them at the end of the document (like endnotes or footnotes).
An Example Putting the Parts Together
Say you add a URL as a standard URL link to a paragraph and it looks like this in Markdown:
Though it may point to interesting additional information, the URL as displayed really doesn’t add much to the existing raw text other than making it harder to read. To fix that, you could format the URL like this instead:
In both instances above, the rendered output would be identical:
In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole, filled with the ends of worms and an oozy smell, nor yet a dry, bare, sandy hole with nothing in it to sit down on or to eat: it was a hobbit-hole, and that means comfort.
and the HTML for the link would be:
Link Best Practices
Markdown applications don’t agree on how to handle spaces in the middle of a URL. For compatibility, try to URL encode any spaces with %20
.
✅ Do this | ❌ Don't do this |
---|---|
[link](https://www.example.com/my%20great%20page) | [link](https://www.example.com/my great page) |
Images
To add an image, add an exclamation mark (!
), followed by alt text in brackets, and the path or URL to the image asset in parentheses. You can optionally add a title after the URL in the parentheses.
The rendered output looks like this:
Linking Images
To add a link to an image, enclose the Markdown for the image in brackets, and then add the link in parentheses.
The rendered output looks like this:
Escaping Characters
To display a literal character that would otherwise be used to format text in a Markdown document, add a backslash () in front of the character.
The rendered output looks like this:
* Without the backslash, this would be a bullet in an unordered list.
Characters You Can Escape
You can use a backslash to escape the following characters.
Character | Name |
---|---|
backslash | |
` | backtick (see also escaping backticks in code) |
* | asterisk |
_ | underscore |
{ } | curly braces |
[ ] | brackets |
< > | angle brackets |
( ) | parentheses |
# | pound sign |
+ | plus sign |
- | minus sign (hyphen) |
. | dot |
! | exclamation mark |
| | pipe (see also escaping pipe in tables) |
HTML
Many Markdown applications allow you to use HTML tags in Markdown-formatted text. This is helpful if you prefer certain HTML tags to Markdown syntax. For example, some people find it easier to use HTML tags for images. Using HTML is also helpful when you need to change the attributes of an element, like specifying the color of text or changing the width of an image.
To use HTML, place the tags in the text of your Markdown-formatted file.
The rendered output looks like this:
This word is bold. This word is italic.
HTML Best Practices
For security reasons, not all Markdown applications support HTML in Markdown documents. When in doubt, check your Markdown application’s documentation. Some applications support only a subset of HTML tags.
Use blank lines to separate block-level HTML elements like <div>
, <table>
, <pre>
, and <p>
from the surrounding content. Try not to indent the tags with tabs or spaces — that can interfere with the formatting.
You can’t use Markdown syntax inside block-level HTML tags. For example, <p>italic and **bold**</p>
won’t work.
Take your Markdown skills to the next level.
Learn Markdown in 60 pages. Designed for both novices and experts, The Markdown Guide book is a comprehensive reference that has everything you need to get started and master Markdown syntax.
Get the BookWant to learn more Markdown?
Don't stop now! 😎 Star the GitHub repository and then enter your email address below to receive new Markdown tutorials via email. No spam!
Syntax
Metadata
It is possible to include special metadata at the top of a MultiMarkdowndocument, such as title, author, etc. This information can then be used tocontrol how MultiMarkdown processes the document, or can be used in certainoutput formats in special ways. For example:
The syntax for including metadata is simple.
The metadata must begin at the very top of the document - no blank lines can precede it. There can optionally be a
---
on the line before and after the metadata. The line after the metadata can also be...
. This is to provide better compatibility with YAML, though MultiMarkdown doesn’t support all YAML metadata.Metadata consists of the two parts - the
key
and thevalue
The metadata key must begin at the beginning of the line. It must start with an ASCII letter or a number, then the following characters can consist of ASCII letters, numbers, spaces, hyphens, or underscore characters.
The end of the metadata key is specified with a colon (‘:’)
After the colon comes the metadata value, which can consist of pretty much any characters (including new lines). To keep multiline metadata values from being confused with additional metadata, I recommend indenting each new line of metadata. If your metadata value includes a colon, it must be indented to keep it from being treated as a new key-value pair.
While not required, I recommend using two spaces at the end of each line of metadata. This will improve the appearance of the metadata section if your document is processed by Markdown instead of MultiMarkdown.
Metadata keys are case insensitive and stripped of all spaces during processing. This means that
Base Header Level
,base headerlevel
, andbaseheaderlevel
are all the same.Metadata is processed as plain text, so it should not include MultiMarkdown markup. It is possible to create customized XSLT files that apply certain processing to the metadata value, but this is not the default behavior.
After the metadata is finished, a blank line triggers the beginning of the rest of the document.
Metadata “Variables”
You can substitute the value
for a metadata key
in the body of a document using the following format, where foo
and bar
are the key
s of the desired metadata.
“Standard” Metadata keys
Multimarkdown Syntax
There are a few metadata keys that are standardized in MultiMarkdown. You canuse any other keys that you desire, but you have to make use of them yourself.
My goal is to keep the list of “standard” metadata keys as short as possible.
Author
This value represents the author of the document and is used in LaTeX, ODF, and RTFdocuments to generate the title information.
Affiliation
This is used to enter further information about the author — a link to awebsite, the name of an employer, academic affiliation, etc.
Base Header Level
This is used to change the top level of organization of the document. For example:
Normally, the Introduction would be output as <h1>
in HTML, or part{}
inLaTeX. If you’re writing a shorter document, you may wish for the largestdivision in the document to be <h2>
or chapter{}
. The Base Header Level
metadata tells MultiMarkdown to change the largest division level to thespecified value.
This can also be useful when combining multiple documents.
Base Header Level
does not trigger a complete document.
Additionally, there are “flavors” of this metadata key for various outputformats so that you can specify a different header level for different outputformats — e.g. LaTeX Header Level
, HTML Header Level
, and ODF HeaderLevel
.
If you are doing something interesting with File Transclusion, you can also use anegative number here. Since metadata is not used when a file is “transcluded”,this allows you to use a different level of headings when a file is processed onits own.
Biblio Style
This metadata specifies the name of the BibTeX style to be used, if you arenot using natbib.
BibTeX
This metadata specifies the name of the BibTeX file used to store citationinformation. Do not include the trailing ‘.bib’.
Copyright
This can be used to provide a copyright string.
CSS
This metadata specifies a URL to be used as a CSS file for the produceddocument. Obviously, this is only useful when outputting to HTML.
Date
Specify a date to be associated with the document.
HTML Header
You can include raw HTML information to be included in the header.MultiMarkdown doesn’t perform any validation on this data — it just copiesit as is.
As an example, this can be useful to link your document to a working MathJaxinstallation (not provided by me):
Quotes Language
This is used to specify which style of “smart” quotes to use in the output document. The available options are:
- dutch (or
nl
) - english
- french (
fr
) - german (
de
) - germanguillemets
- swedish (
sv
)
The default is english
if not specified. This affects HTML output. Tochange the language of a document in LaTeX is up to the individual.
Quotes Language
does not trigger a complete document.
LaTeX Author
Since MultiMarkdown syntax is not processed inside of metadata, you can use the latex author
metadata to override the regular author metadata when exporting to LaTeX.
This metadata must come after the regular author
metadata if it is also being used.
LaTeX Footer
A special case of the LaTeX Input
metadata below. This file will be linkedto at the very end of the document.
LaTeX Input
When outputting a LaTeX document it is necessary to include various directionsthat specify how the document should be formatted. These are not included inthe MultiMarkdown document itself — instead they should be stored separatelyand linked to with input{file}
commands.
These links can be included in the metadata section. The metadata is processedin order, so I generally break my directives into a group that need to gobefore my metadata, a group that goes after the metadata but before thedocument itself, and a separate group that goes at the end of the document,for example:
You can download the LaTeX Support Files if you want to output documentsusing the default MultiMarkdown styles. You can then use these as examples tocreate your own customized LaTeX output.
This function should allow you to do almost anything you could do using theXSLT features from MultiMarkdown 2.0. More importantly, it means that advancedLaTeX users do not have to learn XSLT to customize their code as desired.
LaTeX Mode
When outputting a document to LaTeX, there are two special options that changethe output slightly — memoir
and beamer
. These options are designed tobe compatible with the LaTeX classes of the same names.
LaTeX Title
Since MultiMarkdown syntax is not processed inside of metadata, you can use the latex title
metadata to override the regular title metadata when exporting to LaTeX.
This metadata must come after the regular title
metadata if it is also being used.
MMD Footer
The MMD Footer
metadata is used to specify the name of a file that should be appended to the end of the document using the File Transclusion feature. This is useful for keeping a list of references, abbreviations, footnotes, links, etc. all in a single file that can be reused across multiple documents. If you’re building a big document out of smaller documents, this allows you to use one list in all files, without multiple copies being inserted in the master file.
ODF Header
You can include raw XML to be included in the header of a file output inOpenDocument format. It’s up to you to properly format your XML and get itworking — MultiMarkdown just copies it verbatim to the output.
Title
Self-explanatory.
Transclude Base
When using the File Transclusion feature to “link” to other documents inside a MultiMarkdown document, this metadata specifies a folder that contains the files being linked to. If omitted, the default is the folder containing the file in question. This can be a relative path or a complete path.
This metadata can be particularly useful when using MultiMarkdown to parse a text string that does not exist as a file on the computer, and therefore does not have a parent folder (when using stdin
or another application that offers MultiMarkdown support). In this case, the path must be a complete path.
Smart Typography
MultiMarkdown incorporates John Gruber’s SmartyPants tool in addition to the core Markdown functionality. This program converts “plain” punctuation into “smarter” typographic punctuation.
Just like the original, MultiMarkdown converts:
- Straight quotes (
'
and'
) into “curly” quotes - Backticks-style quotes (
``this'
) into “curly” quotes - Dashes (
--
and---
) into en- and em- dashes - Three dots (
...
) become an ellipsis
MultiMarkdown also includes support for quotes styles other than English (the default). Use the quotes language
metadata to choose:
- dutch (
nl
) - german(
de
) - germanguillemets
- french(
fr
) - swedish(
sv
)
This feature is enabled by default, but is disabled in compatibility
mode, since it is not part of the original Markdown. You can also use the smart
and nosmart
command line options to control this feature.
Cross-References
An oft-requested feature was the ability to have Markdown automatically handlewithin-document links as easily as it handled external links. To this aim, Iadded the ability to interpret [Some Text][]
as a cross-link, if a headernamed “Some Text” exists.
As an example, [Metadata][]
will take you to thesection describing metadata.
Alternatively, you can include an optional label of your choosing to helpdisambiguate cases where multiple headers have the same title:
This allows you to use [MultiMarkdownOverview]
to refer to this sectionspecifically, and not another section named Overview
. This works with atx-or settext-style headers.
If you have already defined an anchor using the same id that is used by aheader, then the defined anchor takes precedence.
In addition to headers within the document, you can provide labels for imagesand tables which can then be used for cross-references as well.
Link and Image Attributes
Adding attributes to links and images has been requested for a long time onthe Markdown discussion list. I was fairly opposed to this, as most of theproposals really disrupted the readability of the syntax. I consider myself a“Markdown purist”, meaning that I took John’s introduction to heart:
The overriding design goal for Markdown’s formatting syntax is to makeit as readable as possible. The idea is that a Markdown-formatteddocument should be publishable as-is, as plain text, without lookinglike it’s been marked up with tags or formatting instructions. WhileMarkdown’s syntax has been influenced by several existing text-to-HTMLfilters, the single biggest source of inspiration for Markdown’ssyntax is the format of plain text email.
Because there was not a syntax proposal that I felt fit this goal, I was generally opposed to the idea.
Then, Choan C. Gálvez proposed a brilliantly simple syntax thatstayed out of the way. By simply appending the attributes to the linkreference information, which is already removed from the text itself, itdoesn’t disturb the readability.
For example:
This will generate width and height attributes for the image, and a borderaround the link. And while it can be argued that it does look “like it’s beenmarked up with tags [and] formatting instructions”, even I can’t argue toostrongly against it. The link and the title in quotes already look like someform of markup, and the the additional tags are hardly that intrusive, andthey offer a great deal of functionality. They might even be useful in furtherfunctions (citations?).
The attributes must continue after the other link/image data, and may containnewlines, but must start at the beginning of the line. The format isattribute=value
or attribute='multi word value'
. Currently, MultiMarkdowndoes not attempt to interpret or make any use of any of these attributes.Also, you can’t have a multiword attribute span a newline.
Images
The basic syntax for images in Markdown is:
In addition to the attributes you can use with links and images (described in the previous section), MultiMarkdown also adds a few additional things. If an image is the only thing in a paragraph, it is treated as a block level element:
The resulting HTML is:
The first one would be an inline image. The second one (in HTML) would be wrapped in an HTMLfigure
element. In this case, the alt
text is also used as a figure caption, and can contain MultiMarkdown syntax (e.g. bold, emph, etc.). The alt text is not specifically designed to limit which MultiMarkdown is supported, but there will be limits and block level elements aren’t supported.
Tables
Table Basics
MultiMarkdown has a special syntax for creating tables. It is generally compatible with the syntax used by Michael Fortin for PHP Markdown Extra
Basically, it allows you to turn:
into the following table.
Grouping | ||
---|---|---|
First Header | Second Header | Third Header |
Content | Long Cell | |
Content | Cell | Cell |
New section | More | Data |
And more | With an escaped ‘|’ |
Table Rules
The requirements are:
- There must be at least one
|
per line - The “separator” line between headers and table content must contain only
|
,-
,=
,:
,.
,+
, or spaces - Cell content must be on one line only
- Columns are separated by
|
- The first line of the table, and the alignment/divider line, must start atthe beginning of the line
Other notes:
It is optional whether you have
|
characters at the beginning and end of lines.The “separator” line uses
----
or to indicate the line between a header and cell. The length of the line doesn’t matter, but must have at least one character per cell.To set alignment, you can use a colon to designate left or right alignment, or a colon at each end to designate center alignment, as above. If no colon is present, the default alignment of your system is selected (left in most cases). If the separator line ends with
+
, then cells in that column will be wrapped when exporting to LaTeX if they are long enough.To indicate that a cell should span multiple columns, then simply add additional pipes (
|
) at the end of the cell, as shown in the example. If the cell in question is at the end of the row, then of course that means that pipes are not optional at the end of that row…. The number of pipes equals the number of columns the cell should span.You can use normal Markdown markup within the table cells.
Captions are optional, but if present must be at the beginning of the line immediately preceding or following the table, start with
[
, and end with]
. If you have a caption before and after the table, only the first match will be used.If you have a caption, you can also have a label, allowing you to create anchors pointing to the table. If there is no label, then the caption acts as the label
Cells can be empty.
You can create multiple
<tbody>
tags (for HTML) within a table by having a single empty line between rows of the table. This allows your CSS to place horizontal borders to emphasize different sections of the table. This feature doesn’t work in all output formats (e.g. RTF and OpenDocument).
Limitations of Tables
MultiMarkdown table support is designed to handle most tables for most people; it doesn’t cover all tables for all people. If you need complex tables you will need to create them by hand or with a tool specifically designed for your output format. At some point, however, you should consider whether a table is really the best approach if you find MultiMarkdown tables too limiting.
Native RTF support for tables is very limited. If you need more complex tables, I recommend using the OpenDocument format, and then using LibreOffice to convert your document to RTF.
Footnotes
I have added support for footnotes to MultiMarkdown, using the syntax proposedby John Gruber. Note that there is no official support for footnotes yet, sothe output format may change, but the input format sounds fairly stable.
To create a footnote, enter something like the following:
The footnote itself must be at the start of a line, just like links byreference. If you want a footnote to have multiple paragraphs, lists, etc.,then the subsequent paragraphs need an extra tab preceding them. You may haveto experiment to get this just right, and please let me know of any issues youfind.
This is what the final result looks like:
Here is some text containing a footnote.[1]
You can also use “inline footnotes”:
Citations
I have included support for basic bibliography features in this version ofMultiMarkdown. Please give me feedback on ways to improve this but keep thefollowing in mind:
Bibliography support in MultiMarkdown is rudimentary. The goal is to offera basic standalone feature, that can be changed using the tool of your choiceto a more robust format (e.g. BibTeX, CiteProc). My XSLT files demonstrate howto make this format compatible with BibTeX, but I am not planning onpersonally providing compatibility with other tools. Feel free to post yourideas and tools to the wiki.
Those needing more detailed function sets for their bibliographies may needcustomized tools to provide those services. This is a basic tool that shouldwork for most people. Reference librarians will probably not be satisfiedhowever.
To use citations in MultiMarkdown, you use a syntax much like that foranchors:
In HTML output, citations are indistinguishable from footnotes.
You are not required to use a locator (e.g. p. 23), and there areno special rules on what can be used as a locator if you chooseto use one. If you prefer to omit the locator, just use an emptyset of square brackets before the citation:
There are no rules on the citation key format that you use (e.g. Doe:2006
),but it must be preceded by a #
, just like footnotes use ^
.
As for the reference description, you can use Markup code within this section,and I recommend leaving a blank line afterwards to prevent concatenation ofseveral references. Note that there is no way to reformat these references indifferent bibliography styles; for this you need a program designed for thatpurpose (e.g. BibTeX).
If you want to include a source in your bibliography that was not cited, youmay use the following:
The Not cited
bit is not case sensitive.
If you are creating a LaTeX document, the citations will be included, andnatbib will be used by default. If you are not using BibTeX and are gettingerrors about your citations not being compatible with ‘Author-Year’, you canadd the following to your documents metadata:
This changes the citation style in natbib to avoid these errors, and is usefulwhen you include your citations in the MultiMarkdown document itself.
BibTeX
If you are creating a LaTeX document, and need a bibliography, then you shoulddefinitely look into BibTeX andnatbib. It is beyond the scope ofthis document to describe how these two packages work, but it is possible tocombine them with MultiMarkdown.
To use BibTeX in a MultiMarkdown document, you need to use the BibTeX
metadata to specify where your citations are stored.
Since natbib
is enabled by default, you have a choice between using thecitep
and citet
commands. The following shows how this relates to theMultiMarkdown syntax used.
Definition Lists
MultiMarkdown has support for definition lists using the same syntax used inPHP Markdown Extra. Specifically:
becomes:
- Apple
- Pomaceous fruit of plants of the genus Malus in the family Rosaceae.
- An american computer company.
- Orange
- The fruit of an evergreen tree of the genus Citrus.
You can have more than one term per definition by placing each term on aseparate line. Each definition starts with a colon, and you can have more thanone definition per term. You may optionally have a blank line between the lastterm and the first definition.
Definitions may contain other block level elements, such as lists,blockquotes, or other definition lists.
Unlike PHP Markdown Extra, all definitions are wrapped in <p>
tags. First, Iwas unable to get Markdown not to create paragraphs. Second, I didn’t seewhere it mattered - the only difference seems to be aesthetic, and I actuallyprefer the <p>
tags in place. Let me know if this is a problem.
See the PHP Markdown Extra page for more information.
Abbreviations
MultiMarkdown includes support for abbreviations, as implemented in Michel Fortin’s PHP Markdown Extra. Basically, you define an abbreviation using the following syntax:
Then, wherever you use the words HTML
or W3C
in your document, the abbr
markup will be added:
becomes:
Here’s an example using HTML and W3C. The exact behavior will depend on which format you are viewing this document in. Especially if we use HTML and W3C again. (Remember that HTML has probably already been used if you’re viewing a longer version of this document.)
As in PHP Markdown Extra, abbreviations are case-sensitive and will work on multiple word abbreviations. In this case, MultiMarkdown is tolerant of different variations of whitespace between words.
An abbreviation with an empty definition results in an omitted title
attribute.
There are a few limitations:
- The full name of the abbreviation is plain text only – no MultiMarkdown markup will be processed.
- Abbreviations don’t do anything when exporting to ODF – there’s not an equivalent structure there – it would have to be hand coded. I may or may not get around to this, but pull requests welcome. ;)
- When exporting to LaTeX, the
acronym
package is used; this means that the first usage will result infull text (short)
, and subsequent uses will result inshort
.
Fenced Code Blocks
In addition to the regular indented code block that Markdown uses, you can use “fenced” code blocks in MultiMarkdown. These code blocks do not have to be indented, and can also be configured to be compatible with a third party syntax highlighter. These code blocks should begin with 3 to 5 backticks, an optional language specifier (if using a syntax highlighter), and should end with the same number of backticks you started with:
I don’t recommend any specific syntax highlighter, but have used the following metadata to set things up. It may or may not work for you:
Fenced code blocks are particularly useful when including another file (File Transclusion), and you want to show the source of the file, not what the file looks like when processed by MultiMarkdown.
Math
MultiMarkdown 2.0 used ASCIIMathML to typeset mathematical equations. Therewere benefits to using ASCIIMathML, but also some disadvantages.
When rewriting for MultiMarkdown 3.0, there was no straightforward way toimplement ASCIIMathML which lead me to look for alternatives. I settled onusing MathJax. The advantage here is that the same syntax is supported byMathJax in browsers, and in LaTeX.
This does mean that math will need to be entered into MultiMarkdown documentsusing the LaTeX syntax, rather than ASCIIMathML.
To enable MathJax support in web pages, you have to include a link to anactive MathJax installation — setting this up is beyond the scope of thisdocument, but it’s not too hard.
Here’s an example of the metadata setup, and some math:
Here’s what it looks like in action (if you’re viewing this document in asupported format):
An example of math within a paragraph — ({e}^{ipi }+1=0)— easy enough.
And an equation on it’s own:
[ {x}_{1,2}=frac{-bpm sqrt{{b}^{2}-4ac}}{2a} ]
That’s it.
In addition to the [ ]
and ( )
syntax, you can use LaTeX style “dollar sign” delimiters:
In order to be correctly parsed as math, there must not be any space between the $
and the actual math on the inside of the delimiter, and there must be space on the outside.
Superscripts and Subscripts
You can easily include superscripts and subscripts in MultiMarkdown as well:
becomes
This apartment has an area of 100m2
One must consider the value of xz
The subscript must not contain any whitespace or punctuation.
More complicated exponents and subscripts can be delimited like this:
y(a+b)
xy,z
Glossaries
MultiMarkdown has a feature that allows footnotes to be specified as glossaryterms. It doesn’t do much for XHTML documents, but the XSLT file that convertsthe document into LaTeX is designed to convert these special footnotes intoglossary entries.
The glossary format for the footnotes is:
The term
is the item that belongs in the glossary. The sort key
isoptional, and is used to specify that the term should appear somewhere else inthe glossary (which is sorted in alphabetical order).
Unfortunately, it takes an extra step to generate the glossary when creating apdf from a latex file:
You need to have the
basic.gst
file installed, which comes with thememoir class.You need to run a special makeindex command to generate the
.glo
file:makeindex -s `kpsewhich basic.gst` -o 'filename.gls' 'filename.glo'
Then you run the usual pdflatex command again a few times.
Alternatively, you can use the code below to create an engine file for TeXShop(it belongs in ~/Library/TeXShop/Engines
). You can name it something likeMemoirGlossary.engine
. Then, when processing a file that needs a glossary,you typeset your document once with this engine, and then continue to processit normally with the usual LaTeX engine. Your glossary should be compiledappropriately. If you use TeXShop, this is the way to go.
Note: Getting glossaries to work is a slightly more advanced LaTeXfeature, and might take some trial and error the first few times.
CriticMarkup
What Is CriticMarkup?
CriticMarkup is a way for authors and editors to track changes to documents in plain text. As with Markdown, small groups of distinctive characters allow you to highlight insertions, deletions, substitutions and comments, all without the overhead of heavy, proprietary office suites. http://criticmarkup.com/
CriticMarkup is integrated with MultiMarkdown itself, as well as MultiMarkdown Composer. I encourage you to check out the web site to learn more as it can be a very useful tool. There is also a great video showing CriticMarkup in use while editing a document in MultiMarkdown Composer.
The CriticMarkup Syntax
The CriticMarkup syntax is fairly straightforward. The key thing to remember is that CriticMarkup is processed before any other MultiMarkdown is handled. It’s almost like a separate layer on top of the MultiMarkdown syntax.
When editing in MultiMarkdown Composer, you can have CriticMarkup syntax flagged in the both the editor pane and the preview window. This will allow you to see changes in the HTML preview.
When using CriticMarkup with MultiMarkdown itself, you have four choices:
- Leave the CriticMarkup syntax in place (
multimarkdown foo.txt
) - Accept all changes, giving you the “new” document (
multimarkdown -a foo.txt
) - Reject all changes, giving you the “original” document (
multimarkdown -r foo.txt
) - Attempt to show the changes as highlights. This only works in HTML, and to use it you ask for the new and original document at the same time (
multimarkdown -a -r foo.txt
)
CriticMarkup comments and highlighting are ignored when processing.
Deletions from the original text:
Additions:
Substitutions:
Highlighting:
Comments:
My philosophy on CriticMarkup
I view CriticMarkup as two things:
A syntax for documenting editing notes and changes, and for collaborating amongst coauthors.
A means to display those notes/changes in the HTML output.
I believe that #1 is a really great idea, and well implemented. #2 is not so well implemented, largely due to the “orthogonal” nature of CriticMarkup and the underlying Markdown syntax.
CM is designed as a separate layer on top of Markdown/MultiMarkdown. This means that a Markdown span could, for example, start in the middle of a CriticMarkup structure, but end outside of it. This means that an algorithm to properly convert a CM/Markdown document to HTML would be quite complex, with a huge number of edge cases to consider. I’ve tried a few (fairly creative, in my opinion) approaches, but they didn’t work. Perhaps someone else will come up with a better solution, or will be so interested that they put the work in to create the complex algorithm. I have no current plans to do so.
Additionally, there is a philosophical distinction between documenting editing notes, and using those notes to produce a “finished” document (e.g. HTML or PDF) that keeps those editing notes intact (e.g. strikethroughs, highlighting, etc.) I believe that CM is incredibly useful for the editing process, but am less convinced for the output process (I know many others disagree with me, and that’s ok. And to be clear, I think that what Gabe and Erik have done with CriticMarkup is fantastic!)
There are other CriticMarkup tools besides MultiMarkdown and MultiMarkdown Composer, and you are more than welcome to use them.
For now, the official MultiMarkdown support for CriticMarkup consists of:
- CriticMarkup syntax is “understood” by the MultiMarkdown parser, and by MultiMarkdown Composer syntax highlighting.
- When converting from MultiMarkdown text to an output format, you can ignore CM formatting (probably not what you want to do), accept all changes, or reject all changes (as above). These are the preferred choices.
- The secondary to choice, when exporting to HTML, is to attempt to show the changes in the HTML output. Because the syntaxes are orthogonal, this will not always work properly, and will not always give valid HTML output.
Raw HTML
You can include raw (X)HTML within your document. Exactly what happens withthese portions depends on the output format. You can also use the markdown
attribute to indicate that MultiMarkdown processing should be applied withinthe block level HTML tag. This is in addition to the --process-html
commandline option that causes MultiMarkdown processing to occur within all blocklevel HTML tags.
For example:
will produce the following without --process-html
:
and with --process-html
:
However, the results may be different than anticipated when outputting toLaTeX or other formats. Normally, block level HTML will be ignored whenoutputting to LaTeX or ODF. The example above would produce the following,leaving out the first <div>
entirely:
And this with --process-html
:
You will also notice that the line breaks are different when outputting toLaTeX or ODF, and this can cause the contents of two <div>
tags to be placedinto a single paragraph.
Raw LaTeX/OpenDocument/etc.
You can use HTML comments to include additional text that will be included in the exported file without being changed. This can be used for any export format, which means that each document can only be configured for one export format at a time. In other words, it is highly unlikely that valid raw LaTeX will also be valid OpenDocument source code.
File Transclusion
File transclusion is the ability to tell MultiMarkdown to insert the contents of another file inside the current file being processed. For example:
If a file named some_other_file.txt
exists, its contents will be inserted inside of this document before being processed by MultiMarkdown. This means that the contents of the file can also contain MultiMarkdown formatted text.
If you want to display the contents of the file without processing it, you can include it in a code block (you may need to remove trailing newlines at the end of the document to be included):
Transclusion is recursive, so the file being inserted will be scanned to see if it references any other files.
Metadata in the file being inserted will be ignored. This means that the file can contain certain metadata when viewed alone that will not be included when the file is transcluded by another file.
You can use the [Transclude Base]
metadata to specify where MultiMarkdown should look for the files to be included. All files must be in this folder. If this folder is not specified, then MultiMarkdown will look in the same folder as the parent file.
Note: Thanks to David Richards for his ideas in developing support for this feature.
Wildcard Extensions
Sometimes you may wish to transclude alternate versions of a file depending on your output format. Simply use the extension “.*” to have MMD choose the proper version of the file (e.g. foo.tex
, foo.fodt
, foo.html
, etc.)
Transclusion Preprocessing
If you want to perform transclusion, without converting to another format, you can use mmd
as the output format:
This will only perform “basic” transclusion –it does not support wildcard extensions, since the final output format is not known.
Escaped newlines
Thanks to a contribution from Nicolas, MultiMarkdown has an additional syntax to indicate a line break. The usual approach for Markdown is “space-space-newline” — two spaces at the end of the line. For some users, this causes problems:
- the trailing spaces are typically invisible when glancing at the source, making it easy to overlook them
- some users’ text editors modify trailing space (IMHO, the proper fix for this is a new text editor…)
Nicolas submitted a patch that enables a new option that interprets “” before a newline as a marker that a line break should be used:
To enable this feature, use the following option:
Multimarkdown Syntax
If this option is not enabled, then the default behavior will be to treat the newline as an escaped character, which results in it simply appearing as a newline character in the output. This means that the default behavior is the same as if the “” is not in the source file.
Comments are closed.