kramdown 1.17.0 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of kramdown might be problematic. Click here for more details.

Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTERS +4 -2
  3. data/VERSION +1 -1
  4. data/bin/kramdown +13 -14
  5. data/lib/kramdown.rb +2 -2
  6. data/lib/kramdown/converter.rb +6 -7
  7. data/lib/kramdown/converter/base.rb +18 -29
  8. data/lib/kramdown/converter/hash_ast.rb +4 -4
  9. data/lib/kramdown/converter/html.rb +82 -67
  10. data/lib/kramdown/converter/kramdown.rb +83 -78
  11. data/lib/kramdown/converter/latex.rb +53 -47
  12. data/lib/kramdown/converter/man.rb +22 -25
  13. data/lib/kramdown/converter/math_engine/mathjax.rb +10 -10
  14. data/lib/kramdown/converter/remove_html_tags.rb +2 -2
  15. data/lib/kramdown/converter/syntax_highlighter.rb +2 -2
  16. data/lib/kramdown/converter/syntax_highlighter/minted.rb +2 -2
  17. data/lib/kramdown/converter/syntax_highlighter/rouge.rb +5 -5
  18. data/lib/kramdown/converter/toc.rb +5 -5
  19. data/lib/kramdown/document.rb +9 -11
  20. data/lib/kramdown/element.rb +11 -9
  21. data/lib/kramdown/error.rb +2 -2
  22. data/lib/kramdown/options.rb +258 -384
  23. data/lib/kramdown/parser.rb +2 -3
  24. data/lib/kramdown/parser/base.rb +7 -6
  25. data/lib/kramdown/parser/html.rb +103 -95
  26. data/lib/kramdown/parser/kramdown.rb +32 -36
  27. data/lib/kramdown/parser/kramdown/abbreviation.rb +13 -10
  28. data/lib/kramdown/parser/kramdown/autolink.rb +3 -3
  29. data/lib/kramdown/parser/kramdown/blank_line.rb +2 -2
  30. data/lib/kramdown/parser/kramdown/block_boundary.rb +2 -2
  31. data/lib/kramdown/parser/kramdown/blockquote.rb +4 -5
  32. data/lib/kramdown/parser/kramdown/codeblock.rb +4 -5
  33. data/lib/kramdown/parser/kramdown/codespan.rb +5 -5
  34. data/lib/kramdown/parser/kramdown/emphasis.rb +6 -6
  35. data/lib/kramdown/parser/kramdown/eob.rb +2 -2
  36. data/lib/kramdown/parser/kramdown/escaped_chars.rb +2 -2
  37. data/lib/kramdown/parser/kramdown/extensions.rb +31 -26
  38. data/lib/kramdown/parser/kramdown/footnote.rb +7 -6
  39. data/lib/kramdown/parser/kramdown/header.rb +6 -6
  40. data/lib/kramdown/parser/kramdown/horizontal_rule.rb +3 -3
  41. data/lib/kramdown/parser/kramdown/html.rb +31 -26
  42. data/lib/kramdown/parser/kramdown/html_entity.rb +6 -5
  43. data/lib/kramdown/parser/kramdown/line_break.rb +3 -3
  44. data/lib/kramdown/parser/kramdown/link.rb +13 -11
  45. data/lib/kramdown/parser/kramdown/list.rb +38 -40
  46. data/lib/kramdown/parser/kramdown/math.rb +4 -5
  47. data/lib/kramdown/parser/kramdown/paragraph.rb +5 -5
  48. data/lib/kramdown/parser/kramdown/smart_quotes.rb +23 -23
  49. data/lib/kramdown/parser/kramdown/table.rb +18 -17
  50. data/lib/kramdown/parser/kramdown/typographic_symbol.rb +8 -8
  51. data/lib/kramdown/parser/markdown.rb +9 -8
  52. data/lib/kramdown/utils.rb +5 -6
  53. data/lib/kramdown/utils/configurable.rb +7 -6
  54. data/lib/kramdown/utils/entities.rb +286 -289
  55. data/lib/kramdown/utils/html.rb +10 -12
  56. data/lib/kramdown/utils/lru_cache.rb +3 -2
  57. data/lib/kramdown/utils/string_scanner.rb +2 -3
  58. data/lib/kramdown/utils/unidecoder.rb +8 -6
  59. data/lib/kramdown/version.rb +3 -3
  60. data/man/man1/kramdown.1 +3 -107
  61. data/test/run_tests.rb +6 -6
  62. data/test/test_files.rb +122 -298
  63. data/test/test_location.rb +8 -30
  64. data/test/test_string_scanner_kramdown.rb +6 -9
  65. data/test/testcases/block/06_codeblock/highlighting-opts.html +6 -6
  66. data/test/testcases/block/06_codeblock/highlighting.html +5 -6
  67. data/test/testcases/block/06_codeblock/with_lang_in_fenced_block.options +1 -1
  68. data/test/testcases/block/07_horizontal_rule/error.html +2 -2
  69. data/test/testcases/block/09_html/html5_attributes.html +2 -0
  70. data/test/testcases/block/09_html/html5_attributes.text +2 -0
  71. data/test/testcases/block/09_html/html_to_native/typography.html +1 -1
  72. data/test/testcases/block/09_html/simple.html +1 -1
  73. data/test/testcases/block/12_extension/options3.html +7 -6
  74. data/test/testcases/block/12_extension/options3.text +2 -2
  75. data/test/testcases/span/01_link/inline.html +1 -1
  76. data/test/testcases/span/01_link/reference.html +3 -3
  77. data/test/testcases/span/03_codespan/highlighting.html +1 -1
  78. data/test/testcases/span/text_substitutions/entities_as_char.html +1 -1
  79. metadata +5 -234
  80. data/Rakefile +0 -341
  81. data/benchmark/benchmark.rb +0 -43
  82. data/benchmark/benchmark.sh +0 -74
  83. data/benchmark/generate_data.rb +0 -119
  84. data/benchmark/mdbasics.text +0 -306
  85. data/benchmark/mdsyntax.text +0 -888
  86. data/benchmark/testing.sh +0 -12
  87. data/benchmark/timing.sh +0 -10
  88. data/doc/_design.scss +0 -441
  89. data/doc/bg.png +0 -0
  90. data/doc/default.scss +0 -217
  91. data/doc/default.template +0 -62
  92. data/doc/documentation.page +0 -84
  93. data/doc/documentation.template +0 -36
  94. data/doc/index.page +0 -113
  95. data/doc/installation.page +0 -88
  96. data/doc/links.markdown +0 -6
  97. data/doc/metainfo +0 -13
  98. data/doc/news.feed +0 -9
  99. data/doc/news.page +0 -29
  100. data/doc/options.page +0 -49
  101. data/doc/quickref.page +0 -603
  102. data/doc/sidebar.template +0 -22
  103. data/doc/sitemap.sitemap +0 -5
  104. data/doc/syntax.page +0 -1799
  105. data/doc/tests.page +0 -104
  106. data/doc/virtual +0 -14
  107. data/lib/kramdown/converter/math_engine/itex2mml.rb +0 -39
  108. data/lib/kramdown/converter/math_engine/katex.rb +0 -35
  109. data/lib/kramdown/converter/math_engine/mathjaxnode.rb +0 -56
  110. data/lib/kramdown/converter/math_engine/ritex.rb +0 -38
  111. data/lib/kramdown/converter/math_engine/sskatex.rb +0 -97
  112. data/lib/kramdown/converter/pdf.rb +0 -625
  113. data/lib/kramdown/converter/syntax_highlighter/coderay.rb +0 -81
  114. data/lib/kramdown/parser/gfm.rb +0 -188
  115. data/lib/kramdown/utils/ordered_hash.rb +0 -18
  116. data/setup.rb +0 -1585
  117. data/test/testcases/block/07_horizontal_rule/error.html.19 +0 -7
  118. data/test/testcases/block/09_html/html_to_native/typography.html.19 +0 -1
  119. data/test/testcases/block/09_html/simple.html.19 +0 -60
  120. data/test/testcases/block/15_math/itex2mml.html +0 -1
  121. data/test/testcases/block/15_math/itex2mml.options +0 -1
  122. data/test/testcases/block/15_math/itex2mml.text +0 -1
  123. data/test/testcases/block/15_math/katex.html.19 +0 -2
  124. data/test/testcases/block/15_math/katex.options +0 -1
  125. data/test/testcases/block/15_math/katex.text +0 -2
  126. data/test/testcases/block/15_math/mathjaxnode.html.19 +0 -27
  127. data/test/testcases/block/15_math/mathjaxnode.options +0 -1
  128. data/test/testcases/block/15_math/mathjaxnode.text +0 -1
  129. data/test/testcases/block/15_math/mathjaxnode_notexhints.html.19 +0 -23
  130. data/test/testcases/block/15_math/mathjaxnode_notexhints.options +0 -3
  131. data/test/testcases/block/15_math/mathjaxnode_notexhints.text +0 -1
  132. data/test/testcases/block/15_math/mathjaxnode_semantics.html.19 +0 -32
  133. data/test/testcases/block/15_math/mathjaxnode_semantics.options +0 -3
  134. data/test/testcases/block/15_math/mathjaxnode_semantics.text +0 -1
  135. data/test/testcases/block/15_math/ritex.html +0 -1
  136. data/test/testcases/block/15_math/ritex.options +0 -1
  137. data/test/testcases/block/15_math/ritex.text +0 -1
  138. data/test/testcases/block/15_math/sskatex.html.19 +0 -2
  139. data/test/testcases/block/15_math/sskatex.options +0 -1
  140. data/test/testcases/block/15_math/sskatex.text +0 -2
  141. data/test/testcases/span/01_link/inline.html.19 +0 -46
  142. data/test/testcases/span/01_link/reference.html.19 +0 -37
  143. data/test/testcases/span/math/itex2mml.html +0 -1
  144. data/test/testcases/span/math/itex2mml.options +0 -1
  145. data/test/testcases/span/math/itex2mml.text +0 -1
  146. data/test/testcases/span/math/katex.html.19 +0 -1
  147. data/test/testcases/span/math/katex.options +0 -1
  148. data/test/testcases/span/math/katex.text +0 -1
  149. data/test/testcases/span/math/mathjaxnode.html.19 +0 -27
  150. data/test/testcases/span/math/mathjaxnode.options +0 -1
  151. data/test/testcases/span/math/mathjaxnode.text +0 -1
  152. data/test/testcases/span/math/ritex.html +0 -1
  153. data/test/testcases/span/math/ritex.options +0 -1
  154. data/test/testcases/span/math/ritex.text +0 -1
  155. data/test/testcases/span/math/sskatex.html.19 +0 -1
  156. data/test/testcases/span/math/sskatex.options +0 -1
  157. data/test/testcases/span/math/sskatex.text +0 -1
  158. data/test/testcases/span/text_substitutions/entities_as_char.html.19 +0 -1
  159. data/test/testcases_gfm/atx_header.html +0 -3
  160. data/test/testcases_gfm/atx_header.text +0 -3
  161. data/test/testcases_gfm/backticks_disable_highlighting.html +0 -2
  162. data/test/testcases_gfm/backticks_disable_highlighting.options +0 -1
  163. data/test/testcases_gfm/backticks_disable_highlighting.text +0 -3
  164. data/test/testcases_gfm/backticks_syntax.html +0 -20
  165. data/test/testcases_gfm/backticks_syntax.text +0 -19
  166. data/test/testcases_gfm/codeblock_fenced.html +0 -20
  167. data/test/testcases_gfm/codeblock_fenced.options +0 -1
  168. data/test/testcases_gfm/codeblock_fenced.text +0 -21
  169. data/test/testcases_gfm/hard_line_breaks.html +0 -3
  170. data/test/testcases_gfm/hard_line_breaks.text +0 -3
  171. data/test/testcases_gfm/hard_line_breaks_off.html +0 -2
  172. data/test/testcases_gfm/hard_line_breaks_off.options +0 -1
  173. data/test/testcases_gfm/hard_line_breaks_off.text +0 -2
  174. data/test/testcases_gfm/header_ids.html +0 -27
  175. data/test/testcases_gfm/header_ids.html.19 +0 -27
  176. data/test/testcases_gfm/header_ids.options +0 -1
  177. data/test/testcases_gfm/header_ids.text +0 -27
  178. data/test/testcases_gfm/header_ids_with_prefix.html +0 -3
  179. data/test/testcases_gfm/header_ids_with_prefix.options +0 -2
  180. data/test/testcases_gfm/header_ids_with_prefix.text +0 -3
  181. data/test/testcases_gfm/no_typographic.html +0 -3
  182. data/test/testcases_gfm/no_typographic.html.19 +0 -3
  183. data/test/testcases_gfm/no_typographic.options +0 -1
  184. data/test/testcases_gfm/no_typographic.text +0 -3
  185. data/test/testcases_gfm/paragraph_end-disabled.html +0 -31
  186. data/test/testcases_gfm/paragraph_end-disabled.options +0 -1
  187. data/test/testcases_gfm/paragraph_end-disabled.text +0 -27
  188. data/test/testcases_gfm/paragraph_end.html +0 -38
  189. data/test/testcases_gfm/paragraph_end.text +0 -27
  190. data/test/testcases_gfm/strikethrough.html +0 -27
  191. data/test/testcases_gfm/strikethrough.html.19 +0 -27
  192. data/test/testcases_gfm/strikethrough.text +0 -27
  193. data/test/testcases_gfm/task_list.html +0 -40
  194. data/test/testcases_gfm/task_list.text +0 -26
  195. data/test/testcases_gfm/two_para_hard_line_breaks.html +0 -4
  196. data/test/testcases_gfm/two_para_hard_line_breaks.text +0 -4
