If you like kramdown and would like to support it, you are welcome to make a smalldonation (Patreon or PayPal) -- it will surely be appreciated! Thanks!
GROSSWEBER providessoftwaredevelopment consulting and training services.We like to work on open source. We use it heavily.We love kramdown!
This is version2.5.1 of the syntax documentation.
The kramdown syntax is based on the Markdown syntax and has been enhanced with features that arefound in other Markdown implementations likeMaruku,PHP Markdown Extra andPandoc. However,it strives to provide a strict syntax with definite rules and therefore isn’t completely compatiblewith Markdown. Nonetheless, most Markdown documents should work fine when parsed with kramdown. Allplaces where the kramdown syntax differs from the Markdown syntax are highlighted.
Following is the complete syntax definition for all elements kramdown supports. Together with thedocumentation on the available converters, it is clearly specified what you will get when a kramdowndocument is converted.
A kramdown document may be in any encoding, for example ASCII, UTF-8 or ISO-8859-1, and the outputwill have the same encoding as the source.
The document consists of two types of elements, block-level elements and span-level elements:
Block-level elements define the main structure of the content, for example, what part of the textshould be a paragraph, a list, a blockquote and so on.
Span-level elements mark up small text parts as, for example, emphasized text or a link.
Thus span-level elements can only occur inside block-level elements or other span-level elements.
You will often find references to the “first column” or “first character” of a line in a block-levelelement descriptions. Such a reference is always to be taken relative to the current indentationlevel because some block-level elements open up a new indentation level (e.g. blockquotes). Thebeginning of a kramdown document opens up the default indentation level which begins at the firstcolumn of the text.
Some lightweight markup syntax don’t work well in environments where lines are hard-wrapped. Forexample, this is the case with many email programs. Therefore kramdown allows content likeparagraphs or blockquotes to be hard-wrapped, i.e. broken across lines. This is sometimes referredto as “lazy syntax” since the indentation or line prefix required for the first line of content isnot required for the consecutive lines.
Block-level elements that support line wrapping always end when one of the following conditions ismet:
ablank line, anEOB marker line, ablock IAL or theend of the document (i.e. ablock boundary),
or anHTML block.
Line wrapping is allowed throughout a kramdown document but there are some block-level elements thatdonot support being hard-wrapped:
This is not an issue in most situations since headers normally fit on one line. If a header textgets too long for one line, you need to use HTML syntax instead.
The delimiting lines of a fenced code block do not support hard-wrapping. Since everything betweenthe delimiting lines is taken as is, the content of a fenced code block does also not supporthard-wrapping.
Each definition term has to appear on a separate line. Hard-wrapping would therefore introduceadditional definition terms. The definitions themselves, however, do support hard-wrapping.
Since each line of a kramdown table describes one table row or a separator, it is not possible tohard-wrap tables.
Note that it isNOT recommended to use lazy syntax to write a kramdown document. Theflexibility that the kramdown syntax offers due to the issue of line wrapping hinders readabilityand should therefore not be used.
kramdown assumes that tab stops are set at multiples of four. This is especially important whenusing tabs for indentation in lists. Also, tabs may only be used at the beginning of a line whenindenting text and must not be preceded by spaces. Otherwise the results may be unexpected.
Depending on the output format, there are often characters that need special treatment. For example,when converting a kramdown document to HTML one needs to take care of the characters<
,>
and&
. To ease working with these special characters, they are automatically and correctly escapeddepending on the output format.
This means, for example, that you can just use<
,>
and&
in a kramdown document and need notthink about when to use their HTML entity counterparts. However, if youdo use HTML entities orHTML tags which use one of the characters, the result will be correct nonetheless!
Since kramdown also uses some characters to mark-up the text, there needs to be a way to escapethese special characters so that they can have their normal meaning. This can be done by usingbackslash escapes. For example, you can use a literal back tick like this:
This \`is not a code\` span!
Following is a list of all the characters (character sequences) that can be escaped:
\ backslash. period* asterisk_ underscore+ plus- minus= equal sign` back tick()[]{}<> left and right parens/brackets/braces/angle brackets# hash! bang<< left guillemet>> right guillemet: colon| pipe" double quote' single quote$ dollar sign
Some block-level elements have to start and/or end on so called block boundaries, as stated in theirdocumentation. There are two cases where block boundaries come into play:
If a block-level element has to start on a block boundary, it has to be preceded by either ablank line, anEOB marker, ablock IAL or it has tobe the first element.
If a block-level element has to end on a block boundary, it has to be followed by either ablankline, anEOB marker, ablock IAL or it has to be thelast element.
All structural elements are block-level elements and they are used to structure the content. Theycan mark up some text as, for example, a simple paragraph, a quote or as a list item.
Any line that just contains white space characters such as spaces and tabs is considered a blankline by kramdown. One or more consecutive blank lines are handled as one empty blank line. Blanklines are used to separate block-level elements from each other and in this case they don’t havesemantic meaning. However, there are some cases where blank lines do have a semantic meaning:
Paragraphs are the most used block-level elements. One or more consecutive lines of text areinterpreted as one paragraph. The first line of a paragraph may be indented up to three spaces, theother lines can have any amount of indentation because paragraphs supportlinewrapping. In addition to the rules outlined in the section about line wrapping, aparagraph ends when adefinition list line is encountered.
You can separate two consecutive paragraphs from each other by using one or more blank lines. Noticethat a line break in the source does not mean a line break in the output (due to thelazysyntax)!. If you want to have an explicit line break (i.e. a<br />
tag) you needto end a line with two or more spaces or two backslashes! Note, however, that a line break on thelast text line of a paragraph is not possible and will be ignored. Leading and trailing spaces willbe stripped from the paragraph text.
The following gives you an example of how paragraphs look like:
This⋅para⋅line⋅starts⋅at⋅the⋅first⋅column.⋅However,⋅⋅⋅⋅⋅⋅the⋅following⋅lines⋅can⋅be⋅indented⋅any⋅number⋅of⋅spaces/tabs.⋅⋅⋅The⋅para⋅continues⋅here.⋅⋅This⋅is⋅another⋅paragraph,⋅not⋅connected⋅to⋅the⋅above⋅one.⋅But⋅⋅with⋅a⋅hard⋅line⋅break.⋅\\And⋅another⋅one.
kramdown supports so called Setext style and atx style headers. Both forms can be used inside asingle document.
Setext style headers have to start on ablock boundary with a line of text (theheader text) and a line with only equal signs (for a first level header) or dashes (for a secondlevel header). The header text may be indented up to three spaces but any leading or trailing spacesare stripped from the header text. The amount of equal signs or dashes is not significant, just oneis enough but more may look better. The equal signs or dashes have to begin at the first column. Forexample:
First level header==================Second level header------ Other first level header=
Since Setext headers start on block boundaries, this means in most situations that they have to bepreceded by a blank line. However, blank lines are not necessary after a Setext header:
This is a normalparagraph.And A Header------------And a paragraph> This is a blockquote.And A Header------------
However, it is generally a good idea to also use a blank line after a Setext header because it looksmore appropriate and eases reading of the document.
The original Markdown syntax allows one to omit the blank line before a Setext header. However,this leads to ambiguities and makes reading the document harder than necessary. Therefore it isnot allowed in a kramdown document.
An edge case worth mentioning is the following:
header---para
One might ask if this represents two paragraphs separated by ahorizontal ruleor a second level header and a paragraph. As suggested by the wording in the example, the latter isthe case. The general rule is that Setext headers are processed before horizontal rules.
atx style headers have to start on ablock boundary with a line that containsone or more hash characters and then the header text. No spaces are allowed before the hashcharacters. The number of hash characters specifies the heading level: one hash character gives youa first level heading, two a second level heading and so on until the maximum of six hash charactersfor a sixth level heading. You may optionally use any number of hashes at the end of the line toclose the header. Any leading or trailing spaces are stripped from the header text. For example:
# First level header### Third level header ##### Second level header ######
Again, the original Markdown syntax allows one to omit the blank line before an atx style header.
kramdown supports a nice way for explicitly setting the header ID which is taken fromPHP MarkdownExtra andMaruku: If you follow the header text with an opening curly bracket (separated from thetext with a least one space), a hash, the ID and a closing curly bracket, the ID is set on theheader. If you use the trailing hash feature of atx style headers, the header ID has to go after thetrailing hashes. For example:
Hello {#id}-----# Hello {#id}# Hello # {#id}
This additional syntax is not part of standard Markdown.
A blockquote is started using the>
marker followed by an optional space and the content of theblockquote. The marker itself may be indented up to three spaces. All following lines, whether theyare started with the blockquote marker or just contain text, belong to the blockquote becauseblockquotes supportline wrapping.
The contents of a blockquote are block-level elements. This means that if you are just using text ascontent that it will be wrapped in a paragraph. For example, the following gives you one blockquotewith two paragraphs in it:
> This is a blockquote.> on multiple linesthat may be lazy.>> This is the second paragraph.
Since the contents of a blockquote are block-level elements, you can nest blockquotes and use otherblock-level elements (this is also the reason why blockquotes need to support line wrapping):
> This is a paragraph.>> > A nested blockquote.>> ## Headers work>> * lists too>> and all other block-level elements
Note that the first space character after the>
marker doesnot count when counting spaces forthe indentation of the block-level elements inside the blockquote! Socode blockswill have to be indented with five spaces or one space and one tab, like this:
> A code block:>> ruby -e 'puts :works'
Line wrapping allows one to be lazy but hinders readability and should thereforebe avoided, especially with blockquotes. Here is an example of using blockquotes with line wrapping:
> This is a paragraph insidea blockquote.>> > This is a nested paragraphthat continues here> and here> > and here
Code blocks can be used to represent verbatim text like markup, HTML or a program fragment becauseno syntax is parsed within a code block.
A code block can be started by using four spaces or one tab and then the text of the code block. Allfollowing lines containing text, whether they adhere to this syntax or not, belong to the code blockbecause code blocks supportline wrapping). A wrapped code line is automaticallyappended to the preceding code line by substituting the line break with a space character. Theindentation (four spaces or one tab) is stripped from each line of the code block.
The original Markdown syntax does not allow line wrapping in code blocks.
Note that consecutive code blocks that are only separate byblank lines are mergedtogether into one code block:
Here comes some code This text belongs to the same code block.
If you want to have one code block directly after another one, you need to use anEOBmarker to separate the two:
Here comes some code^ This one is separate.
This alternative syntax is not part of the original Markdown syntax. The idea and syntax comesfrom thePHP Markdown Extra package.
kramdown also supports an alternative syntax for code blocks which does not use indented blocks butdelimiting lines. The starting line needs to begin with three or more tilde characters (~
) and theclosing line needs to have at least the number of tildes the starting line has. Everything betweenis taken literally as with the other syntax but there is no need for indenting the text. Forexample:
~~~~~~~~Here comes some code.~~~~~~~~
If you need lines of tildes in such a code block, just start the code block with more tildes. Forexample:
~~~~~~~~~~~~~~~~~~~code with tildes~~~~~~~~~~~~~~~~~~~~~~~~~~
This type of code block is especially useful for copy-pasted code since you don’t need to indent thecode.
You can tell kramdown the language of a code block by using anIAL:
~~~def what? 42end~~~{: .language-ruby}
The specially named classlanguage-ruby
tells kramdown that this code block is written in the Rubylanguage. Such information can be used, for example, by converters to do syntax highlighting on thecode block.
Fenced code blocks provide an easier way to specify the language, namely by appending the languageof the code block to the end of the starting line:
~~~ rubydef what? 42end~~~
kramdown provides syntax elements for creating ordered and unordered lists as well as definitionlists.
Both ordered and unordered lists follow the same rules.
A list is started with a list marker (in case of unordered lists one of+
,-
or*
– you canmix them – and in case of ordered lists a number followed by a period) followed by one tab or atleast one space, optionally followed by anIAL that should be applied tothe list item and then the first part of the content of the list item. The leading tabs or spacesare stripped away from this first line of content to allow for a nice alignment with the followingcontent of a list item (see below). All following list items with the same marker type (unordered orordered) are put into the same list. The numbers used for ordered lists are irrelevant, an orderedlist always starts at 1.
The following gives you an unordered list and an ordered list:
* kram+ down- now1. kram2. down3. now
The original Markdown syntax allows the markers of ordered and unordered lists to be mixed, thefirst marker specifying the list type (ordered or unordered). This is not allowed in kramdown. Asstated, the above example will give you two lists (an unordered and an ordered) in kramdown andonly one unordered list in Markdown.
The first list marker in a list may be indented up to three spaces. The column number of the firstnon-space character which appears after the list item marker on the same line specifies theindentation that has to be used for the following lines of content of the list item. If there is nosuch character, the indentation that needs to be used is four spaces or one tab. Indented lines maybe followed by lines containing text with any amount of indentation due tolinewrapping. Note, however, that in addition to the rules outlined in the sectionabout line wrapping, a list item also ends when a line with another list item marker is encountered– see the next paragraph.
The indentation is stripped from the content and the content (note that the content naturally alsocontains the content of the line with the item marker) is processed as text containing block-levelelements. All other list markers in the list may be indented up to three spaces or the number ofspaces used for the indentation of the last list item minus one, whichever number is smaller. Forexample:
* This is the first line. Since the first non-space characters appears in column 3, all other indented lines have to be indented 2 spaces.However, one could be lazy and not indent a line but this is notrecommended.* This is the another item of the list. It uses a different number of spaces for indentation which is okay but should generally be avoided. * The list item marker is indented 3 spaces which is allowed but should also be avoided and starts the third list item. Note that the lazy line in the second list item may make you believe that this is a sub-list which it isn't! So avoid being lazy!
So, while the above is possible and creates one list with three items, it is not advised to usedifferent (marker and list content) indents for same level list items as well as lazy indentation!It is much better to write such a list in the following way:
* This is the first list item bla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla bla* This is the another item of the list. bla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
The original Markdown syntax also allows you to indent the marker, however, the behaviour of whathappens with the list items is not clearly specified and may surprise you.
Also, Markdown uses a fixed number of spaces/tabs to indent the lines that belong to a list item!
Unordered and ordered lists work the same way in regard to the indentation:
* list 1 item 1 * list 1 item 2 (indent 1 space) * list 1 item 3 (indent 2 spaces) * list 1 item 4 (indent 3 spaces) * lazy text belonging to above item 4
1. list 1 item 1 2. list 1 item 2 (indent 1 space) 3. list 1 item 3 (indent 2 spaces) 4. list 1 item 4 (indent 3 spaces) 5. lazy text belonging to above item 4
* list 1 item 1 * nested list item 1 * nested list item 2* list 1 item 2 * nested list item 1
1. list 1 item 1 1. nested list item 1 2. nested list item 210. list 1 item 2 1. nested list item 1
1. text for this list item further text (indent 3 spaces)10. text for this list item further text (indent 4 spaces)
When using tabs for indenting the content of a list item, remember that tab stops occur at multiplesof four for kramdown. Tabs are correctly converted to spaces for calculating the indentation. Forexample:
* Using a tab to indent this line, the tab only counts as three spaces and therefore the overall indentation is four spaces. 1. The tab after the marker counts here as three spaces. Since the indentation of the marker is three spaces and the marker itself takes two characters, the overall indentation needed for the following lines is eight spaces or two tabs.
It is clear that you might get unexpected results if you mix tabs and spaces or if you don’t havethe tab stops set to multiples of four in your editor! Therefore this should be avoided!
The content of a list item is made up of either text or block-level elements. Simple list items onlycontain text like in the above examples. They are not even wrapped in a paragraph tag. If the firstlist text is followed by one or more blank lines, it will be wrapped in a paragraph tag:
* kram* down* now
In the above example, the first list item text will be wrapped in a paragraph tag since it isfollowed by a blank line whereas the second list item contains just text. There is obviously aproblem for doing this with the last list item when it contains only text. You can circumvent thisby leaving a blank line after the last list item and using an EOB marker:
* Not wrapped in a paragraph* Wrapped in a paragraph due to the following blank line.* Also wrapped in a paragraph due to the following blank line and the EOB marker.^
The text of the last list item is also wrapped in a paragraph tag ifall other list items containa proper paragraph as first element. This makes the following use case work like expected, i.e.all the list items are wrapped in paragraphs:
* First list item* Second list item* Last list item
The original Markdown syntax page specifies that list items which are separated by one or moreblank lines are wrapped in paragraph tags. This means that the first text will also be wrapped ina paragraph if you have block-level elements in a list which are separated by blank lines. Theabove rule is easy to remember and lets you exactly specify when the first list text should bewrapped in a paragraph. The idea for the above rule comes from thePandoc package.
As seen in the examples above, blank lines between list items are allowed.
Since the content of a list item can contain block-level elements, you can do the following:
* First item A second paragraph * nested list > blockquote* Second item
However, there is a problem when you want to have a code block immediately after a list item. Youcan use an EOB marker to circumvent this problem:
* This is a list item. The second para of the list item.^ A code block following the list item.
You can have any block-level element as first element in a list item. However, as described above,the leading tabs or spaces of the line with the list item marker are stripped away. This leads to aproblem when you want to have a code block as first element. The solution to this problem is thefollowing construct:
*⋅⋅⋅⋅⋅⋅⋅⋅⋅This⋅is⋅a⋅code⋅block⋅(indentation⋅needs⋅to⋅be⋅4(1)+4(1)⋅⋅⋅⋅⋅⋅⋅⋅spaces⋅(tabs)).
Note that the list marker needs to be followed with at least one space or tab! Otherwise the line isnot recognized as the start of a list item but interpreted as a paragraph containing the listmarker.
If you want to have one list directly after another one (both with the same list type, i.e. orderedor unordered), you need to use an EOB marker to separate the two:
* List one^* List two
Since paragraphs supportline wrapping, it would usually not be possible to createcompact nested list, i.e. a list where the text is not wrapped in paragraphs because there is noblank line but a sub list after it:
* This is just text. * this is a sub list item * this is a sub sub list item* This is just text, spanning two lines * this is a nested list item.
However, this is an often used syntax and is therefore support by kramdown.
If you want to start a paragraph with something that looks like a list item marker, you need toescape it. This is done by escaping the period in an ordered list or the list item marker in anunordered list:
1984\. It was great\- others say that, too!
As mentioned at the beginning, an optional IAL for applying attributes to a list item can be usedafter the list item marker:
* {:.cls} This item has the class "cls". Here continues the above paragraph.* This is a normal list item.
This syntax feature is not part of the original Markdown syntax. The idea and syntax comes fromthePHP Markdown Extra package.
Definition lists allow you to assign one or more definitions to one or more terms.
A definition list is started when a normal paragraph is followed by a line with a definition marker(a colon which may be optionally indented up to three spaces), then at least one tab or one space,optionally followed by anIAL that should be applied to the list item andthen the first part of the definition. The line with the definition marker may optionally beseparated from the preceding paragraph by a blank line. The leading tabs or spaces are stripped awayfrom this first line of the definition to allow for a nice alignment with the following definitioncontent. Each line of the preceding paragraph is taken to be a term and the lines separately parsedas span-level elements. Each such term may optionally start with anIALthat should be applied to the term.
The following is a simple definition list:
kramdown: A Markdown-superset converterMaruku: Another Markdown-superset converter
The column number of the first non-space character which appears after a definition marker on thesame line specifies the indentation that has to be used for the following lines of the definition.If there is no such character, the indentation that needs to be used is four spaces or one tab.Indented lines may be followed by lines containing text with any amount of indentation due tolinewrapping. Note, however, that in addition to the rules outlined in the sectionabout line wrapping, a list item also ends when a line with another definition marker is encountered.
The indentation is stripped from the definition and it (note that the definition naturally alsocontains the content of the line with the definition marker) is processed as text containing blocklevel elements. If there is more than one definition, all other definition markers for the term maybe indented up to three spaces or the number of spaces used for the indentation of the lastdefinition minus one, whichever number is smaller. For example:
definition term 1definition term 2: This is the first line. Since the first non-space characters appears incolumn 3, all other lines have to be indented 2 spaces (or lazy syntax may be used after an indented line). This tells kramdown that the lines belong to the definition.: This is the another definition for the same term. It uses a different number of spaces for indentation which is okay but should generally be avoided. : The definition marker is indented 3 spaces which is allowed but should also be avoided.
So, while the above is possible and creates a definition list with two terms and three definitionsfor them, it is not advised to use different (definition marker and definition) indents in the samedefinition list as well as lazy indentation!
The definition for a term is made up of text and/or block-level elements. If a definition isnotpreceded by a blank line, the first part of the definition will just be text if it would be aparagraph otherwise:
definition term: This definition will just be text because it would normally be a paragraph and the there is no preceding blank line. > although the definition contains other block-level elements: This definition *will* be a paragraph since it is preceded by a blank line.
The rules about having any block-level element as first element in a list item also apply to adefinition.
As mentioned at the beginning, an optional IAL for applying attributes to a term or a definition canbe used:
{:#term} Term with: {:.cls} Definition with class "cls"{:#term1} First term{:#term2} Second term: {:.cls} Definition
This syntax feature is not part of the original Markdown syntax. The syntax is based on the onefrom thePHP Markdown Extra package.
Sometimes one wants to include simple tabular data in a kramdown document for which using afull-blown HTML table is just too much. kramdown supports this with a simple syntax for ASCIItables.
Tables can be created with or without a leading pipe character: If the first line of a tablecontains a pipe character at the start of the line (optionally indented up to three spaces), thenall leading pipe characters (i.e. pipe characters that are only preceded by whitespace) are ignoredon all table lines. Otherwise they are not ignored and count when dividing a table line into tablecells.
There are four different line types that can be used in a table:
Table rows define the content of a table.
A table row is any line that contains at least one pipe character and is not identified as anyother type of table line! The table row is divided into individual table cells by pipe characters.An optional trailing pipe character is ignored. Note that literal pipe characters need to beescapedexcept if they occur in code spans or HTML<code>
elements!
Header rows, footer rows and normal rows are all done using these table rows. Table cells can onlycontain a single line of text, no multi-line text is supported. The text of a table cell is parsedas span-level elements.
Here are some example table rows:
| First cell|Second cell|Third cell| First | Second | Third |First | Second | | Fourth |
Separator lines are used to split the table body into multiple body parts.
A separator line is any line that contains only pipes, dashes, pluses, colons and spaces/tabs andwhich contains at least one dash and one pipe character. The pipe and plus characters can be usedto visually separate columns although this is not needed. Multiple separator lines after anotherare treated as one separator line.
Here are some example separator lines:
|----+----|+----|----+|---------||-| :-----: |-|-
The first separator line after at least one table row is treated specially, namely asheaderseparator line. It is used to demarcate header rows from normal table rows and/or to set columnalignments. All table rows above the header separator line are considered to be header rows.
The header separator line can be specially formatted to contain column alignment definitions: Analignment definition consists of an optional space/tab followed by an optional colon, one or moredashes, an optional colon and another optional space/tab. The colons of an alignment definitionare used to set the alignment of a column: if there are no colons, the column uses the defaultalignment, if there is a colon only before the dashes, the column is left aligned, if there arecolons before and after the dashes, the column is center aligned and if there is only a colonafter the dashes, the column is right aligned. Each alignment definition sets the alignment forone column, the first alignment definition for the first column, the second alignment definitionfor the second column and so on.
Here are some example header separator lines with alignment definitions:
|---+---+---|+ :-: |:------| ---:|| :-: :- -: -:-: | :-
Afooter separator line is used to demarcate footer rows from normal table rows. All table rowsbelow the footer separator line are considered to be footer rows.
A footer separator line is like a normal separator line except that dashes are replaced by equalsigns. A footer separator line may only appear once in a table. If multiple footer separator linesare used in one table, only the last is treated as footer separator line, all others are treatedas normal separator lines. Normal separator lines that are used after the footer separator lineare ignored.
Here are some example footer separator lines:
|====+====|+====|====+|=========||=
Trailing spaces or tabs are ignored in all cases. To simplify table creation and maintenance,header, footer and normal separator lines need not specify the same number of columns as table rows;even|-
and|=
are a valid separators.
Given the above components, a table is specified by
Also note
The table syntax differs from the one used inPHP Markdown Extra as follows:
- kramdown tables do not need to have a table header.
- kramdown tables can be structured using separator lines.
- kramdown tables can contain a table footer.
- kramdown tables need to be separated from other block-level elements.
Here is an example for a kramdown table with a table header row, two table bodies and a table footerrow:
|-----------------+------------+-----------------+----------------|| Default aligned |Left aligned| Center aligned | Right aligned ||-----------------|:-----------|:---------------:|---------------:|| First body part |Second cell | Third cell | fourth cell || Second line |foo | **strong** | baz || Third line |quux | baz | bar ||-----------------+------------+-----------------+----------------|| Second body | | | || 2 line | | | ||=================+============+=================+================|| Footer row | | | ||-----------------+------------+-----------------+----------------|
The above example table is rather time-consuming to create without the help of an ASCII tableeditor. However, the table syntax is flexible and the above table could also be written like this:
|---| Default aligned | Left aligned | Center aligned | Right aligned|-|:-|:-:|-:| First body part | Second cell | Third cell | fourth cell| Second line |foo | **strong** | baz| Third line |quux | baz | bar|---| Second body| 2 line|===| Footer row
A horizontal rule for visually separating content is created by using three or more asterisks,dashes or underscores (these may not be mixed on a line), optionally separated by spaces or tabs, onan otherwise blank line. The first asterisk, dash or underscore may optionally be indented up tothree spaces. The following examples show different possibilities to create a horizontal rule:
* * *--- _ _ _ _---------------
This syntax feature is not part of the original Markdown syntax. The idea comes from theMarukuandPandoc packages.
kramdown has built-in support for block and span-level mathematics written in LaTeX.
A math block needs to start and end onblock boundaries. It is started usingtwo dollar signs, optionally indented up to three spaces. The math block continues until the nexttwo dollar signs (which may be on the same line or on one of the next lines) that appear at the endof a line, i.e. they may only be followed by whitespace characters. The content of a math block hasto be valid LaTeX math. It is always wrapped inside a\begin{displaymath}...\end{displaymath}
environment except if it begins with a\begin
statement.
The following kramdown fragment
$$\begin{aligned} & \phi(x,y) = \phi \left(\sum_{i=1}^n x_ie_i, \sum_{j=1}^n y_je_j \right) = \sum_{i=1}^n \sum_{j=1}^n x_i y_j \phi(e_i, e_j) = \\ & (x_1, \ldots, x_n) \left( \begin{array}{ccc} \phi(e_1, e_1) & \cdots & \phi(e_1, e_n) \\ \vdots & \ddots & \vdots \\ \phi(e_n, e_1) & \cdots & \phi(e_n, e_n) \end{array} \right) \left( \begin{array}{c} y_1 \\ \vdots \\ y_n \end{array} \right)\end{aligned}$$
renders (using Javascript libraryMathJax) as
\[\begin{aligned} & \phi(x,y) = \phi \left(\sum_{i=1}^n x_ie_i, \sum_{j=1}^n y_je_j \right) = \sum_{i=1}^n \sum_{j=1}^n x_i y_j \phi(e_i, e_j) = \\ & (x_1, \ldots, x_n) \left( \begin{array}{ccc} \phi(e_1, e_1) & \cdots & \phi(e_1, e_n) \\ \vdots & \ddots & \vdots \\ \phi(e_n, e_1) & \cdots & \phi(e_n, e_n) \end{array} \right) \left( \begin{array}{c} y_1 \\ \vdots \\ y_n \end{array} \right)\end{aligned}\]Using inline math is also easy: just surround your math content with two dollar signs, like with amath block. If you don’t want to start an inline math statement, just escape the dollar signs andthey will be treated as simple dollar signs.
Note that LaTeX code that uses the pipe symbol
|
in inline math statements may lead to aline being recognized as a table line. This problem can be avoided by using the\vert
commandinstead of|
!
If you have a paragraph that looks like a math block but should actually be a paragraph with just aninline math statement, you need to escape the first dollar sign:
The following is a math block:$$ 5 + 5 $$But next comes a paragraph with an inline math statement:\$$ 5 + 5 $$
If you don’t even want the inline math statement, escape the first two dollar signs:
\$\$ 5 + 5 $$
The original Markdown syntax specifies that an HTML block must start at the left margin, i.e. noindentation is allowed. Also, the HTML block has to be surrounded by blank lines. Bothrestrictions are lifted for kramdown documents. Additionally, the original syntax does not allowyou to use Markdown syntax in HTML blocks which is allowed with kramdown.
An HTML block is potentially started if a line is encountered that begins with a non-span-level HTMLtag or a general XML tag (opening or closing) which may be indented up to three spaces.
The following HTML tags count as span-level HTML tags andwon’t start an HTML block if found atthe beginning of an HTML block line:
a abbr acronym b big bdo br button cite code del dfn em i img inputins kbd label option q rb rbc rp rt rtc ruby samp select small spanstrong sub sup textarea tt var
Further parsing of a found start tag depends on the tag and in which of three possible ways itscontent is parsed:
Parse as raw HTML block: If the HTML/XML tag content should be handled as raw HTML, then onlyHTML/XML tags are parsed from this point onwards and text is handled as raw, unparsed text untilthe matching end tag is found or until the end of the document. Each found tag will be parsed asraw HTML again. However, if a tag has amarkdown
attribute, this attribute controls parsing ofthis one tag (see below).
Note that the parser basically supports only correct XHTML! However, there are some exceptions.For example, attributes without values (i.e. boolean attributes) as well as unquoted attributevalues are also supported and elements without content like<hr />
can be written as<hr>
. Ifan invalid closing tag is found, it is ignored.
Parse as block-level elements: If the HTML/XML tag content should be parsed as text containingblock-level elements, the remaining text on the line will be parsed by the block-level parser asif it appears on a separate line (Caution: This also means that if the line consists of thestart tag, text and the end tag, the end tag will not be found!). All following lines are parsedas block-level elements until an HTML block line with the matching end tag is found or until theend of the document.
Parse as span-level elements: If the HTML/XML tag content should be parsed as text containing spanlevel elements, then all text until thenext matching end tag or until the end of the documentwill be the content of the tag and will later be parsed by the span-level parser. This also meansthat if the matching end tag is inside what appears to be a code span, it is still used!
If there is text after an end tag, it will be parsed as if it appears on a separate line except wheninside a raw HTML block.
Also, if an invalid closing tag is found, it is ignored.
Note that all HTML tag and attribute names are converted to lowercase!
By default, kramdown parses all block HTML tags and all XML tags as raw HTML blocks. However, thiscan be configured with theparse_block_html
. If this is set totrue
, then syntax parsing in HTMLblocks is globally enabled. It is also possible to enable/disable syntax parsing on a tag per tagbasis using themarkdown
attribute:
If an HTML tag has an attributemarkdown="0"
, then the content of the tag is parsed as raw HTMLblock.
If an HTML tag has an attributemarkdown="1"
, then the default mechanism for parsing syntax inthis tag is used.
If an HTML tag has an attributemarkdown="block"
, then the content of the tag is parsed as blocklevel elements.
If an HTML tag has an attributemarkdown="span"
, then the content of the tag is parsed as spanlevel elements.
The following list shows which HTML tags are parsed in which mode by default whenmarkdown="1"
isapplied orparse_block_html
istrue
:
script style math option textarea pre code kbd samp var
Also, all general XML tags are parsed as raw HTML blocks.
applet button blockquote body colgroup dd div dl fieldset form iframe limap noscript object ol table tbody thead tfoot tr td ul
a abbr acronym address b bdo big cite caption code del dfn dt emh1 h2 h3 h4 h5 h6 i ins kbd label legend optgroup p pre q rb rbcrp rt rtc ruby samp select small span strong sub sup th tt var
Remember that all span-level HTML tags like
a
orb
do not start an HTML block! However, theabove lists also include span-level HTML tags in the case themarkdown
attribute is used on atag inside a raw HTML block.
Here is a simple example input and its HTML output withparse_block_html
set tofalse
:
This is a para.<div>Something in here.</div>Other para.
<p>This is a para.</p><div>Something in here.</div><p>Other para.</p>
As one can see the content of thediv
tag will be parsed as raw HTML block and left alone.However, if themarkdown="1"
attribute was used on thediv
tag, the content would be parsed asblock-level elements and therefore converted to a paragraph.
You can also use several HTML tags at once:
<div><div><div>This is some text in the `layer1` div.</div>This is some text in the `layers` div.</div></div>This is a para outside the HTML block.
However, remember that if the content of a tag is parsed as block-level elements, the content thatappears after a start/end tag but on the same line, is processed as if it appears on a new line:
<div markdown="1">This is the first part of a para,which is continued here.</div><p markdown="1">This works without problems because it is parsed asspan-level elements</p><div markdown="1">The end tag is not found becausethis line is parsed as a paragraph</div>
Since settingparse_block_html
totrue
can lead to some not wanted behaviour, it is generallybetter to selectively enable or disable block/span-level elements parsing by using themarkdown
attribute!
Unclosed block-level HTML tags are correctly closed at the end of the document to ensure correctnesting and invalidly used end tags are removed from the output:
This is a para.<div markdown="1">Another para.</p>
<p>This is a para.</p><div> <p>Another para.</p></div>
The parsing of XML comments is also supported. The content of XML comments may span multiple lines.The start of an XML comment may only appear at the beginning of a line, optionally indented up tothree spaces. If there is text after the end of an XML comment, it will be parsed as if it appearson a separate line. kramdown syntax in XML comments is not processed:
This is a para.<!-- a *comment* --><!-- a `comment` spanning multiple lines--> First part of para,continues here.
These elements are all span-level elements and used inside block-level elements to markup textfragments. For example, one can easily create links or apply emphasis to certain text parts.
Note that empty span-level elements are not converted to empty HTML tags but are copied as-is to theoutput.
Three types of links are supported: automatic links, inline links and reference links.
This is the easiest one to create: Just surround a web address or an email address with anglebrackets and the address will be turned into a proper link. The address will be used as link targetand as link text. For example:
Information can be found on the <http://example.com> homepage.You can also mail me: <me.example@example.com>
It is not possible to specify a different link text using automatic links – use the other linktypes for this!
As the wording suggests, inline links provide all information inline in the text flow. Referencestyle links only provide the link text in the text flow and everything else is definedelsewhere. This also allows you to reuse link definitions.
An inline style link can be created by surrounding the link text with square brackets, followedimmediately by the link URL (and an optional title in single or double quotes preceded by at leastone space) in normal parentheses. For example:
This is [a link](http://rubyforge.org) to a page.A [link](../test "local URI") can also have a title.And [spaces](link with spaces.html)!
Notes:
The link text is treated like normal span-level text and therefore is parsed and converted.However, if you use square brackets within the link text, you have to either properly nest them orto escape them. It is not possible to create nested links!
The link text may also be omitted, e.g. for creating link anchors.
The link URL has to contain properly nested parentheses if no title is specified, or the link URLmust be contained in angle brackets (incorrectly nested parentheses are allowed).
The link title may not contain its delimiters and may not be empty.
Additional link attributes can be added by using aspan IAL after the inline link,for example:
This is a [link](http://example.com){:hreflang="de"}
To create a reference style link, you need to surround the link text with square brackets (as withinline links), followed by optional spaces/tabs/line breaks and then optionally followed withanother set of square brackets with the link identifier in them. A link identifier may not contain aclosing bracket and, when specified in a link definition, newline characters; it is also not casesensitive, line breaks and tabs are converted to spaces and multiple spaces are compressed into one.For example:
This is a [reference style link][linkid] to a page. And [this][linkid] is also a link. As is [this][] and [THIS].
If you don’t specify a link identifier (i.e. only use empty square brackets) or completely omit thesecond pair of square brackets, the link text is converted to a valid link identifier by removingall invalid characters and inserting spaces for line breaks. If there is a link definition found forthe link identifier, a link will be created. Otherwise the text is not converted to a link.
As with inline links, additional link attributes can be added by using aspan IALafter the reference link.
The link definition can be put anywhere in the document. It does not appear in the output. A linkdefinition looks like this:
[linkid]: http://www.example.com/ "Optional Title"
Link definitions are, despite being described here, non-content block-level elements.
The link definition has the following structure:
The original Markdown syntax also allowed the title to be specified in parenthesis. This is notallowed for consistency with the inline title.
If you have some text that looks like a link definition but should really be a link and some text,you can escape the colon after the link identifier:
The next paragraph contains a link and some text.[Room 100]\: There you should find everything you need![Room 100]: link_to_room_100.html
Although link definitions are non-content block-level elements,block IALs can beused on them to specify additional attributes for the links:
[linkid]: http://example.com{:hreflang="de"}
Images can be specified via a syntax that is similar to the one used by links. The difference isthat you have to use an exclamation mark before the first square bracket and that the link text of anormal link becomes the alternative text of the image link. As with normal links, image links can bewritten inline or reference style. For example:
Here comes a ! And here. Or ![here].With empty alt text 
The link definition for images is exactly the same as the link definition for normal links. Sinceadditional attributes can be added via span and block IALs, it is possible, for example, to specifyimage width and height:
Here is an inline {:height="36px" width="36px"}.And here is a referenced ![smile][smile]: smile.png{: height="36px" width="36px"}
kramdown supports two types of emphasis: light and strong emphasis. Text parts that are surroundedwith single asterisks*
or underscores_
are treated as text with light emphasis, text partssurrounded with two asterisks or underscores are treated as text with strong emphasis. Surroundedmeans that the starting delimiter must not be followed by a space and that the stopping delimitermust not be preceded by a space.
Here is an example for text with light and strong emphasis:
*some text*_some text_**some text**__some text__
The asterisk form is also allowed within a single word:
This is un*believe*able! This d_oe_s not work!
Text can be marked up with both light and strong emphasis, possibly using different delimiters.However, it is not possible to nest strong within strong or light within light emphasized text:
This is a ***text with light and strong emphasis***.This **is _emphasized_ as well**.This *does _not_ work*.This **does __not__ work either**.
If one or two asterisks or underscores are surrounded by spaces, they are treated literally. If youwant to force the literal meaning of an asterisk or an underscore you can backslash-escape it:
This is a * literal asterisk.These are ** two literal asterisk.As \*are\* these!
This is the span-level equivalent of thecode block element. You can markup a textpart as code span by surrounding it with backticks`
. For example:
Use `<html>` tags for this.
Note that all special characters in a code span are treated correctly. For example, when a code spanis converted to HTML, the characters<
,>
and&
are substituted by their respective HTMLcounterparts.
To include a literal backtick in a code span, you need to use two or more backticks as delimiters.You can insert one optional space after the starting and before the ending delimiter (these spacesare not used in the output). For example:
Here is a literal `` ` `` backtick.And here is `` `some` `` text (note the two spaces so that one is leftin the output!).
A single backtick surrounded by spaces is treated as literal backtick. If you want to force theliteral meaning of a backtick you can backslash-escape it:
This is a ` literal backtick.As \`are\` these!
As withcode blocks you can set the language of a code span by using anIAL:
This is a Ruby code fragment `x = Class.new`{:.language-ruby}
HTML tags cannot only be used on the block-level but also on the span-level. Span-level HTML tagscan only be used inside one block-level element, it is not possible to use a start tag in one blocklevel element and the end tag in another. Note that only correct XHTML is supported! This means thatyou have to use, for example,<br />
instead of<br>
(although kramdown tries to fix such errorsif possible).
By default, kramdown parses kramdown syntax inside span HTML tags. However, this behaviour can beconfigured with theparse_span_html
option. If this is set totrue
, then syntax parsing in HTMLspans is enabled, if it is set tofalse
, parsing is disabled. It is also possible toenable/disable syntax parsing on a tag per tag basis using themarkdown
attribute:
If an HTML tag has an attributemarkdown="0"
, then no parsing (except parsing of HTML span tags)is done inside that HTML tag.
If an HTML tag has an attributemarkdown="1"
, then the content of the tag is parsed as spanlevel elements.
If an HTML tag has an attributemarkdown="block"
, then a warning is issued because HTML spanscannot contain block-level elements and the attribute is ignored.
If an HTML tag has an attributemarkdown="span"
, then the content of the tag is parsed as spanlevel elements.
The content of a span-level HTML tag is normally parsed as span-level elements. Note, however, thatsome tags like<script>
are not parsed, i.e. their content is not modified.
XML comments can also be used (their content is not parsed). However, as with HTML tags the startand the end have to appear in the same block-level element.
Span-level XML comments as well as general span-level HTML and XML tags have to be preceded by atleast one non whitespace character on the same line so that kramdown correctly recognizes them asspan-level element and not as block-level element. However, all span HTML tags, i.e.a
,em
,b
,…, (opening or closing) can appear at the start of a line.
Unclosed span-level HTML tags are correctly closed at the end of the span-level text to ensurecorrect nesting and invalidly used end tags or block HTML tags are removed from the output:
This is </invalid>.This <span>is automatically closed.
<p>This is .</p><p>This <span>is automatically closed.</span></p>
Also note that one or more consecutive new line characters in an HTML span tag are replaced by asingle space, for example:
Link: <a href="somelink">text</a>
<p>Link: <a href="some link">text</a></p>
This syntax feature is not part of the original Markdown syntax. The idea and syntax comes fromthePHP Markdown Extra package.
Footnotes in kramdown are similar to reference style links and link definitions. You need to placethe footnote marker in the correct position in the text and the actual footnote content can bedefined anywhere in the document.
More exactly, a footnote marker can be created by placing the footnote name in square brackets.The footnote name has to start with a caret (^
), followed by a word character or a digit and thenoptionally followed by other word characters, digits or dashes. For example:
This is some text.[^1]. Other text.[^footnote].
Note that footnote markers cannot be used as part of the link text of a link because this wouldlead to nested links which is not allowed in HTML.
Footnote markers with the same name will link to the same footnote definition. The actual naming ofa footnote does not matter since the numbering of footnotes is controlled via the position of thefootnote markers in the document (the first found footnote marker will get the number 1, the second new footnote marker the number 2 and so on). If there is a footnote definition found for theidentifier, a footnote will be created. Otherwise the footnote marker is not converted to a footnotelink. Also note that all attributes set via a span IAL are ignored for a footnote marker!
A footnote definition is used to define the content of a footnote and has the following structure:
Footnote definitions are, despite being described here, non-content block-level elements.
The whole footnote content is treated like block-level text and can therefore contain any validblock-level element (also, any block-level element can be the first element). If you want to have acode block as first element, note that all leading spaces/tabs on the first line are stripped away.Here are some example footnote definitions:
[^1]: Some *crazy* footnote definition.[^footnote]: > Blockquotes can be in a footnote. as well as code blocks or, naturally, simple paragraphs.[^other-note]: no code block here (spaces are stripped away)[^codeblock-note]: this is now a code block (8 spaces indentation)
It does not matter where you put a footnote definition in a kramdown document; the content of allreferenced footnote definitions will be placed at the end of the kramdown document. Not referencedfootnote definitions are ignored. If more than one footnote definitions have the same footnote name,all footnote definitions but the last are ignored.
Although footnote definitions are non-content block-level elements,block IALs can beused on them to attach attributes. How these attributes are used depends on the converter.
This syntax feature is not part of the original Markdown syntax. The idea and syntax comes fromthePHP Markdown Extra package.
kramdown provides a syntax to assign the full phrase to an abbreviation. When writing the text, youdon’t need to do anything special. However, once you add abbreviation definitions, theabbreviations in the text get marked up automatically. Abbreviations can consist of any characterexcept a closing bracket.
An abbreviation definition is used to define the full phrase for an abbreviation and has thefollowing structure:
Later abbreviation definitions for the same abbreviation override prior ones and it does not matterwhere you put an abbreviation definition in a kramdown document. Empty definitions are also allowed.
Although abbreviation definitions are non-content block-level elements,block IALscan be used on them to specify additional attributes.
Here are some examples:
This is some text not written in HTML but in another language!*[another language]: It's called Markdown*[HTML]: HyperTextMarkupLanguage{:.mega-big}
Abbreviation definitions are, despite being described here, non-content block-level elements.
The original Markdown syntax does not support these transformations.
kramdown converts the following plain ASCII character into their corresponding typographic symbols:
---
will become an em-dash (like this —)--
will become an en-dash (like this –)...
will become an ellipsis (like this …)<<
will become a left guillemet (like this «) – an optional following space will become anon-breakable space>>
will become a right guillemet (like this ») – an optional leading space will become anon-breakable spaceThe parser also replaces normal single'
and double quotes"
with “fancy quotes”. Theremay betimes when kramdown falsely replace the quotes. If this is the case, just\'escape\"
the quotes andthey won’t be replaced with fancy ones.
This section describes the non-content elements that are used in kramdown documents, i.e. elementsthat don’t provide content for the document but have other uses such as separating block-levelelements or attaching attributes to elements.
Three non-content block-level elements are not described here because they fit better where theyare:
The EOB marker is not part of the standard Markdown syntax.
The End-Of-Block (EOB) marker – a^
as first character on an otherwise empty line – is a blocklevel element that can be used to specify the end of a block-level element even if the block-levelelement, after which it is used, would continue otherwise. If there is no block-level element toend, the EOB marker is simply ignored.
You won’t find an EOB marker in most kramdown documents but sometimes it is necessary to use it toachieve the wanted results which would be impossible otherwise. However, it should only be used whenabsolutely necessary!
For example, the following gives you one list with two items:
* list item one* list item two
By using an EOB marker, you can make two lists with one item each:
* list one^* list two
This syntax feature is not part of the original Markdown syntax. The idea and syntax comes fromtheMaruku package.
This is an implementation ofMaruku’s feature for adding attributes to block and span-levelelements (the naming is also taken from Maruku). This block-level element is used to defineattributes which can be referenced later. TheBlock Inline Attribute List is used toattach attributes to a block-level element and theSpan Inline Attribute List is usedto attach attributes to a span-level element.
Following are some examples of attribute list definitions (ALDs) and afterwards comes the syntaxexplanation:
{:ref-name: #myid .my-class}{:other: ref-name #id-of-other title="hallo you"}{:test: key="value \" with quote" and other='quote brace \}'}
An ALD line has the following structure:
The reference name needs to start with a word character or a digit, optionally followed by otherword characters, digits or dashes.
There are four different types of attribute definitions which have to be separated by one or morespaces:
This must be a valid reference name. It is used to reference an other ALD so that the attributesof the other ALD are also included in this one. The reference name is ignored when collecting theattributes if no attribute definition list with this reference name exists. For example, a simplereference looks likeid
.
A key-value pair is defined by a key name, which must follow the rules for reference names, thenan equal sign and then the value in single or double quotes. If you need to use the valuedelimiter (a single or a double quote) inside the value, you need to escape it with a backslash.Key-value pairs can be used to specify arbitrary attributes for block or span-level elements. Forexample, a key-value pair looks likekey1="bef \"quoted\" aft"
ortitle='This is a title'
.
An ID name is defined by using a hash and then the identifier name which needs to start with anASCII alphabetic character (A-Z or a-z), optionally followed by other ASCII characters, digits,dashes or colons. This is a short hand for the key-value pairid="IDNAME"
since this is oftenused. The ID name specifies the unique ID of a block or span-level element. For example, an IDname looks like#myid
.
A class name is defined by using a dot and then the class name which may contain any characterexcept whitespace, the dot character and the hash character.
This is (almost, but not quite) a short hand for the key-value pairclass="class-name"
. Almostbecause it actually means that the class name should be appended to the current value of theclass
attribute. The following ALDs are all equivalent:
{:id: .cls1 .cls2}{:id: .cls2}{:id: .cls2}{:id:}
As can be seen from the example of the class names, attributes that are defined earlier areoverwritten by ones with the same name defined later.
Also, everything in the attribute definitions part that does not match one of the above four typesis ignored.
If there is more than one ALD with the same reference name, the attribute definitions of all theALDs are processed like they are defined in one ALD.
These elements are used to attach attributes to another element.
This syntax feature is not part of the original Markdown syntax. The idea and syntax comes fromtheMaruku package.
This block-level element is used to attach attributes to another block-level element. A block inlineattribute list (block IAL) has the same structure as anALD exceptthat the colon/reference name/colon part is replaced by a colon. A block IAL (or two or more blockIALs) has to be put directly before or after the block-level element to which the attributes shouldbe attached. If a block IAL is directly afterand before a block-level element, it is applied topreceding element. The block IAL is ignored in all other cases, for example, when the block IAL issurrounded by blank lines.
Key-value pairs of an IAL take precedence over equally named key-value pairs in referenced ALDs.
Here are some examples for block IALs:
A simple paragraph with an ID attribute.{: #para-one}> A blockquote with a title{:title="The blockquote title"}{: #myid}{:.ruby} Some code here
This syntax feature is not part of the original Markdown syntax. The idea and syntax comes fromtheMaruku package.
This is a version of theblock inline attribute list for span-level elements. It hasthe same structure as the block IAL except that leading and trailing spaces are not allowed. A spanIAL (or two or more span IALs) has to be put directly after the span-level element to which itshould be applied, no additional character is allowed between, otherwise it is ignored and onlyremoved from the output.
Here are some examples for span IALs:
This *is*{:.underline} some `code`{:#id}{:.class}.A [link](test.html){:rel='something'} and some **tools**{:.tools}.
The special span IAL{::}
contains no attributes but doesn’t generate a warning either. It can beused to separate consecutive elements that would be falsely parsed if not separated. Here is an usecase:
This *is italic*{::}*marked*{:.special} text
This syntax feature is not part of the original Markdown syntax.
Extensions provide additional functionality but use the same syntax for it. They are available asblock as well as span-level elements.
The syntax for an extension is very similar to the syntax ofALDs.Here are some examples of how to specify extensions and afterwards is the syntax definition:
{::comment}This text is completely ignored by kramdown - a comment in the text.{:/comment}Do you see {::comment}this text{:/comment}?{::comment}some other comment{:/}{::options key="val" /}
An extension can be specified with or without a body. Therefore there exist a start and an end tagfor extensions. The start tag has the following structure:
The stop tag has the following structure:
A stop tag is only needed if the extension has a body!
The above syntax can be used as is for span-level extensions. The starting and ending lines for block-levelextensions are defined as:
If no end tag can be found for an extension start tag, the start tag is treated as if it has nobody. If an invalid extension stop tag is found, it is ignored. If an invalid extension name isspecified the extension (and the eventually specified body) are ignored.
The following extensions can be used with kramdown:
comment
Treat the body text as a comment which does not show in the output.
nomarkdown
Don’t process the body with kramdown but output it as-is. The attributetype
specifies whichconverters should output the body: if the attribute is missing, all converters should output it.Otherwise the attribute value has to be a space separated list of converter names and theseconverters should output the body.
options
Should be used without a body since the body is ignored. Is used for setting the global optionsfor the kramdown processor (for example, to disable automatic header ID generation). Note thatoptions that are used by the parser are immediately effective whereas all other options are not!This means, for example, that it is not possible to set converter options only for some part of akramdown document.