--- title: Quick Reference in_menu: true sort_info: 9 --- # Quick Reference Below are examples of all available structural elements that can be used in a kramdown text. Since the kramdown syntax is a superset of the Markdown syntax, only a small part of the available syntax is not available in standard Markdown syntax. Note, that only the most basic syntax information is given. However, a link to the detailed syntax for each element is provided (which also details the differences to the standard Markdown syntax). The quick reference is for version **<%= ::Kramdown::VERSION %>** of the syntax documentation. kramdown has two main classes of elements: block and span level elements. Block level elements are used to create paragraphs, headers, lists and so on whereas span level elements are used to markup text phrases as emphasized, as a link and so on. All examples below feature the kramdown source, the converted HTML source and the output as it appears in the browser. This looks like this:
kramdown example code
Example code converted to HTML
This can contain only *span* level elements.
{::kdexample:} ## Block Attributes {::kdlink:: #block-inline-attribute-lists part="block IALs"} {::kdlink:: #attribute-list-definitions part="ALDs"} You can assign any attribute to a block level element. Just directly follow the block with a *block inline attribute list* (or short: block IAL). A block IAL consists of a left curly brace, followed by a colon, the attribute definitions and a right curly brace. Here is a simple example which sets the `title` attribute of a block quote: {::kdexample:} > A nice blockquote {: title="Blockquote title"} {::kdexample:} As one often wants to set one or more CSS classes on an element, there is an easy shortcut: {::kdexample:} > A nice blockquote {: .class1 .class2} {::kdexample:} A shortcut for setting the ID is also provided. Just prefix the ID with a hash symbol: {::kdexample:} > A nice blockquote {: #with-an-id} {::kdexample:} Sometimes one wants to use the same attributes for many elements. kramdown allows you to define the attributes in one place with an *attribute list definition* (or short: ALD) and just reference this definition in a block IAL. An ALD has the same structure as a block IAL but the colon has to be replace with a colon, the reference name and another colon. By just using the reference name as-is in a block IAL, one can include the attributes of the referenced ALD: {::kdexample:} {:refdef: .c1 #id .c2 title="title"} paragraph {: refdef} {::kdexample:} The order in a block IAL or ALD is important because later defined attributes overwrite (with the exception of the shortcut for CSS classes) prior defined attributes: {::kdexample:} {:refdef: .c1 #id .c2 title="title"} paragraph {: refdef .c3 title="t" #para} {::kdexample:} ## Extension Blocks {::kdlink:: #extension-blocks part="extension blocks"} Extension blocks can be used to add custom behaviour to kramdown. For more information on how to do this have a look at the [API documentation]({relocatable: /rdoc/index.html}). kramdown comes with some built-in extensions for ignoring text (i.e. treating text as comment), for inserting arbitrary text into the output and for setting kramdown options. Here is an example that shows how to insert comments into text: {::kdexample:} This is a paragraph {::comment:} This is a comment which is completely ignored. {::comment:} ... paragraph continues here. {::nomarkdown:} This is not parsed *by* kramdown {::nomarkdown:} {::kdexample:} As one can see from the above example, the syntax for extension blocks is virtually the same as for block IALs and ALDs, except that the colon of a block IAL has to be replaced by two colons, the name of the extension and then one or two colons. If one colon is used, it means that the extension has body text and continues until a matching ending line (as in the example above). If two colons are used, then the extension does not have a body, for example: {::kdexample:} # Header with id {::options:: auto_ids="false"} # Header without id {::options:: auto_ids="true"} # Header with id {::kdexample:} # Span Level Elements - Text Modifiers ## Emphasis {::kdlink:: #emphasis part="emphasis"} Emphasis can be added to text by surrounding the text with either asterisks or underscores: {::kdexample:} This is *emphasized*, _this_ too! {::kdexample:} Strong emphasis can be done by doubling the delimiters: {::kdexample:} This is **strong**, __this__ too! {::kdexample:} The form with the asterisks can also be used to markup parts of words: {::kdexample:} This w**ork**s as expected! {::kdexample:} ## Links and Images {::kdlink:: #links-and-images part="links and images"} A simple link can be created by surrounding the text with square brackets and the link URL with parentheses: {::kdexample:} A [link](http://kramdown.rubyforge.org) to the kramdown homepage. {::kdexample:} You can also add title information to the link: {::kdexample:} A [link](http://kramdown.rubyforge.org "hp") to the homepage. {::kdexample:} There is another way to create links which does not interrupt the text flow. The URL and title are defined using a reference name and this reference name is then used in square brackets instead of the link URL: {::kdexample:} A [link][kramdown hp] to the homepage. [kramdown hp]: http://kramdown.rubyforge.org "hp" {::kdexample:} If the link text itself is the reference name, the second set of square brackets can be omitted: {::kdexample:} A link to the [kramdown hp]. [kramdown hp]: http://kramdown.rubyforge.org "hp" {::kdexample:} Images can be created in a similar way: just use an exclamation mark before the square brackets. The link text will become the alternative text of the image and the link URL specifies the image source: {::kdexample:} An image:  {::kdexample:} ## Inline Code {::kdlink:: #code-spans part="code spans"} Text phrases can be easily marked up as code by surrounding them with backticks: {::kdexample:} Use `Kramdown::Document.new(text).to_html` to convert the `text` in kramdown syntax to HTML. {::kdexample:} If you want to use literal backticks in your code, just use two or more backticks as delimiters. The space right after the beginning delimiter and the one right before the closing delimiter are ignore: {::kdexample:} Use backticks to markup code, e.g. `` `code` ``. {::kdexample:} ## Footnotes {::kdlink:: #footnotes part="footnotes"} Footnotes can easily be used in kramdown. Just set a footnote marker (consists of square brackets with a caret and the footnote name inside) in the text and somewhere else the footnote definition (which basically looks like a reference link definition): {::kdexample:} This is a text with a footnote[^1]. [^1]: And here is the definition. {::kdexample:} The footnote definition can contain any block level element, all lines following a footnote definition indented with four spaces or one tab belong to the definition: {::kdexample:} This is a text with a footnote[^2]. [^2]: And here is the definition. > With a quote! {::kdexample:} As can be seen above the footnote name is only used for the anchors and the numbering is done automatically in document order. ## HTML Elements {::kdlink:: #html-spans part="HTML spans"} HTML is not only supported on the block level but also on the span level: {::kdexample:} This is written in red. {::kdexample:} ## Inline Attributes {::kdlink:: #span-inline-attribute-lists part="span IALs"} As with a block level element you can assign any attribute to a span level elements using a *span inline attribute list* (or short: span IAL). A span IAL has the same syntax as a block IAL and must immediately follow the span level element: {::kdexample:} This is *red*{: style="color: red"}. {::kdexample:}