gitdown 0.0.1

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