@@ -1,22 +0,0 @@
1
- <h2>Support kramdown</h2>
2
-
3
- <p>If you like kramdown and would like to support it, you are welcome to make a small
4
- donation (Patreon or PayPal) -- it will surely be appreciated! Thanks!</p>
5
-
6
- <div style="text-align: center">
7
-
8
- <a href="https://www.patreon.com/bePatron?u=4908963" class="patreon">Become a Patron!</a>
9
-
10
- <form style="margin-top: 15px" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
11
- <input type="hidden" name="cmd" value="_s-xclick">
12
- <input type="hidden" name="hosted_button_id" value="99HUWKWPMUHWG">
13
- <input type="image" src="//static.gettalong.org/images/paypal_small.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
14
- </form>
15
-
16
- </div>
17
-
18
- <h2>Sponsors</h2>
19
-
20
- <p>GROSSWEBER provides <a href="http://grossweber.com/b/kramdown" target="_blank">software
21
- development consulting and training services</a>. <em>We like to work on open source. We use it heavily.
22
- We love kramdown!</em></p>
@@ -1,5 +0,0 @@
1
- ---
2
- entries:
3
- alcn: /**/*.html
4
- default_change_freq: monthly
5
- ---
@@ -1,1799 +0,0 @@
1
- ---
2
- title: Syntax
3
- in_menu: true
4
- sort_info: 10
5
- --- name:sidebar
6
- <div style="text-align: right">
7
- <a href="https://www.patreon.com/bePatron?u=4908963" class="patreon">Become a Patron!</a>
8
- </div>
9
-
10
- <h1>Contents</h1>
11
-
12
- {menu: {options: {descendants: true, levels: [2,6]}}}
13
- --- name:content
14
-
15
- # kramdown Syntax
16
-
17
- This is version **<%= ::Kramdown::VERSION %>** of the syntax documentation.
18
-
19
- The kramdown syntax is based on the Markdown syntax and has been enhanced with features that are
20
- found in other Markdown implementations like [Maruku], [PHP Markdown Extra] and [Pandoc]. However,
21
- it strives to provide a strict syntax with definite rules and therefore isn't completely compatible
22
- with Markdown. Nonetheless, most Markdown documents should work fine when parsed with kramdown. All
23
- places where the kramdown syntax differs from the Markdown syntax are highlighted.
24
-
25
- Following is the complete syntax definition for all elements kramdown supports. Together with the
26
- documentation on the available converters, it is clearly specified what you will get when a kramdown
27
- document is converted.
28
-
29
-
30
- ## Source Text Formatting
31
-
32
- A kramdown document may be in any encoding, for example ASCII, UTF-8 or ISO-8859-1, and the output
33
- will have the same encoding as the source.
34
-
35
- The document consists of two types of elements, block-level elements and span-level elements:
36
-
37
- * Block-level elements define the main structure of the content, for example, what part of the text
38
- should be a paragraph, a list, a blockquote and so on.
39
-
40
- * Span-level elements mark up small text parts as, for example, emphasized text or a link.
41
-
42
- Thus span-level elements can only occur inside block-level elements or other span-level elements.
43
-
44
- You will often find references to the "first column" or "first character" of a line in a block-level
45
- element descriptions. Such a reference is always to be taken relative to the current indentation
46
- level because some block-level elements open up a new indentation level (e.g. blockquotes). The
47
- beginning of a kramdown document opens up the default indentation level which begins at the first
48
- column of the text.
49
-
50
-
51
- ### Line Wrapping
52
-
53
- Some lightweight markup syntax don't work well in environments where lines are hard-wrapped. For
54
- example, this is the case with many email programs. Therefore kramdown allows content like
55
- paragraphs or blockquotes to be hard-wrapped, i.e. broken across lines. This is sometimes referred
56
- to as "lazy syntax" since the indentation or line prefix required for the first line of content is
57
- not required for the consecutive lines.
58
-
59
- Block-level elements that support line wrapping always end when one of the following conditions is
60
- met:
61
-
62
- * a [blank line](#blank-lines), an [EOB marker line](#eob-marker), a [block IAL](#block-ials) or the
63
- end of the document (i.e. a [block boundary](#block-boundaries)),
64
-
65
- * or an [HTML block](#html-blocks).
66
-
67
- Line wrapping is allowed throughout a kramdown document but there are some block-level elements that
68
- do *not* support being hard-wrapped:
69
-
70
- [headers](#headers)
71
-
72
- : This is not an issue in most situations since headers normally fit on one line. If a header text
73
- gets too long for one line, you need to use HTML syntax instead.
74
-
75
- [fenced code blocks](#fenced-code-blocks)
76
-
77
- : The delimiting lines of a fenced code block do not support hard-wrapping. Since everything between
78
- the delimiting lines is taken as is, the content of a fenced code block does also not support
79
- hard-wrapping.
80
-
81
- [definition list terms](#definition-lists)
82
-
83
- : Each definition term has to appear on a separate line. Hard-wrapping would therefore introduce
84
- additional definition terms. The definitions themselves, however, do support hard-wrapping.
85
-
86
- [tables](#tables)
87
-
88
- : Since each line of a kramdown table describes one table row or a separator, it is not possible to
89
- hard-wrap tables.
90
-
91
- **Note** that it is **NOT** recommended to use lazy syntax to write a kramdown document. The
92
- flexibility that the kramdown syntax offers due to the issue of line wrapping hinders readability
93
- and should therefore not be used.
94
-
95
-
96
- ### Usage of Tabs
97
-
98
- kramdown assumes that tab stops are set at multiples of four. This is especially important when
99
- using tabs for indentation in lists. Also, tabs may only be used at the beginning of a line when
100
- indenting text and must not be preceded by spaces. Otherwise the results may be unexpected.
101
-
102
-
103
- ### Automatic and Manual Escaping
104
-
105
- Depending on the output format, there are often characters that need special treatment. For example,
106
- when converting a kramdown document to HTML one needs to take care of the characters `<`, `>` and
107
- `&`. To ease working with these special characters, they are automatically and correctly escaped
108
- depending on the output format.
109
-
110
- This means, for example, that you can just use `<`, `>` and `&` in a kramdown document and need not
111
- think about when to use their HTML entity counterparts. However, if you *do use* HTML entities or
112
- HTML tags which use one of the characters, the result will be correct nonetheless!
113
-
114
- Since kramdown also uses some characters to mark-up the text, there needs to be a way to escape
115
- these special characters so that they can have their normal meaning. This can be done by using
116
- backslash escapes. For example, you can use a literal back tick like this:
117
-
118
- This \`is not a code\` span!
119
-
120
- Following is a list of all the characters (character sequences) that can be escaped:
121
-
122
- \ backslash
123
- . period
124
- * asterisk
125
- _ underscore
126
- + plus
127
- - minus
128
- = equal sign
129
- ` back tick
130
- ()[]{}<> left and right parens/brackets/braces/angle brackets
131
- # hash
132
- ! bang
133
- << left guillemet
134
- >> right guillemet
135
- : colon
136
- | pipe
137
- " double quote
138
- ' single quote
139
- $ dollar sign
140
-
141
-
142
- ## Block Boundaries
143
-
144
- Some block-level elements have to start and/or end on so called block boundaries, as stated in their
145
- documentation. There are two cases where block boundaries come into play:
146
-
147
- * If a block-level element has to start on a block boundary, it has to be preceded by either a
148
- [blank line](#blank-lines), an [EOB marker](#eob-marker), a [block IAL](#block-ials) or it has to
149
- be the first element.
150
-
151
- * If a block-level element has to end on a block boundary, it has to be followed by either a [blank
152
- line](#blank-lines), an [EOB marker](#eob-marker), a [block IAL](#block-ials) or it has to be the
153
- last element.
154
-
155
-
156
-
157
- # Structural Elements
158
-
159
- All structural elements are block-level elements and they are used to structure the content. They
160
- can mark up some text as, for example, a simple paragraph, a quote or as a list item.
161
-
162
-
163
- ## Blank lines
164
-
165
- Any line that just contains white space characters such as spaces and tabs is considered a blank
166
- line by kramdown. One or more consecutive blank lines are handled as one empty blank line. Blank
167
- lines are used to separate block-level elements from each other and in this case they don't have
168
- semantic meaning. However, there are some cases where blank lines do have a semantic meaning:
169
-
170
- * When used in headers -- see the [headers section](#headers)
171
- * When used in code blocks -- see the [code blocks section](#code-blocks)
172
- * When used in lists -- see the [lists section](#lists)
173
- * When used in math blocks -- see the [math blocks section](#math-blocks)
174
- * When used for elements that have to start/end on [block boundaries](#block-boundaries)
175
-
176
-
177
- ## Paragraphs
178
-
179
- Paragraphs are the most used block-level elements. One or more consecutive lines of text are
180
- interpreted as one paragraph. The first line of a paragraph may be indented up to three spaces, the
181
- other lines can have any amount of indentation because paragraphs support [line
182
- wrapping](#line-wrapping). In addition to the rules outlined in the section about line wrapping, a
183
- paragraph ends when a [definition list line](#definition-lists) is encountered.
184
-
185
- You can separate two consecutive paragraphs from each other by using one or more blank lines. Notice
186
- that a line break in the source does not mean a line break in the output (due to the [lazy
187
- syntax](#line-wrapping))!. If you want to have an explicit line break (i.e. a `<br />` tag) you need
188
- to end a line with two or more spaces or two backslashes! Note, however, that a line break on the
189
- last text line of a paragraph is not possible and will be ignored. Leading and trailing spaces will
190
- be stripped from the paragraph text.
191
-
192
- The following gives you an example of how paragraphs look like:
193
-
194
- This para line starts at the first column. However,
195
- the following lines can be indented any number of spaces/tabs.
196
- The para continues here.
197
-
198
- This is another paragraph, not connected to the above one. But
199
- with a hard line break. \\
200
- And another one.
201
- {: .show-whitespaces .ws-lr}
202
-
203
-
204
- ## Headers
205
-
206
- kramdown supports so called Setext style and atx style headers. Both forms can be used inside a
207
- single document.
208
-
209
- ### Setext Style
210
-
211
- Setext style headers have to start on a [block boundary](#block-boundaries) with a line of text (the
212
- header text) and a line with only equal signs (for a first level header) or dashes (for a second
213
- level header). The header text may be indented up to three spaces but any leading or trailing spaces
214
- are stripped from the header text. The amount of equal signs or dashes is not significant, just one
215
- is enough but more may look better. The equal signs or dashes have to begin at the first column. For
216
- example:
217
-
218
- First level header
219
- ==================
220
-
221
- Second level header
222
- ------
223
-
224
- Other first level header
225
- =
226
-
227
- Since Setext headers start on block boundaries, this means in most situations that they have to be
228
- preceded by a blank line. However, blank lines are not necessary after a Setext header:
229
-
230
- This is a normal
231
- paragraph.
232
-
233
- And A Header
234
- ------------
235
- And a paragraph
236
-
237
- > This is a blockquote.
238
-
239
- And A Header
240
- ------------
241
-
242
- However, it is generally a good idea to also use a blank line after a Setext header because it looks
243
- more appropriate and eases reading of the document.
244
-
245
- > The original Markdown syntax allows one to omit the blank line before a Setext header. However,
246
- > this leads to ambiguities and makes reading the document harder than necessary. Therefore it is
247
- > not allowed in a kramdown document.
248
- {: .markdown-difference}
249
-
250
- An edge case worth mentioning is the following:
251
-
252
- header
253
- ---
254
- para
255
-
256
- One might ask if this represents two paragraphs separated by a [horizontal rule](#horizontal-rules)
257
- or a second level header and a paragraph. As suggested by the wording in the example, the latter is
258
- the case. The general rule is that Setext headers are processed before horizontal rules.
259
-
260
- ### atx Style
261
-
262
- atx style headers have to start on a [block boundary](#block-boundaries) with a line that contains
263
- one or more hash characters and then the header text. No spaces are allowed before the hash
264
- characters. The number of hash characters specifies the heading level: one hash character gives you
265
- a first level heading, two a second level heading and so on until the maximum of six hash characters
266
- for a sixth level heading. You may optionally use any number of hashes at the end of the line to
267
- close the header. Any leading or trailing spaces are stripped from the header text. For example:
268
-
269
- # First level header
270
-
271
- ### Third level header ###
272
-
273
- ## Second level header ######
274
-
275
- > Again, the original Markdown syntax allows one to omit the blank line before an atx style header.
276
- {: .markdown-difference}
277
-
278
-
279
- ### Specifying a Header ID
280
-
281
- kramdown supports a nice way for explicitly setting the header ID which is taken from [PHP Markdown
282
- Extra] and [Maruku]: If you follow the header text with an opening curly bracket (separated from the
283
- text with a least one space), a hash, the ID and a closing curly bracket, the ID is set on the
284
- header. If you use the trailing hash feature of atx style headers, the header ID has to go after the
285
- trailing hashes. For example:
286
-
287
- Hello {#id}
288
- -----
289
-
290
- # Hello {#id}
291
-
292
- # Hello # {#id}
293
-
294
- > This additional syntax is not part of standard Markdown.
295
- {: .markdown-difference}
296
-
297
-
298
- ## Blockquotes
299
-
300
- A blockquote is started using the `>` marker followed by an optional space and the content of the
301
- blockquote. The marker itself may be indented up to three spaces. All following lines, whether they
302
- are started with the blockquote marker or just contain text, belong to the blockquote because
303
- blockquotes support [line wrapping](#line-wrapping).
304
-
305
- The contents of a blockquote are block-level elements. This means that if you are just using text as
306
- content that it will be wrapped in a paragraph. For example, the following gives you one blockquote
307
- with two paragraphs in it:
308
-
309
- > This is a blockquote.
310
- > on multiple lines
311
- that may be lazy.
312
- >
313
- > This is the second paragraph.
314
-
315
- Since the contents of a blockquote are block-level elements, you can nest blockquotes and use other
316
- block-level elements (this is also the reason why blockquotes need to support line wrapping):
317
-
318
- > This is a paragraph.
319
- >
320
- > > A nested blockquote.
321
- >
322
- > ## Headers work
323
- >
324
- > * lists too
325
- >
326
- > and all other block-level elements
327
-
328
- Note that the first space character after the `>` marker does *not* count when counting spaces for
329
- the indentation of the block-level elements inside the blockquote! So [code blocks](#code-blocks)
330
- will have to be indented with five spaces or one space and one tab, like this:
331
-
332
- > A code block:
333
- >
334
- > ruby -e 'puts :works'
335
-
336
- [Line wrapping](#line-wrapping) allows one to be lazy but hinders readability and should therefore
337
- be avoided, especially with blockquotes. Here is an example of using blockquotes with line wrapping:
338
-
339
- > This is a paragraph inside
340
- a blockquote.
341
- >
342
- > > This is a nested paragraph
343
- that continues here
344
- > and here
345
- > > and here
346
-
347
-
348
- ## Code Blocks
349
-
350
- Code blocks can be used to represent verbatim text like markup, HTML or a program fragment because
351
- no syntax is parsed within a code block.
352
-
353
- ### Standard Code Blocks
354
-
355
- A code block can be started by using four spaces or one tab and then the text of the code block. All
356
- following lines containing text, whether they adhere to this syntax or not, belong to the code block
357
- because code blocks support [line wrapping](#line-wrapping)). A wrapped code line is automatically
358
- appended to the preceding code line by substituting the line break with a space character. The
359
- indentation (four spaces or one tab) is stripped from each line of the code block.
360
-
361
- > The original Markdown syntax does not allow line wrapping in code blocks.
362
- {: .markdown-difference}
363
-
364
- Note that consecutive code blocks that are only separate by [blank lines](#blank-lines) are merged
365
- together into one code block:
366
-
367
- Here comes some code
368
-
369
- This text belongs to the same code block.
370
-
371
- If you want to have one code block directly after another one, you need to use an [EOB
372
- marker](#eob-marker) to separate the two:
373
-
374
- Here comes some code
375
- ^
376
- This one is separate.
377
-
378
- ### Fenced Code Blocks
379
-
380
- > This alternative syntax is not part of the original Markdown syntax. The idea and syntax comes
381
- > from the [PHP Markdown Extra] package.
382
- {: .markdown-difference}
383
-
384
- kramdown also supports an alternative syntax for code blocks which does not use indented blocks but
385
- delimiting lines. The starting line needs to begin with three or more tilde characters (`~`) and the
386
- closing line needs to have at least the number of tildes the starting line has. Everything between
387
- is taken literally as with the other syntax but there is no need for indenting the text. For
388
- example:
389
-
390
- ~~~~~~~~
391
- Here comes some code.
392
- ~~~~~~~~
393
-
394
- If you need lines of tildes in such a code block, just start the code block with more tildes. For
395
- example:
396
-
397
- ~~~~~~~~~~~~
398
- ~~~~~~~
399
- code with tildes
400
- ~~~~~~~~
401
- ~~~~~~~~~~~~~~~~~~
402
-
403
- This type of code block is especially useful for copy-pasted code since you don't need to indent the
404
- code.
405
-
406
- ### Language of Code Blocks
407
-
408
- You can tell kramdown the language of a code block by using an [IAL](#inline-attribute-lists):
409
-
410
- ~~~
411
- def what?
412
- 42
413
- end
414
- ~~~
415
- {: .language-ruby}
416
-
417
- The specially named class `language-ruby` tells kramdown that this code block is written in the Ruby
418
- language. Such information can be used, for example, by converters to do syntax highlighting on the
419
- code block.
420
-
421
- Fenced code blocks provide an easier way to specify the language, namely by appending the language
422
- of the code block to the end of the starting line:
423
-
424
- ~~~ ruby
425
- def what?
426
- 42
427
- end
428
- ~~~
429
-
430
-
431
- ## Lists
432
-
433
- kramdown provides syntax elements for creating ordered and unordered lists as well as definition
434
- lists.
435
-
436
- ### Ordered and Unordered lists
437
-
438
- Both ordered and unordered lists follow the same rules.
439
-
440
- A list is started with a list marker (in case of unordered lists one of `+`, `-` or `*` -- you can
441
- mix them -- and in case of ordered lists a number followed by a period) followed by one tab or at
442
- least one space, optionally followed by an [IAL](#inline-attribute-lists) that should be applied to
443
- the list item and then the first part of the content of the list item. The leading tabs or spaces
444
- are stripped away from this first line of content to allow for a nice alignment with the following
445
- content of a list item (see below). All following list items with the same marker type (unordered or
446
- ordered) are put into the same list. The numbers used for ordered lists are irrelevant, an ordered
447
- list always starts at 1.
448
-
449
- The following gives you an unordered list and an ordered list:
450
-
451
- * kram
452
- + down
453
- - now
454
-
455
- 1. kram
456
- 2. down
457
- 3. now
458
-
459
- > The original Markdown syntax allows the markers of ordered and unordered lists to be mixed, the
460
- > first marker specifying the list type (ordered or unordered). This is not allowed in kramdown. As
461
- > stated, the above example will give you two lists (an unordered and an ordered) in kramdown and
462
- > only one unordered list in Markdown.
463
- {: .markdown-difference}
464
-
465
- The first list marker in a list may be indented up to three spaces. The column number of the first
466
- non-space character which appears after the list item marker on the same line specifies the
467
- indentation that has to be used for the following lines of content of the list item. If there is no
468
- such character, the indentation that needs to be used is four spaces or one tab. Indented lines may
469
- be followed by lines containing text with any amount of indentation due to [line
470
- wrapping](#line-wrapping). Note, however, that in addition to the rules outlined in the section
471
- about line wrapping, a list item also ends when a line with another list item marker is encountered
472
- -- see the next paragraph.
473
-
474
- The indentation is stripped from the content and the content (note that the content naturally also
475
- contains the content of the line with the item marker) is processed as text containing block-level
476
- elements. All other list markers in the list may be indented up to three spaces or the number of
477
- spaces used for the indentation of the last list item minus one, whichever number is smaller. For
478
- example:
479
-
480
- * This is the first line. Since the first non-space characters appears in
481
- column 3, all other indented lines have to be indented 2 spaces.
482
- However, one could be lazy and not indent a line but this is not
483
- recommended.
484
- * This is the another item of the list. It uses a different number
485
- of spaces for indentation which is okay but should generally be avoided.
486
- * The list item marker is indented 3 spaces which is allowed but should
487
- also be avoided and starts the third list item. Note that the lazy
488
- line in the second list item may make you believe that this is a
489
- sub-list which it isn't! So avoid being lazy!
490
-
491
- So, while the above is possible and creates one list with three items, it is not advised to use
492
- different (marker and list content) indents for same level list items as well as lazy indentation!
493
- It is much better to write such a list in the following way:
494
-
495
- * This is the first list item bla blabla blabla blabla blabla blabla
496
- blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
497
- blabla blabla blabla bla
498
- * This is the another item of the list. bla blabla blabla blabla blabla
499
- blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
500
-
501
- > The original Markdown syntax also allows you to indent the marker, however, the behaviour of what
502
- > happens with the list items is not clearly specified and may surprise you.
503
- >
504
- > Also, Markdown uses a fixed number of spaces/tabs to indent the lines that belong to a list item!
505
- {: .markdown-difference}
506
-
507
- Unordered and ordered lists work the same way in regard to the indentation:
508
-
509
- * list 1 item 1
510
- * list 1 item 2 (indent 1 space)
511
- * list 1 item 3 (indent 2 spaces)
512
- * list 1 item 4 (indent 3 spaces)
513
- * lazy text belonging to above item 4
514
-
515
- ^
516
-
517
- 1. list 1 item 1
518
- 2. list 1 item 2 (indent 1 space)
519
- 3. list 1 item 3 (indent 2 spaces)
520
- 4. list 1 item 4 (indent 3 spaces)
521
- 5. lazy text belonging to above item 4
522
-
523
- ^
524
-
525
- * list 1 item 1
526
- * nested list item 1
527
- * nested list item 2
528
- * list 1 item 2
529
- * nested list item 1
530
-
531
- ^
532
-
533
- 1. list 1 item 1
534
- 1. nested list item 1
535
- 2. nested list item 2
536
- 10. list 1 item 2
537
- 1. nested list item 1
538
-
539
- ^
540
-
541
- 1. text for this list item
542
- further text (indent 3 spaces)
543
-
544
- 10. text for this list item
545
- further text (indent 4 spaces)
546
-
547
- When using tabs for indenting the content of a list item, remember that tab stops occur at multiples
548
- of four for kramdown. Tabs are correctly converted to spaces for calculating the indentation. For
549
- example:
550
-
551
- * Using a tab to indent this line, the tab only counts as three spaces
552
- and therefore the overall indentation is four spaces.
553
-
554
- 1. The tab after the marker counts here as three spaces. Since the
555
- indentation of the marker is three spaces and the marker itself
556
- takes two characters, the overall indentation needed for the
557
- following lines is eight spaces or two tabs.
558
-
559
- It is clear that you might get unexpected results if you mix tabs and spaces or if you don't have
560
- the tab stops set to multiples of four in your editor! Therefore this should be avoided!
561
-
562
- The content of a list item is made up of either text or block-level elements. Simple list items only
563
- contain text like in the above examples. They are not even wrapped in a paragraph tag. If the first
564
- list text is followed by one or more blank lines, it will be wrapped in a paragraph tag:
565
-
566
- * kram
567
-
568
- * down
569
- * now
570
-
571
- In the above example, the first list item text will be wrapped in a paragraph tag since it is
572
- followed by a blank line whereas the second list item contains just text. There is obviously a
573
- problem for doing this with the last list item when it contains only text. You can circumvent this
574
- by leaving a blank line after the last list item and using an EOB marker:
575
-
576
- * Not wrapped in a paragraph
577
- * Wrapped in a paragraph due to the following blank line.
578
-
579
- * Also wrapped in a paragraph due to the
580
- following blank line and the EOB marker.
581
-
582
- ^
583
-
584
- The text of the last list item is also wrapped in a paragraph tag if *all* other list items contain
585
- a proper paragraph as first element. This makes the following use case work like expected, i.e.
586
- *all* the list items are wrapped in paragraphs:
587
-
588
- * First list item
589
-
590
- * Second list item
591
-
592
- * Last list item
593
-
594
- > The original Markdown syntax page specifies that list items which are separated by one or more
595
- > blank lines are wrapped in paragraph tags. This means that the first text will also be wrapped in
596
- > a paragraph if you have block-level elements in a list which are separated by blank lines. The
597
- > above rule is easy to remember and lets you exactly specify when the first list text should be
598
- > wrapped in a paragraph. The idea for the above rule comes from the [Pandoc] package.
599
- {: .markdown-difference}
600
-
601
- As seen in the examples above, blank lines between list items are allowed.
602
-
603
- Since the content of a list item can contain block-level elements, you can do the following:
604
-
605
- * First item
606
-
607
- A second paragraph
608
-
609
- * nested list
610
-
611
- > blockquote
612
-
613
- * Second item
614
-
615
- However, there is a problem when you want to have a code block immediately after a list item. You
616
- can use an EOB marker to circumvent this problem:
617
-
618
- * This is a list item.
619
-
620
- The second para of the list item.
621
- ^
622
- A code block following the list item.
623
-
624
- You can have any block-level element as first element in a list item. However, as described above,
625
- the leading tabs or spaces of the line with the list item marker are stripped away. This leads to a
626
- problem when you want to have a code block as first element. The solution to this problem is the
627
- following construct:
628
-
629
- *
630
- This is a code block (indentation needs to be 4(1)+4(1)
631
- spaces (tabs)).
632
- {: .show-whitespaces .ws-lr}
633
-
634
- Note that the list marker needs to be followed with at least one space or tab! Otherwise the line is
635
- not recognized as the start of a list item but interpreted as a paragraph containing the list
636
- marker.
637
-
638
- If you want to have one list directly after another one (both with the same list type, i.e. ordered
639
- or unordered), you need to use an EOB marker to separate the two:
640
-
641
- * List one
642
- ^
643
- * List two
644
-
645
- Since paragraphs support [line wrapping](#line-wrapping), it would usually not be possible to create
646
- compact nested list, i.e. a list where the text is not wrapped in paragraphs because there is no
647
- blank line but a sub list after it:
648
-
649
- * This is just text.
650
- * this is a sub list item
651
- * this is a sub sub list item
652
- * This is just text,
653
- spanning two lines
654
- * this is a nested list item.
655
-
656
- However, this is an often used syntax and is therefore support by kramdown.
657
-
658
- If you want to start a paragraph with something that looks like a list item marker, you need to
659
- escape it. This is done by escaping the period in an ordered list or the list item marker in an
660
- unordered list:
661
-
662
- 1984\. It was great
663
- \- others say that, too!
664
-
665
- As mentioned at the beginning, an optional IAL for applying attributes to a list item can be used
666
- after the list item marker:
667
-
668
- * {:.cls} This item has the class "cls".
669
- Here continues the above paragraph.
670
-
671
- * This is a normal list item.
672
-
673
-
674
- ### Definition Lists
675
-
676
- > This syntax feature is not part of the original Markdown syntax. The idea and syntax comes from
677
- > the [PHP Markdown Extra] package.
678
- {: .markdown-difference}
679
-
680
- Definition lists allow you to assign one or more definitions to one or more terms.
681
-
682
- A definition list is started when a normal paragraph is followed by a line with a definition marker
683
- (a colon which may be optionally indented up to three spaces), then at least one tab or one space,
684
- optionally followed by an [IAL](#inline-attribute-lists) that should be applied to the list item and
685
- then the first part of the definition. The line with the definition marker may optionally be
686
- separated from the preceding paragraph by a blank line. The leading tabs or spaces are stripped away
687
- from this first line of the definition to allow for a nice alignment with the following definition
688
- content. Each line of the preceding paragraph is taken to be a term and the lines separately parsed
689
- as span-level elements. Each such term may optionally start with an [IAL](#inline-attribute-lists)
690
- that should be applied to the term.
691
-
692
- The following is a simple definition list:
693
-
694
- kramdown
695
- : A Markdown-superset converter
696
-
697
- Maruku
698
- : Another Markdown-superset converter
699
-
700
- The column number of the first non-space character which appears after a definition marker on the
701
- same line specifies the indentation that has to be used for the following lines of the definition.
702
- If there is no such character, the indentation that needs to be used is four spaces or one tab.
703
- Indented lines may be followed by lines containing text with any amount of indentation due to [line
704
- wrapping](#line-wrapping). Note, however, that in addition to the rules outlined in the section
705
- about line wrapping, a list item also ends when a line with another definition marker is encountered.
706
-
707
- The indentation is stripped from the definition and it (note that the definition naturally also
708
- contains the content of the line with the definition marker) is processed as text containing block
709
- level elements. If there is more than one definition, all other definition markers for the term may
710
- be indented up to three spaces or the number of spaces used for the indentation of the last
711
- definition minus one, whichever number is smaller. For example:
712
-
713
- definition term 1
714
- definition term 2
715
- : This is the first line. Since the first non-space characters appears in
716
- column 3, all other lines have to be indented 2 spaces (or lazy syntax may
717
- be used after an indented line). This tells kramdown that the lines
718
- belong to the definition.
719
- : This is the another definition for the same term. It uses a
720
- different number of spaces for indentation which is okay but
721
- should generally be avoided.
722
- : The definition marker is indented 3 spaces which is allowed but
723
- should also be avoided.
724
-
725
- So, while the above is possible and creates a definition list with two terms and three definitions
726
- for them, it is not advised to use different (definition marker and definition) indents in the same
727
- definition list as well as lazy indentation!
728
-
729
- The definition for a term is made up of text and/or block-level elements. If a definition is *not*
730
- preceded by a blank line, the first part of the definition will just be text if it would be a
731
- paragraph otherwise:
732
-
733
- definition term
734
- : This definition will just be text because it would normally be a
735
- paragraph and the there is no preceding blank line.
736
-
737
- > although the definition contains other block-level elements
738
-
739
- : This definition *will* be a paragraph since it is preceded by a
740
- blank line.
741
-
742
- The rules about having any block-level element as first element in a list item also apply to a
743
- definition.
744
-
745
- As mentioned at the beginning, an optional IAL for applying attributes to a term or a definition can
746
- be used:
747
-
748
- {:#term} Term with id="term"
749
- : {:.cls} Definition with class "cls"
750
-
751
- {:#term1} First term
752
- {:#term2} Second term
753
- : {:.cls} Definition
754
-
755
-
756
- ## Tables
757
-
758
- > This syntax feature is not part of the original Markdown syntax. The syntax is based on the one
759
- > from the [PHP Markdown Extra] package.
760
- {: .markdown-difference}
761
-
762
- Sometimes one wants to include simple tabular data in a kramdown document for which using a
763
- full-blown HTML table is just too much. kramdown supports this with a simple syntax for ASCII
764
- tables.
765
-
766
- Tables can be created with or without a leading pipe character: If the first line of a table
767
- contains a pipe character at the start of the line (optionally indented up to three spaces), then
768
- all leading pipe characters (i.e. pipe characters that are only preceded by whitespace) are ignored
769
- on all table lines. Otherwise they are not ignored and count when dividing a table line into table
770
- cells.
771
-
772
- There are four different line types that can be used in a table:
773
-
774
- * *Table rows* define the content of a table.
775
-
776
- A table row is any line that contains at least one pipe character and is not identified as any
777
- other type of table line! The table row is divided into individual table cells by pipe characters.
778
- An optional trailing pipe character is ignored. Note that literal pipe characters need to be
779
- escaped *except* if they occur in code spans or HTML `<code>` elements!
780
-
781
- Header rows, footer rows and normal rows are all done using these table rows. Table cells can only
782
- contain a single line of text, no multi-line text is supported. The text of a table cell is parsed
783
- as span-level elements.
784
-
785
- Here are some example table rows:
786
-
787
- | First cell|Second cell|Third cell
788
- | First | Second | Third |
789
-
790
- First | Second | | Fourth |
791
-
792
- * *Separator lines* are used to split the table body into multiple body parts.
793
-
794
- A separator line is any line that contains only pipes, dashes, pluses, colons and spaces/tabs and
795
- which contains at least one dash and one pipe character. The pipe and plus characters can be used
796
- to visually separate columns although this is not needed. Multiple separator lines after another
797
- are treated as one separator line.
798
-
799
- Here are some example separator lines:
800
-
801
- |----+----|
802
- +----|----+
803
- |---------|
804
- |-
805
- | :-----: |
806
- -|-
807
-
808
- * The first separator line after at least one table row is treated specially, namely as *header
809
- separator line*. It is used to demarcate header rows from normal table rows and/or to set column
810
- alignments. All table rows above the header separator line are considered to be header rows.
811
-
812
- The header separator line can be specially formatted to contain column alignment definitions: An
813
- alignment definition consists of an optional space/tab followed by an optional colon, one or more
814
- dashes, an optional colon and another optional space/tab. The colons of an alignment definition
815
- are used to set the alignment of a column: if there are no colons, the column uses the default
816
- alignment, if there is a colon only before the dashes, the column is left aligned, if there are
817
- colons before and after the dashes, the column is center aligned and if there is only a colon
818
- after the dashes, the column is right aligned. Each alignment definition sets the alignment for
819
- one column, the first alignment definition for the first column, the second alignment definition
820
- for the second column and so on.
821
-
822
- Here are some example header separator lines with alignment definitions:
823
-
824
- |---+---+---|
825
- + :-: |:------| ---:|
826
- | :-: :- -: -
827
- :-: | :-
828
-
829
- * A *footer separator line* is used to demarcate footer rows from normal table rows. All table rows
830
- below the footer separator line are considered to be footer rows.
831
-
832
- A footer separator line is like a normal separator line except that dashes are replaced by equal
833
- signs. A footer separator line may only appear once in a table. If multiple footer separator lines
834
- are used in one table, only the last is treated as footer separator line, all others are treated
835
- as normal separator lines. Normal separator lines that are used after the footer separator line
836
- are ignored.
837
-
838
- Here are some example footer separator lines:
839
-
840
- |====+====|
841
- +====|====+
842
- |=========|
843
- |=
844
-
845
- Trailing spaces or tabs are ignored in all cases. To simplify table creation and maintenance,
846
- header, footer and normal separator lines need not specify the same number of columns as table rows;
847
- even `|-` and `|=` are a valid separators.
848
-
849
- Given the above components, a table is specified by
850
-
851
- * an optional separator line,
852
- * optionally followed by zero, one or more table rows followed by a header separator line,
853
- * one or more table rows, optionally interspersed with separator lines,
854
- * optionally followed by a footer separator line and zero, one or more table rows and
855
- * an optional trailing separator line.
856
-
857
- Also note
858
-
859
- * that the first line of a table must not have more than three spaces of indentation before the
860
- first non-space character,
861
- * that each line of a table needs to have at least one not escaped pipe character so that kramdown
862
- recognizes it as a line belonging to the table and
863
- * that tables have to start and end on [block boundaries](#block-boundaries)!
864
-
865
- > The table syntax differs from the one used in [PHP Markdown Extra] as follows:
866
- >
867
- > * kramdown tables do not need to have a table header.
868
- > * kramdown tables can be structured using separator lines.
869
- > * kramdown tables can contain a table footer.
870
- > * kramdown tables need to be separated from other block-level elements.
871
- {: .markdown-difference}
872
-
873
- Here is an example for a kramdown table with a table header row, two table bodies and a table footer
874
- row:
875
-
876
- |-----------------+------------+-----------------+----------------|
877
- | Default aligned |Left aligned| Center aligned | Right aligned |
878
- |-----------------|:-----------|:---------------:|---------------:|
879
- | First body part |Second cell | Third cell | fourth cell |
880
- | Second line |foo | **strong** | baz |
881
- | Third line |quux | baz | bar |
882
- |-----------------+------------+-----------------+----------------|
883
- | Second body | | | |
884
- | 2 line | | | |
885
- |=================+============+=================+================|
886
- | Footer row | | | |
887
- |-----------------+------------+-----------------+----------------|
888
-
889
- The above example table is rather time-consuming to create without the help of an ASCII table
890
- editor. However, the table syntax is flexible and the above table could also be written like this:
891
-
892
- |---
893
- | Default aligned | Left aligned | Center aligned | Right aligned
894
- |-|:-|:-:|-:
895
- | First body part | Second cell | Third cell | fourth cell
896
- | Second line |foo | **strong** | baz
897
- | Third line |quux | baz | bar
898
- |---
899
- | Second body
900
- | 2 line
901
- |===
902
- | Footer row
903
-
904
-
905
- ## Horizontal Rules
906
-
907
- A horizontal rule for visually separating content is created by using three or more asterisks,
908
- dashes or underscores (these may not be mixed on a line), optionally separated by spaces or tabs, on
909
- an otherwise blank line. The first asterisk, dash or underscore may optionally be indented up to
910
- three spaces. The following examples show different possibilities to create a horizontal rule:
911
-
912
- * * *
913
-
914
- ---
915
-
916
- _ _ _ _
917
-
918
- ---------------
919
-
920
-
921
- ## Math Blocks
922
-
923
- > This syntax feature is not part of the original Markdown syntax. The idea comes from the [Maruku]
924
- > and [Pandoc] packages.
925
- {: .markdown-difference}
926
-
927
- kramdown has built-in support for block and span-level mathematics written in LaTeX.
928
-
929
- A math block needs to start and end on [block boundaries](#block-boundaries). It is started using
930
- two dollar signs, optionally indented up to three spaces. The math block continues until the next
931
- two dollar signs (which may be on the same line or on one of the next lines) that appear at the end
932
- of a line, i.e. they may only be followed by whitespace characters. The content of a math block has
933
- to be valid LaTeX math. It is always wrapped inside a `\begin{displaymath}...\end{displaymath}`
934
- enviroment except if it begins with a `\begin` statement.
935
-
936
- The following kramdown fragment
937
-
938
- $$
939
- \begin{align*}
940
- & \phi(x,y) = \phi \left(\sum_{i=1}^n x_ie_i, \sum_{j=1}^n y_je_j \right)
941
- = \sum_{i=1}^n \sum_{j=1}^n x_i y_j \phi(e_i, e_j) = \\
942
- & (x_1, \ldots, x_n) \left( \begin{array}{ccc}
943
- \phi(e_1, e_1) & \cdots & \phi(e_1, e_n) \\
944
- \vdots & \ddots & \vdots \\
945
- \phi(e_n, e_1) & \cdots & \phi(e_n, e_n)
946
- \end{array} \right)
947
- \left( \begin{array}{c}
948
- y_1 \\
949
- \vdots \\
950
- y_n
951
- \end{array} \right)
952
- \end{align*}
953
- $$
954
-
955
- renders (using Javascript library [MathJax](http://www.mathjax.org/)) as
956
-
957
- $$
958
- \begin{align*}
959
- & \phi(x,y) = \phi \left(\sum_{i=1}^n x_ie_i, \sum_{j=1}^n y_je_j \right)
960
- = \sum_{i=1}^n \sum_{j=1}^n x_i y_j \phi(e_i, e_j) = \\
961
- & (x_1, \ldots, x_n) \left( \begin{array}{ccc}
962
- \phi(e_1, e_1) & \cdots & \phi(e_1, e_n) \\
963
- \vdots & \ddots & \vdots \\
964
- \phi(e_n, e_1) & \cdots & \phi(e_n, e_n)
965
- \end{array} \right)
966
- \left( \begin{array}{c}
967
- y_1 \\
968
- \vdots \\
969
- y_n
970
- \end{array} \right)
971
- \end{align*}
972
- $$
973
-
974
- Using inline math is also easy: just surround your math content with two dollar signs, like with a
975
- math block. If you don't want to start an inline math statement, just escape the dollar signs and
976
- they will be treated as simple dollar signs.
977
-
978
- > **Note** that LaTeX code that uses the pipe symbol `|` in inline math statements may lead to a
979
- > line being recognized as a table line. This problem can be avoided by using the `\vert` command
980
- > instead of `|`!
981
- {:.information}
982
-
983
- If you have a paragraph that looks like a math block but should actually be a paragraph with just an
984
- inline math statement, you need to escape the first dollar sign:
985
-
986
- The following is a math block:
987
-
988
- $$ 5 + 5 $$
989
-
990
- But next comes a paragraph with an inline math statement:
991
-
992
- \$$ 5 + 5 $$
993
-
994
- If you don't even want the inline math statement, escape the first two dollar signs:
995
-
996
- \$\$ 5 + 5 $$
997
-
998
- ## HTML Blocks
999
-
1000
- > The original Markdown syntax specifies that an HTML block must start at the left margin, i.e. no
1001
- > indentation is allowed. Also, the HTML block has to be surrounded by blank lines. Both
1002
- > restrictions are lifted for kramdown documents. Additionally, the original syntax does not allow
1003
- > you to use Markdown syntax in HTML blocks which is allowed with kramdown.
1004
- {: .markdown-difference}
1005
-
1006
- An HTML block is potentially started if a line is encountered that begins with a non-span-level HTML
1007
- tag or a general XML tag (opening or closing) which may be indented up to three spaces.
1008
-
1009
- The following HTML tags count as span-level HTML tags and *won't* start an HTML block if found at
1010
- the beginning of an HTML block line:
1011
-
1012
- a abbr acronym b big bdo br button cite code del dfn em i img input
1013
- ins kbd label option q rb rbc rp rt rtc ruby samp select small span
1014
- strong sub sup textarea tt var
1015
-
1016
- Further parsing of a found start tag depends on the tag and in which of three possible ways its
1017
- content is parsed:
1018
-
1019
- * Parse as raw HTML block: If the HTML/XML tag content should be handled as raw HTML, then only
1020
- HTML/XML tags are parsed from this point onwards and text is handled as raw, unparsed text until
1021
- the matching end tag is found or until the end of the document. Each found tag will be parsed as
1022
- raw HTML again. However, if a tag has a `markdown` attribute, this attribute controls parsing of
1023
- this one tag (see below).
1024
-
1025
- Note that the parser basically supports only correct XHTML! However, there are some exceptions.
1026
- For example, attributes without values (i.e. boolean attributes) are also supported and elements
1027
- without content like `<hr />` can be written as `<hr>`. If an invalid closing tag is found, it is
1028
- ignored.
1029
-
1030
- * Parse as block-level elements: If the HTML/XML tag content should be parsed as text containing
1031
- block-level elements, the remaining text on the line will be parsed by the block-level parser as
1032
- if it appears on a separate line (**Caution**: This also means that if the line consists of the
1033
- start tag, text and the end tag, the end tag will not be found!). All following lines are parsed
1034
- as block-level elements until an HTML block line with the matching end tag is found or until the
1035
- end of the document.
1036
-
1037
- * Parse as span-level elements: If the HTML/XML tag content should be parsed as text containing span
1038
- level elements, then all text until the *next* matching end tag or until the end of the document
1039
- will be the content of the tag and will later be parsed by the span-level parser. This also means
1040
- that if the matching end tag is inside what appears to be a code span, it is still used!
1041
-
1042
- If there is text after an end tag, it will be parsed as if it appears on a separate line except when
1043
- inside a raw HTML block.
1044
-
1045
- Also, if an invalid closing tag is found, it is ignored.
1046
-
1047
- Note that all HTML tag and attribute names are converted to lowercase!
1048
-
1049
- By default, kramdown parses all block HTML tags and all XML tags as raw HTML blocks. However, this
1050
- can be configured with the `parse_block_html`. If this is set to `true`, then syntax parsing in HTML
1051
- blocks is globally enabled. It is also possible to enable/disable syntax parsing on a tag per tag
1052
- basis using the `markdown` attribute:
1053
-
1054
- * If an HTML tag has an attribute `markdown="0"`, then the tag is parsed as raw HTML block.
1055
-
1056
- * If an HTML tag has an attribute `markdown="1"`, then the default mechanism for parsing syntax in
1057
- this tag is used.
1058
-
1059
- * If an HTML tag has an attribute `markdown="block"`, then the content of the tag is parsed as block
1060
- level elements.
1061
-
1062
- * If an HTML tag has an attribute `markdown="span"`, then the content of the tag is parsed as span
1063
- level elements.
1064
-
1065
- The following list shows which HTML tags are parsed in which mode by default when `markdown="1"` is
1066
- applied or `parse_block_html` is `true`:
1067
-
1068
- Parse as raw HTML
1069
- :
1070
- script style math option textarea pre code kbd samp var
1071
-
1072
- Also, all general XML tags are parsed as raw HTML blocks.
1073
-
1074
- Parse as block-level elements
1075
- :
1076
- applet button blockquote body colgroup dd div dl fieldset form iframe li
1077
- map noscript object ol table tbody thead tfoot tr td ul
1078
-
1079
- Parse as span-level elements
1080
- :
1081
- a abbr acronym address b bdo big cite caption code del dfn dt em
1082
- h1 h2 h3 h4 h5 h6 i ins kbd label legend optgroup p pre q rb rbc
1083
- rp rt rtc ruby samp select small span strong sub sup th tt var
1084
-
1085
- > Remember that all span-level HTML tags like `a` or `b` do not start a HTML block! However, the
1086
- > above lists also include span-level HTML tags in the case the `markdown` attribute is used on a
1087
- > tag inside a raw HTML block.
1088
-
1089
- Here is a simple example input and its HTML output with `parse_block_html` set to `false`:
1090
-
1091
- This is a para.
1092
- <div>
1093
- Something in here.
1094
- </div>
1095
- Other para.
1096
- ^
1097
- <p>This is a para.</p>
1098
- <div>
1099
- Something in here.
1100
- </div>
1101
- <p>Other para.</p>
1102
-
1103
- As one can see the content of the `div` tag will be parsed as raw HTML block and left alone.
1104
- However, if the `markdown="1"` attribute was used on the `div` tag, the content would be parsed as
1105
- block-level elements and therefore converted to a paragraph.
1106
-
1107
- You can also use several HTML tags at once:
1108
-
1109
- <div id="content"><div id="layers"><div id="layer1">
1110
- This is some text in the `layer1` div.
1111
- </div>
1112
- This is some text in the `layers` div.
1113
- </div></div>
1114
- This is a para outside the HTML block.
1115
-
1116
- However, remember that if the content of a tag is parsed as block-level elements, the content that
1117
- appears after a start/end tag but on the same line, is processed as if it appears on a new line:
1118
-
1119
- <div markdown="1">This is the first part of a para,
1120
- which is continued here.
1121
- </div>
1122
-
1123
- <p markdown="1">This works without problems because it is parsed as
1124
- span-level elements</p>
1125
-
1126
- <div markdown="1">The end tag is not found because
1127
- this line is parsed as a paragraph</div>
1128
-
1129
- Since setting `parse_block_html` to `true` can lead to some not wanted behaviour, it is generally
1130
- better to selectively enable or disable block/span-level elements parsing by using the `markdown`
1131
- attribute!
1132
-
1133
- Unclosed block-level HTML tags are correctly closed at the end of the document to ensure correct
1134
- nesting and invalidly used end tags are removed from the output:
1135
-
1136
- This is a para.
1137
- <div markdown="1">
1138
- Another para.
1139
- </p>
1140
- ^
1141
- <p>This is a para.</p>
1142
- <div>
1143
- <p>Another para.</p>
1144
- </div>
1145
-
1146
- The parsing of processing instructions and XML comments is also supported. The content of both, PIs
1147
- and XML comments, may span multiple lines. The start of a PI/XML comment may only appear at the
1148
- beginning of a line, optionally indented up to three spaces. If there is text after the end of a PI
1149
- or XML comment, it will be parsed as if it appears on a separate line. kramdown syntax in PIs/XML
1150
- comments is not processed:
1151
-
1152
- This is a para.
1153
- <!-- a *comment* -->
1154
- <? a processing `instruction`
1155
- spanning multiple lines
1156
- ?> First part of para,
1157
- continues here.
1158
-
1159
-
1160
-
1161
- # Text Markup
1162
-
1163
- These elements are all span-level elements and used inside block-level elements to markup text
1164
- fragments. For example, one can easily create links or apply emphasis to certain text parts.
1165
-
1166
- Note that empty span-level elements are not converted to empty HTML tags but are copied as-is to the
1167
- output.
1168
-
1169
-
1170
-
1171
- ## Links and Images
1172
-
1173
- Three types of links are supported: automatic links, inline links and reference links.
1174
-
1175
- ### Automatic Links
1176
-
1177
- This is the easiest one to create: Just surround a web address or an email address with angle
1178
- brackets and the address will be turned into a proper link. The address will be used as link target
1179
- and as link text. For example:
1180
-
1181
- Information can be found on the <http://example.com> homepage.
1182
- You can also mail me: <me.example@example.com>
1183
-
1184
- It is not possible to specify a different link text using automatic links -- use the other link
1185
- types for this!
1186
-
1187
-
1188
- ### Inline Links
1189
-
1190
- As the wording suggests, inline links provide all information inline in the text flow. Reference
1191
- style links only provide the link text in the text flow and everything else is defined
1192
- elsewhere. This also allows you to reuse link definitions.
1193
-
1194
- An inline style link can be created by surrounding the link text with square brackets, followed
1195
- immediately by the link URL (and an optional title in single or double quotes preceded by at least
1196
- one space) in normal parentheses. For example:
1197
-
1198
- This is [a link](http://rubyforge.org) to a page.
1199
- A [link](../test "local URI") can also have a title.
1200
- And [spaces](link with spaces.html)!
1201
-
1202
- Notes:
1203
-
1204
- * The link text is treated like normal span-level text and therefore is parsed and converted.
1205
- However, if you use square brackets within the link text, you have to either properly nest them or
1206
- to escape them. It is not possible to create nested links!
1207
-
1208
- The link text may also be omitted, e.g. for creating link anchors.
1209
-
1210
- * The link URL has to contain properly nested parentheses if no title is specified, or the link URL
1211
- must be contained in angle brackets (incorrectly nested parentheses are allowed).
1212
-
1213
- * The link title may not contain its delimiters and may not be empty.
1214
-
1215
- * Additional link attributes can be added by using a [span IAL](#span-ials) after the inline link,
1216
- for example:
1217
-
1218
- This is a [link](http://example.com){:hreflang="de"}
1219
-
1220
- ### Reference Links
1221
-
1222
- To create a reference style link, you need to surround the link text with square brackets (as with
1223
- inline links), followed by optional spaces/tabs/line breaks and then optionally followed with
1224
- another set of square brackets with the link identifier in them. A link identifier may not contain a
1225
- closing bracket and, when specified in a link definition, newline characters; it is also not case
1226
- sensitive, line breaks and tabs are converted to spaces and multiple spaces are compressed into one.
1227
- For example:
1228
-
1229
- This is a [reference style link][linkid] to a page. And [this]
1230
- [linkid] is also a link. As is [this][] and [THIS].
1231
-
1232
- If you don't specify a link identifier (i.e. only use empty square brackets) or completely omit the
1233
- second pair of square brackets, the link text is converted to a valid link identifier by removing
1234
- all invalid characters and inserting spaces for line breaks. If there is a link definition found for
1235
- the link identifier, a link will be created. Otherwise the text is not converted to a link.
1236
-
1237
- As with inline links, additional link attributes can be added by using a [span IAL](#span-ials)
1238
- after the reference link.
1239
-
1240
- ### Link Definitions
1241
-
1242
- The link definition can be put anywhere in the document. It does not appear in the output. A link
1243
- definition looks like this:
1244
-
1245
- [linkid]: http://www.example.com/ "Optional Title"
1246
-
1247
- > Link definitions are, despite being described here, non-content block-level elements.
1248
- {: .information}
1249
-
1250
- The link definition has the following structure:
1251
-
1252
- * The link identifier in square brackets, optionally indented up to three spaces,
1253
- * then a colon and one or more optional spaces/tabs,
1254
- * then the link URL which must contain at least one non-space character, or a left angle bracket,
1255
- the link URL and a right angle bracket,
1256
- * then optionally the title in single or double quotes, separated from the link URL by one or more
1257
- spaces or on the next line by itself indented any number of spaces/tabs.
1258
-
1259
- > The original Markdown syntax also allowed the title to be specified in parenthesis. This is not
1260
- > allowed for consistency with the inline title.
1261
- {: .markdown-difference}
1262
-
1263
- If you have some text that looks like a link definition but should really be a link and some text,
1264
- you can escape the colon after the link identifier:
1265
-
1266
- The next paragraph contains a link and some text.
1267
-
1268
- [Room 100]\: There you should find everything you need!
1269
-
1270
- [Room 100]: link_to_room_100.html
1271
-
1272
- Although link definitions are non-content block-level elements, [block IALs](#block-ials) can be
1273
- used on them to specify additional attributes for the links:
1274
-
1275
- [linkid]: http://example.com
1276
- {:hreflang="de"}
1277
-
1278
- ### Images
1279
-
1280
- Images can be specified via a syntax that is similar to the one used by links. The difference is
1281
- that you have to use an exclamation mark before the first square bracket and that the link text of a
1282
- normal link becomes the alternative text of the image link. As with normal links, image links can be
1283
- written inline or reference style. For example:
1284
-
1285
- Here comes a ![smiley](../images/smiley.png)! And here
1286
- ![too](../images/other.png 'Title text'). Or ![here].
1287
- With empty alt text ![](see.jpg)
1288
-
1289
- The link definition for images is exactly the same as the link definition for normal links. Since
1290
- additional attributes can be added via span and block IALs, it is possible, for example, to specify
1291
- image width and height:
1292
-
1293
- Here is an inline ![smiley](smiley.png){:height="36px" width="36px"}.
1294
-
1295
- And here is a referenced ![smile]
1296
-
1297
- [smile]: smile.png
1298
- {: height="36px" width="36px"}
1299
-
1300
- ## Emphasis
1301
-
1302
- kramdown supports two types of emphasis: light and strong emphasis. Text parts that are surrounded
1303
- with single asterisks `*` or underscores `_` are treated as text with light emphasis, text parts
1304
- surrounded with two asterisks or underscores are treated as text with strong emphasis. Surrounded
1305
- means that the starting delimiter must not be followed by a space and that the stopping delimiter
1306
- must not be preceded by a space.
1307
-
1308
- Here is an example for text with light and strong emphasis:
1309
-
1310
- *some text*
1311
- _some text_
1312
- **some text**
1313
- __some text__
1314
-
1315
- The asterisk form is also allowed within a single word:
1316
-
1317
- This is un*believe*able! This d_oe_s not work!
1318
-
1319
- Text can be marked up with both light and strong emphasis, possibly using different delimiters.
1320
- However, it is not possible to nest strong within strong or light within light emphasized text:
1321
-
1322
- This is a ***text with light and strong emphasis***.
1323
- This **is _emphasized_ as well**.
1324
- This *does _not_ work*.
1325
- This **does __not__ work either**.
1326
-
1327
- If one or two asterisks or underscores are surrounded by spaces, they are treated literally. If you
1328
- want to force the literal meaning of an asterisk or an underscore you can backslash-escape it:
1329
-
1330
- This is a * literal asterisk.
1331
- These are ** two literal asterisk.
1332
- As \*are\* these!
1333
-
1334
-
1335
- ## Code Spans
1336
-
1337
- This is the span-level equivalent of the [code block](#code-blocks) element. You can markup a text
1338
- part as code span by surrounding it with backticks `` ` ``. For example:
1339
-
1340
- Use `<html>` tags for this.
1341
-
1342
- Note that all special characters in a code span are treated correctly. For example, when a code span
1343
- is converted to HTML, the characters `<`, `>` and `&` are substituted by their respective HTML
1344
- counterparts.
1345
-
1346
- To include a literal backtick in a code span, you need to use two or more backticks as delimiters.
1347
- You can insert one optional space after the starting and before the ending delimiter (these spaces
1348
- are not used in the output). For example:
1349
-
1350
- Here is a literal `` ` `` backtick.
1351
- And here is `` `some` `` text (note the two spaces so that one is left
1352
- in the output!).
1353
-
1354
- A single backtick surrounded by spaces is treated as literal backtick. If you want to force the
1355
- literal meaning of a backtick you can backslash-escape it:
1356
-
1357
- This is a ` literal backtick.
1358
- As \`are\` these!
1359
-
1360
- As with [code blocks](#language-of-code-blocks) you can set the language of a code span by using an
1361
- [IAL](#inline-attribute-lists):
1362
-
1363
- This is a Ruby code fragment `x = Class.new`{:.language-ruby}
1364
-
1365
-
1366
- ## HTML Spans
1367
-
1368
- HTML tags cannot only be used on the block-level but also on the span-level. Span-level HTML tags
1369
- can only be used inside one block-level element, it is not possible to use a start tag in one block
1370
- level element and the end tag in another. Note that only correct XHTML is supported! This means that
1371
- you have to use, for example, `<br />` instead of `<br>` (although kramdown tries to fix such errors
1372
- if possible).
1373
-
1374
- By default, kramdown parses kramdown syntax inside span HTML tags. However, this behaviour can be
1375
- configured with the `parse_span_html` option. If this is set to `true`, then syntax parsing in HTML
1376
- spans is enabled, if it is set to `false`, parsing is disabled. It is also possible to
1377
- enable/disable syntax parsing on a tag per tag basis using the `markdown` attribute:
1378
-
1379
- * If an HTML tag has an attribute `markdown="0"`, then no parsing (except parsing of HTML span tags)
1380
- is done inside that HTML tag.
1381
-
1382
- * If an HTML tag has an attribute `markdown="1"`, then the content of the tag is parsed as span
1383
- level elements.
1384
-
1385
- * If an HTML tag has an attribute `markdown="block"`, then a warning is issued because HTML spans
1386
- cannot contain block-level elements and the attribute is ignored.
1387
-
1388
- * If an HTML tag has an attribute `markdown="span"`, then the content of the tag is parsed as span
1389
- level elements.
1390
-
1391
- The content of a span-level HTML tag is normally parsed as span-level elements. Note, however, that
1392
- some tags like `<script>` are not parsed, i.e. their content is not modified.
1393
-
1394
- Processing instructions and XML comments can also be used (their content is not parsed). However, as
1395
- with HTML tags the start and the end have to appear in the same block-level element.
1396
-
1397
- Span-level PIs and span-level XML comments as well as general span-level HTML and XML tags have to
1398
- be preceded by at least one non whitespace character on the same line so that kramdown correctly
1399
- recognizes them as span-level element and not as block-level element. However, all span HTML tags,
1400
- i.e. `a`, `em`, `b`, ..., (opening or closing) can appear at the start of a line.
1401
-
1402
- Unclosed span-level HTML tags are correctly closed at the end of the span-level text to ensure
1403
- correct nesting and invalidly used end tags or block HTML tags are removed from the output:
1404
-
1405
- This is </invalid>.
1406
-
1407
- This <span>is automatically closed.
1408
- ^
1409
- <p>This is .</p>
1410
-
1411
- <p>This <span>is automatically closed.</span></p>
1412
-
1413
- Also note that one or more consecutive new line characters in an HTML span tag are replaced by a
1414
- single space, for example:
1415
-
1416
- Link: <a href="some
1417
- link">text</a>
1418
- ^
1419
- <p>Link: <a href="some link">text</a></p>
1420
-
1421
-
1422
- ## Footnotes
1423
-
1424
- > This syntax feature is not part of the original Markdown syntax. The idea and syntax comes from
1425
- > the [PHP Markdown Extra] package.
1426
- {: .markdown-difference}
1427
-
1428
- Footnotes in kramdown are similar to reference style links and link definitions. You need to place
1429
- the footnote marker in the correct position in the text and the actual footnote content can be
1430
- defined anywhere in the document.
1431
-
1432
- More exactly, a footnote marker can be created by placing the footnote name in square brackets.
1433
- The footnote name has to start with a caret (`^`), followed by a word character or a digit and then
1434
- optionally followed by other word characters, digits or dashes. For example:
1435
-
1436
- This is some text.[^1]. Other text.[^footnote].
1437
-
1438
- > Note that footnote markers cannot be used as part of the link text of a link because this would
1439
- > lead to nested links which is not allowed in HTML.
1440
- {: .information}
1441
-
1442
- Footnote markers with the same name will link to the same footnote definition. The actual naming of
1443
- a footnote does not matter since the numbering of footnotes is controlled via the position of the
1444
- footnote markers in the document (the first found footnote marker will get the number 1, the second
1445
- new footnote marker the number 2 and so on). If there is a footnote definition found for the
1446
- identifier, a footnote will be created. Otherwise the footnote marker is not converted to a footnote
1447
- link. Also note that all attributes set via a span IAL are ignored for a footnote marker!
1448
-
1449
- A footnote definition is used to define the content of a footnote and has the following structure:
1450
-
1451
- * The footnote name in square brackets, optionally indented up to three spaces,
1452
- * then a colon and one or more optional spaces,
1453
- * then the text of the footnote
1454
- * and optionally more text on the following lines which have to follow the syntax for [standard code
1455
- blocks](#standard-code-blocks) (the leading four spaces/one tab are naturally stripped from the
1456
- text)
1457
-
1458
- > Footnote definitions are, despite being described here, non-content block-level elements.
1459
- {: .information}
1460
-
1461
- The whole footnote content is treated like block-level text and can therefore contain any valid
1462
- block-level element (also, any block-level element can be the first element). If you want to have a
1463
- code block as first element, note that all leading spaces/tabs on the first line are stripped away.
1464
- Here are some example footnote definitions:
1465
-
1466
- [^1]: Some *crazy* footnote definition.
1467
-
1468
- [^footnote]:
1469
- > Blockquotes can be in a footnote.
1470
-
1471
- as well as code blocks
1472
-
1473
- or, naturally, simple paragraphs.
1474
-
1475
- [^other-note]: no code block here (spaces are stripped away)
1476
-
1477
- [^codeblock-note]:
1478
- this is now a code block (8 spaces indentation)
1479
-
1480
- It does not matter where you put a footnote definition in a kramdown document; the content of all
1481
- referenced footnote definitions will be placed at the end of the kramdown document. Not referenced
1482
- footnote definitions are ignored. If more than one footnote definitions have the same footnote name,
1483
- all footnote definitions but the last are ignored.
1484
-
1485
- Although footnote definitions are non-content block-level elements, [block IALs](#block-ials) can be
1486
- used on them to attach attributes. How these attributes are used depends on the converter.
1487
-
1488
- ## Abbreviations
1489
-
1490
- > This syntax feature is not part of the original Markdown syntax. The idea and syntax comes from
1491
- > the [PHP Markdown Extra] package.
1492
- {: .markdown-difference}
1493
-
1494
- kramdown provides a syntax to assign the full phrase to an abbreviation. When writing the text, you
1495
- don't need to do anything special. However, once you add abbreviation definitions, the
1496
- abbreviations in the text get marked up automatically. Abbreviations can consist of any character
1497
- except a closing bracket.
1498
-
1499
- An abbreviation definition is used to define the full phrase for an abbreviation and has the
1500
- following structure:
1501
-
1502
- * An asterisk and the abbreviation in square brackets, optionally indented up to three
1503
- spaces,
1504
- * then a colon and the full phrase of the abbreviation on one line (leading and trailing spaces are
1505
- stripped from the full phrase).
1506
-
1507
- Later abbreviation definitions for the same abbreviation override prior ones and it does not matter
1508
- where you put an abbreviation definition in a kramdown document. Empty definitions are also allowed.
1509
-
1510
- Although abbreviation definitions are non-content block-level elements, [block IALs](#block-ials)
1511
- can be used on them to specify additional attributes.
1512
-
1513
- Here are some examples:
1514
-
1515
- This is some text not written in HTML but in another language!
1516
-
1517
- *[another language]: It's called Markdown
1518
-
1519
- *[HTML]: HyperTextMarkupLanguage
1520
- {:.mega-big}
1521
-
1522
- > Abbreviation definitions are, despite being described here, non-content block-level elements.
1523
- {: .information}
1524
-
1525
-
1526
- ## Typographic Symbols
1527
-
1528
- > The original Markdown syntax does not support these transformations.
1529
- {: .markdown-difference}
1530
-
1531
- kramdown converts the following plain ASCII character into their corresponding typographic symbols:
1532
-
1533
- * `---` will become an em-dash (like this ---)
1534
- * `--` will become an en-dash (like this --)
1535
- * `...` will become an ellipsis (like this ...)
1536
- * `<<` will become a left guillemet (like this <<) -- an optional following space will become a
1537
- non-breakable space
1538
- * `>>` will become a right guillemet (like this >>) -- an optional leading space will become a
1539
- non-breakable space
1540
-
1541
- The parser also replaces normal single `'` and double quotes `"` with "fancy quotes". There *may* be
1542
- times when kramdown falsely replace the quotes. If this is the case, just \'escape\" the quotes and
1543
- they won't be replaced with fancy ones.
1544
-
1545
-
1546
-
1547
- # Non-content elements
1548
-
1549
- This section describes the non-content elements that are used in kramdown documents, i.e. elements
1550
- that don't provide content for the document but have other uses such as separating block-level
1551
- elements or attaching attributes to elements.
1552
-
1553
- Three non-content block-level elements are not described here because they fit better where they
1554
- are:
1555
-
1556
- * [link definitions](#link-definitions)
1557
- * [footnote definitions](#footnotes)
1558
- * [abbreviation definition](#abbreviations)
1559
-
1560
-
1561
- ## End-Of-Block Marker {#eob-marker}
1562
-
1563
- > The EOB marker is not part of the standard Markdown syntax.
1564
- {: .markdown-difference}
1565
-
1566
- The End-Of-Block (EOB) marker -- a `^` as first character on an otherwise empty line -- is a block
1567
- level element that can be used to specify the end of a block-level element even if the block-level
1568
- element, after which it is used, would continue otherwise. If there is no block-level element to
1569
- end, the EOB marker is simply ignored.
1570
-
1571
- You won't find an EOB marker in most kramdown documents but sometimes it is necessary to use it to
1572
- achieve the wanted results which would be impossible otherwise. However, it should only be used when
1573
- absolutely necessary!
1574
-
1575
- For example, the following gives you one list with two items:
1576
-
1577
- * list item one
1578
-
1579
- * list item two
1580
-
1581
- By using an EOB marker, you can make two lists with one item each:
1582
-
1583
- * list one
1584
- ^
1585
- * list two
1586
-
1587
-
1588
- ## Attribute List Definitions
1589
-
1590
- > This syntax feature is not part of the original Markdown syntax. The idea and syntax comes from
1591
- > the [Maruku] package.
1592
- {: .markdown-difference}
1593
-
1594
- This is an implementation of [Maruku]'s feature for adding attributes to block and span-level
1595
- elements (the naming is also taken from Maruku). This block-level element is used to define
1596
- attributes which can be referenced later. The [Block Inline Attribute List](#block-ials) is used to
1597
- attach attributes to a block-level element and the [Span Inline Attribute List](#span-ials) is used
1598
- to attach attributes to a span-level element.
1599
-
1600
- Following are some examples of attribute list definitions (ALDs) and afterwards comes the syntax
1601
- explanation:
1602
-
1603
- {:ref-name: #myid .my-class}
1604
- {:other: ref-name #id-of-other title="hallo you"}
1605
- {:test: key="value \" with quote" and other='quote brace \}'}
1606
-
1607
- An ALD line has the following structure:
1608
-
1609
- * a left brace, optionally preceded by up to three spaces,
1610
- * followed by a colon, the reference name and another colon,
1611
- * followed by attribute definitions (allowed characters are backslash-escaped closing braces or any
1612
- character except a not escaped closing brace),
1613
- * followed by a closing brace and optional spaces until the end of the line.
1614
-
1615
- The reference name needs to start with a word character or a digit, optionally followed by other
1616
- word characters, digits or dashes.
1617
-
1618
- There are four different types of attribute definitions which have to be separated by one or more
1619
- spaces:
1620
-
1621
- references
1622
-
1623
- : This must be a valid reference name. It is used to reference an other ALD so that the attributes
1624
- of the other ALD are also included in this one. The reference name is ignored when collecting the
1625
- attributes if no attribute definition list with this reference name exists. For example, a simple
1626
- reference looks like `id`.
1627
-
1628
- key-value pairs
1629
-
1630
- : A key-value pair is defined by a key name, which must follow the rules for reference names, then
1631
- an equal sign and then the value in single or double quotes. If you need to use the value
1632
- delimiter (a single or a double quote) inside the value, you need to escape it with a backslash.
1633
- Key-value pairs can be used to specify arbitrary attributes for block or span-level elements. For
1634
- example, a key-value pair looks like `key1="bef \"quoted\" aft"` or `title='This is a title'`.
1635
-
1636
- ID name
1637
-
1638
- : An ID name is defined by using a hash and then the identifier name which needs to start with an
1639
- ASCII alphabetic character (A-Z or a-z), optionally followed by other ASCII characters, digits,
1640
- dashes or colons. This is a short hand for the key-value pair `id="IDNAME"` since this is often
1641
- used. The ID name specifies the unique ID of a block or span-level element. For example, an ID
1642
- name looks like `#myid`.
1643
-
1644
- class names
1645
-
1646
- : A class name is defined by using a dot and then the class name which may contain any character
1647
- except whitespace, the dot character and the hash character.
1648
-
1649
- This is (almost, but not quite) a short hand for the key-value pair `class="class-name"`. Almost
1650
- because it actually means that the class name should be appended to the current value of the
1651
- `class` attribute. The following ALDs are all equivalent:
1652
-
1653
- {:id: .cls1 .cls2}
1654
- {:id: class="cls1" .cls2}
1655
- {:id: class="something" class="cls1" .cls2}
1656
- {:id: class="cls1 cls2"}
1657
-
1658
- As can be seen from the example of the class names, attributes that are defined earlier are
1659
- overwritten by ones with the same name defined later.
1660
-
1661
- > Also, everything in the attribute definitions part that does not match one of the above four types
1662
- > is ignored.
1663
- {:.information}
1664
-
1665
- If there is more than one ALD with the same reference name, the attribute definitions of all the
1666
- ALDs are processed like they are defined in one ALD.
1667
-
1668
-
1669
- ## Inline Attribute Lists
1670
-
1671
- These elements are used to attach attributes to another element.
1672
-
1673
- ### Block Inline Attribute Lists {#block-ials}
1674
-
1675
- > This syntax feature is not part of the original Markdown syntax. The idea and syntax comes from
1676
- > the [Maruku] package.
1677
- {: .markdown-difference}
1678
-
1679
- This block-level element is used to attach attributes to another block-level element. A block inline
1680
- attribute list (block IAL) has the same structure as an [ALD](#attribute-list-definitions) except
1681
- that the colon/reference name/colon part is replaced by a colon. A block IAL (or two or more block
1682
- IALs) has to be put directly before or after the block-level element to which the attributes should
1683
- be attached. If a block IAL is directly after *and* before a block-level element, it is applied to
1684
- preceding element. The block IAL is ignored in all other cases, for example, when the block IAL is
1685
- surrounded by blank lines.
1686
-
1687
- Key-value pairs of an IAL take precedence over equally named key-value pairs in referenced ALDs.
1688
-
1689
- Here are some examples for block IALs:
1690
-
1691
- A simple paragraph with an ID attribute.
1692
- {: #para-one}
1693
-
1694
- > A blockquote with a title
1695
- {:title="The blockquote title"}
1696
- {: #myid}
1697
-
1698
- {:.ruby}
1699
- Some code here
1700
-
1701
- ### Span Inline Attribute Lists {#span-ials}
1702
-
1703
- > This syntax feature is not part of the original Markdown syntax. The idea and syntax comes from
1704
- > the [Maruku] package.
1705
- {: .markdown-difference}
1706
-
1707
- This is a version of the [block inline attribute list](#block-ials) for span-level elements. It has
1708
- the same structure as the block IAL except that leading and trailing spaces are not allowed. A span
1709
- IAL (or two or more span IALs) has to be put directly after the span-level element to which it
1710
- should be applied, no additional character is allowed between, otherwise it is ignored and only
1711
- removed from the output.
1712
-
1713
- Here are some examples for span IALs:
1714
-
1715
- This *is*{:.underline} some `code`{:#id}{:.class}.
1716
- A [link](test.html){:rel='something'} and some **tools**{:.tools}.
1717
-
1718
- The special span IAL `{::}` contains no attributes but doesn't generate a warning either. It can be
1719
- used to separate consecutive elements that would be falsely parsed if not separated. Here is an use
1720
- case:
1721
-
1722
- This *is italic*{::}*marked*{:.special} text
1723
-
1724
-
1725
- ## Extensions
1726
-
1727
- > This syntax feature is not part of the original Markdown syntax.
1728
- {: .markdown-difference}
1729
-
1730
- Extensions provide additional functionality but use the same syntax for it. They are available as
1731
- block as well as span-level elements.
1732
-
1733
- The syntax for an extension is very similar to the syntax of [ALDs](#attribute-list-definitions).
1734
- Here are some examples of how to specify extensions and afterwards is the syntax definition:
1735
-
1736
- {::comment}
1737
- This text is completely ignored by kramdown - a comment in the text.
1738
- {:/comment}
1739
-
1740
- Do you see {::comment}this text{:/comment}?
1741
- {::comment}some other comment{:/}
1742
-
1743
- {::options key="val" /}
1744
-
1745
- An extension can be specified with or without a body. Therefore there exist a start and an end tag
1746
- for extensions. The start tag has the following structure:
1747
-
1748
- * a left brace,
1749
- * followed by two colons and the extension name,
1750
- * optionally followed by a space and attribute definitions (allowed characters are backslash-escaped
1751
- closing braces or any character except a not escaped closing brace -- same as with ALDs),
1752
- * followed by a slash and a right brace (in case the extension has no body) or only a right
1753
- brace (in case the extension has a body).
1754
-
1755
- The stop tag has the following structure:
1756
-
1757
- * a left brace,
1758
- * followed by a colon and a slash,
1759
- * optionally followed by the extension name,
1760
- * followed by a right brace.
1761
-
1762
- A stop tag is only needed if the extension has a body!
1763
-
1764
- The above syntax can be used as is for span-level extensions. The starting and ending lines for block-level
1765
- extensions are defined as:
1766
-
1767
- * The starting line consists of the extension start tag, optionally preceded by up to three spaces,
1768
- and followed by optional spaces until the end of the line.
1769
- * The ending line consists of the extension stop tag, optionally preceded by up to three spaces,
1770
- and followed by optional spaces until the end of the line.
1771
-
1772
- If no end tag can be found for an extension start tag, the start tag is treated as if it has no
1773
- body. If an invalid extension stop tag is found, it is ignored. If an invalid extension name is
1774
- specified the extension (and the eventually specified body) are ignored.
1775
-
1776
- The following extensions can be used with kramdown:
1777
-
1778
- `comment`
1779
-
1780
- : Treat the body text as a comment which does not show in the output.
1781
-
1782
- `nomarkdown`
1783
-
1784
- : Don't process the body with kramdown but output it as-is. The attribute `type` specifies which
1785
- converters should output the body: if the attribute is missing, all converters should output it.
1786
- Otherwise the attribute value has to be a space separated list of converter names and these
1787
- converters should output the body.
1788
-
1789
- `options`
1790
-
1791
- : Should be used without a body since the body is ignored. Is used for setting the global options
1792
- for the kramdown processor (for example, to disable automatic header ID generation). Note that
1793
- options that are used by the parser are immediately effective whereas all other options are not!
1794
- This means, for example, that it is not possible to set converter options only for some part of a
1795
- kramdown document.
1796
-
1797
-
1798
-
1799
- {include_file: doc/links.markdown}