daqing_kramdown 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (557) hide show
  1. checksums.yaml +7 -0
  2. data/AUTHORS +1 -0
  3. data/CONTRIBUTERS +78 -0
  4. data/COPYING +30 -0
  5. data/README.md +71 -0
  6. data/VERSION +1 -0
  7. data/bin/daqing_kramdown +132 -0
  8. data/data/kramdown/document.html +22 -0
  9. data/data/kramdown/document.latex +50 -0
  10. data/lib/kramdown.rb +10 -0
  11. data/lib/kramdown/converter.rb +68 -0
  12. data/lib/kramdown/converter/base.rb +261 -0
  13. data/lib/kramdown/converter/hash_ast.rb +38 -0
  14. data/lib/kramdown/converter/html.rb +535 -0
  15. data/lib/kramdown/converter/kramdown.rb +448 -0
  16. data/lib/kramdown/converter/latex.rb +625 -0
  17. data/lib/kramdown/converter/man.rb +300 -0
  18. data/lib/kramdown/converter/math_engine/mathjax.rb +32 -0
  19. data/lib/kramdown/converter/remove_html_tags.rb +57 -0
  20. data/lib/kramdown/converter/syntax_highlighter.rb +56 -0
  21. data/lib/kramdown/converter/syntax_highlighter/minted.rb +35 -0
  22. data/lib/kramdown/converter/syntax_highlighter/rouge.rb +85 -0
  23. data/lib/kramdown/converter/toc.rb +69 -0
  24. data/lib/kramdown/document.rb +139 -0
  25. data/lib/kramdown/element.rb +551 -0
  26. data/lib/kramdown/error.rb +17 -0
  27. data/lib/kramdown/options.rb +604 -0
  28. data/lib/kramdown/parser.rb +26 -0
  29. data/lib/kramdown/parser/base.rb +131 -0
  30. data/lib/kramdown/parser/html.rb +608 -0
  31. data/lib/kramdown/parser/kramdown.rb +376 -0
  32. data/lib/kramdown/parser/kramdown/abbreviation.rb +78 -0
  33. data/lib/kramdown/parser/kramdown/autolink.rb +31 -0
  34. data/lib/kramdown/parser/kramdown/blank_line.rb +30 -0
  35. data/lib/kramdown/parser/kramdown/block_boundary.rb +34 -0
  36. data/lib/kramdown/parser/kramdown/blockquote.rb +38 -0
  37. data/lib/kramdown/parser/kramdown/codeblock.rb +57 -0
  38. data/lib/kramdown/parser/kramdown/codespan.rb +54 -0
  39. data/lib/kramdown/parser/kramdown/emphasis.rb +61 -0
  40. data/lib/kramdown/parser/kramdown/eob.rb +26 -0
  41. data/lib/kramdown/parser/kramdown/escaped_chars.rb +25 -0
  42. data/lib/kramdown/parser/kramdown/extensions.rb +214 -0
  43. data/lib/kramdown/parser/kramdown/footnote.rb +64 -0
  44. data/lib/kramdown/parser/kramdown/header.rb +70 -0
  45. data/lib/kramdown/parser/kramdown/horizontal_rule.rb +27 -0
  46. data/lib/kramdown/parser/kramdown/html.rb +162 -0
  47. data/lib/kramdown/parser/kramdown/html_entity.rb +34 -0
  48. data/lib/kramdown/parser/kramdown/line_break.rb +25 -0
  49. data/lib/kramdown/parser/kramdown/link.rb +149 -0
  50. data/lib/kramdown/parser/kramdown/list.rb +284 -0
  51. data/lib/kramdown/parser/kramdown/math.rb +53 -0
  52. data/lib/kramdown/parser/kramdown/paragraph.rb +62 -0
  53. data/lib/kramdown/parser/kramdown/smart_quotes.rb +174 -0
  54. data/lib/kramdown/parser/kramdown/table.rb +171 -0
  55. data/lib/kramdown/parser/kramdown/typographic_symbol.rb +44 -0
  56. data/lib/kramdown/parser/markdown.rb +57 -0
  57. data/lib/kramdown/utils.rb +45 -0
  58. data/lib/kramdown/utils/configurable.rb +45 -0
  59. data/lib/kramdown/utils/entities.rb +344 -0
  60. data/lib/kramdown/utils/html.rb +84 -0
  61. data/lib/kramdown/utils/lru_cache.rb +41 -0
  62. data/lib/kramdown/utils/string_scanner.rb +81 -0
  63. data/lib/kramdown/utils/unidecoder.rb +50 -0
  64. data/lib/kramdown/version.rb +15 -0
  65. data/man/man1/kramdown.1 +0 -0
  66. data/test/run_tests.rb +46 -0
  67. data/test/test_files.rb +298 -0
  68. data/test/test_location.rb +216 -0
  69. data/test/test_string_scanner_kramdown.rb +27 -0
  70. data/test/testcases/block/01_blank_line/spaces.html +1 -0
  71. data/test/testcases/block/01_blank_line/spaces.text +3 -0
  72. data/test/testcases/block/01_blank_line/tabs.html +1 -0
  73. data/test/testcases/block/01_blank_line/tabs.text +6 -0
  74. data/test/testcases/block/02_eob/beginning.html +1 -0
  75. data/test/testcases/block/02_eob/beginning.text +3 -0
  76. data/test/testcases/block/02_eob/end.html +1 -0
  77. data/test/testcases/block/02_eob/end.text +3 -0
  78. data/test/testcases/block/02_eob/middle.html +1 -0
  79. data/test/testcases/block/02_eob/middle.text +5 -0
  80. data/test/testcases/block/03_paragraph/indented.html +18 -0
  81. data/test/testcases/block/03_paragraph/indented.html.gfm +18 -0
  82. data/test/testcases/block/03_paragraph/indented.text +19 -0
  83. data/test/testcases/block/03_paragraph/line_break_last_line.html +9 -0
  84. data/test/testcases/block/03_paragraph/line_break_last_line.text +9 -0
  85. data/test/testcases/block/03_paragraph/no_newline_at_end.html +5 -0
  86. data/test/testcases/block/03_paragraph/no_newline_at_end.text +5 -0
  87. data/test/testcases/block/03_paragraph/one_para.html +1 -0
  88. data/test/testcases/block/03_paragraph/one_para.text +1 -0
  89. data/test/testcases/block/03_paragraph/standalone_image.html +8 -0
  90. data/test/testcases/block/03_paragraph/standalone_image.text +6 -0
  91. data/test/testcases/block/03_paragraph/two_para.html +4 -0
  92. data/test/testcases/block/03_paragraph/two_para.text +4 -0
  93. data/test/testcases/block/03_paragraph/with_html_to_native.html +1 -0
  94. data/test/testcases/block/03_paragraph/with_html_to_native.options +1 -0
  95. data/test/testcases/block/03_paragraph/with_html_to_native.text +1 -0
  96. data/test/testcases/block/04_header/atx_header.html +57 -0
  97. data/test/testcases/block/04_header/atx_header.text +54 -0
  98. data/test/testcases/block/04_header/atx_header_no_newline_at_end.html +1 -0
  99. data/test/testcases/block/04_header/atx_header_no_newline_at_end.text +1 -0
  100. data/test/testcases/block/04_header/header_type_offset.html +11 -0
  101. data/test/testcases/block/04_header/header_type_offset.kramdown +12 -0
  102. data/test/testcases/block/04_header/header_type_offset.latex +12 -0
  103. data/test/testcases/block/04_header/header_type_offset.options +2 -0
  104. data/test/testcases/block/04_header/header_type_offset.text +13 -0
  105. data/test/testcases/block/04_header/setext_header.html +32 -0
  106. data/test/testcases/block/04_header/setext_header.text +39 -0
  107. data/test/testcases/block/04_header/setext_header_no_newline_at_end.html +1 -0
  108. data/test/testcases/block/04_header/setext_header_no_newline_at_end.text +2 -0
  109. data/test/testcases/block/04_header/with_auto_id_prefix.html +3 -0
  110. data/test/testcases/block/04_header/with_auto_id_prefix.options +2 -0
  111. data/test/testcases/block/04_header/with_auto_id_prefix.text +3 -0
  112. data/test/testcases/block/04_header/with_auto_id_stripping.html +1 -0
  113. data/test/testcases/block/04_header/with_auto_id_stripping.options +1 -0
  114. data/test/testcases/block/04_header/with_auto_id_stripping.text +1 -0
  115. data/test/testcases/block/04_header/with_auto_ids.html +21 -0
  116. data/test/testcases/block/04_header/with_auto_ids.options +2 -0
  117. data/test/testcases/block/04_header/with_auto_ids.text +24 -0
  118. data/test/testcases/block/05_blockquote/indented.html +25 -0
  119. data/test/testcases/block/05_blockquote/indented.text +14 -0
  120. data/test/testcases/block/05_blockquote/lazy.html +34 -0
  121. data/test/testcases/block/05_blockquote/lazy.text +20 -0
  122. data/test/testcases/block/05_blockquote/nested.html +10 -0
  123. data/test/testcases/block/05_blockquote/nested.text +6 -0
  124. data/test/testcases/block/05_blockquote/no_newline_at_end.html +4 -0
  125. data/test/testcases/block/05_blockquote/no_newline_at_end.text +2 -0
  126. data/test/testcases/block/05_blockquote/very_long_line.html +3 -0
  127. data/test/testcases/block/05_blockquote/very_long_line.text +1 -0
  128. data/test/testcases/block/05_blockquote/with_code_blocks.html +15 -0
  129. data/test/testcases/block/05_blockquote/with_code_blocks.text +11 -0
  130. data/test/testcases/block/06_codeblock/disable-highlighting.html +4 -0
  131. data/test/testcases/block/06_codeblock/disable-highlighting.options +1 -0
  132. data/test/testcases/block/06_codeblock/disable-highlighting.text +4 -0
  133. data/test/testcases/block/06_codeblock/error.html +4 -0
  134. data/test/testcases/block/06_codeblock/error.text +4 -0
  135. data/test/testcases/block/06_codeblock/guess_lang_css_class.html +15 -0
  136. data/test/testcases/block/06_codeblock/guess_lang_css_class.options +2 -0
  137. data/test/testcases/block/06_codeblock/guess_lang_css_class.text +13 -0
  138. data/test/testcases/block/06_codeblock/highlighting-minted-with-opts.latex +9 -0
  139. data/test/testcases/block/06_codeblock/highlighting-minted-with-opts.options +4 -0
  140. data/test/testcases/block/06_codeblock/highlighting-minted-with-opts.text +5 -0
  141. data/test/testcases/block/06_codeblock/highlighting-minted.latex +8 -0
  142. data/test/testcases/block/06_codeblock/highlighting-minted.options +3 -0
  143. data/test/testcases/block/06_codeblock/highlighting-minted.text +4 -0
  144. data/test/testcases/block/06_codeblock/highlighting-opts.html +6 -0
  145. data/test/testcases/block/06_codeblock/highlighting-opts.options +7 -0
  146. data/test/testcases/block/06_codeblock/highlighting-opts.text +4 -0
  147. data/test/testcases/block/06_codeblock/highlighting.html +5 -0
  148. data/test/testcases/block/06_codeblock/highlighting.options +5 -0
  149. data/test/testcases/block/06_codeblock/highlighting.text +4 -0
  150. data/test/testcases/block/06_codeblock/issue_gh45.html +164 -0
  151. data/test/testcases/block/06_codeblock/issue_gh45.test +188 -0
  152. data/test/testcases/block/06_codeblock/lazy.html +4 -0
  153. data/test/testcases/block/06_codeblock/lazy.text +5 -0
  154. data/test/testcases/block/06_codeblock/no_newline_at_end.html +2 -0
  155. data/test/testcases/block/06_codeblock/no_newline_at_end.text +1 -0
  156. data/test/testcases/block/06_codeblock/no_newline_at_end_1.html +2 -0
  157. data/test/testcases/block/06_codeblock/no_newline_at_end_1.text +2 -0
  158. data/test/testcases/block/06_codeblock/normal.html +13 -0
  159. data/test/testcases/block/06_codeblock/normal.text +10 -0
  160. data/test/testcases/block/06_codeblock/rouge/disabled.html +2 -0
  161. data/test/testcases/block/06_codeblock/rouge/disabled.options +4 -0
  162. data/test/testcases/block/06_codeblock/rouge/disabled.text +1 -0
  163. data/test/testcases/block/06_codeblock/rouge/multiple.html +11 -0
  164. data/test/testcases/block/06_codeblock/rouge/multiple.options +4 -0
  165. data/test/testcases/block/06_codeblock/rouge/multiple.text +11 -0
  166. data/test/testcases/block/06_codeblock/rouge/simple.html +10 -0
  167. data/test/testcases/block/06_codeblock/rouge/simple.options +3 -0
  168. data/test/testcases/block/06_codeblock/rouge/simple.text +9 -0
  169. data/test/testcases/block/06_codeblock/tilde_syntax.html +7 -0
  170. data/test/testcases/block/06_codeblock/tilde_syntax.text +9 -0
  171. data/test/testcases/block/06_codeblock/whitespace.html +3 -0
  172. data/test/testcases/block/06_codeblock/whitespace.text +3 -0
  173. data/test/testcases/block/06_codeblock/with_blank_line.html +13 -0
  174. data/test/testcases/block/06_codeblock/with_blank_line.text +12 -0
  175. data/test/testcases/block/06_codeblock/with_eob_marker.html +6 -0
  176. data/test/testcases/block/06_codeblock/with_eob_marker.text +5 -0
  177. data/test/testcases/block/06_codeblock/with_ial.html +6 -0
  178. data/test/testcases/block/06_codeblock/with_ial.text +5 -0
  179. data/test/testcases/block/06_codeblock/with_lang_in_fenced_block.html +24 -0
  180. data/test/testcases/block/06_codeblock/with_lang_in_fenced_block.options +2 -0
  181. data/test/testcases/block/06_codeblock/with_lang_in_fenced_block.text +33 -0
  182. data/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.html +8 -0
  183. data/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.options +2 -0
  184. data/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.text +11 -0
  185. data/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.html +3 -0
  186. data/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.options +2 -0
  187. data/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.text +4 -0
  188. data/test/testcases/block/07_horizontal_rule/error.html +7 -0
  189. data/test/testcases/block/07_horizontal_rule/error.text +7 -0
  190. data/test/testcases/block/07_horizontal_rule/normal.html +19 -0
  191. data/test/testcases/block/07_horizontal_rule/normal.text +20 -0
  192. data/test/testcases/block/07_horizontal_rule/sepspaces.html +3 -0
  193. data/test/testcases/block/07_horizontal_rule/sepspaces.text +3 -0
  194. data/test/testcases/block/07_horizontal_rule/septabs.html +3 -0
  195. data/test/testcases/block/07_horizontal_rule/septabs.text +3 -0
  196. data/test/testcases/block/08_list/brackets_in_item.latex +3 -0
  197. data/test/testcases/block/08_list/brackets_in_item.text +1 -0
  198. data/test/testcases/block/08_list/escaping.html +17 -0
  199. data/test/testcases/block/08_list/escaping.text +17 -0
  200. data/test/testcases/block/08_list/item_ial.html +10 -0
  201. data/test/testcases/block/08_list/item_ial.text +8 -0
  202. data/test/testcases/block/08_list/lazy.html +39 -0
  203. data/test/testcases/block/08_list/lazy.text +29 -0
  204. data/test/testcases/block/08_list/lazy_and_nested.html +9 -0
  205. data/test/testcases/block/08_list/lazy_and_nested.text +4 -0
  206. data/test/testcases/block/08_list/list_and_hr.html +9 -0
  207. data/test/testcases/block/08_list/list_and_hr.text +5 -0
  208. data/test/testcases/block/08_list/list_and_others.html +40 -0
  209. data/test/testcases/block/08_list/list_and_others.text +26 -0
  210. data/test/testcases/block/08_list/mixed.html +117 -0
  211. data/test/testcases/block/08_list/mixed.text +66 -0
  212. data/test/testcases/block/08_list/nested.html +17 -0
  213. data/test/testcases/block/08_list/nested.text +7 -0
  214. data/test/testcases/block/08_list/other_first_element.html +39 -0
  215. data/test/testcases/block/08_list/other_first_element.text +18 -0
  216. data/test/testcases/block/08_list/simple_ol.html +19 -0
  217. data/test/testcases/block/08_list/simple_ol.text +13 -0
  218. data/test/testcases/block/08_list/simple_ul.html +48 -0
  219. data/test/testcases/block/08_list/simple_ul.text +36 -0
  220. data/test/testcases/block/08_list/single_item.html +3 -0
  221. data/test/testcases/block/08_list/single_item.text +1 -0
  222. data/test/testcases/block/08_list/special_cases.html +62 -0
  223. data/test/testcases/block/08_list/special_cases.text +40 -0
  224. data/test/testcases/block/09_html/comment.html +18 -0
  225. data/test/testcases/block/09_html/comment.text +15 -0
  226. data/test/testcases/block/09_html/content_model/deflists.html +6 -0
  227. data/test/testcases/block/09_html/content_model/deflists.options +1 -0
  228. data/test/testcases/block/09_html/content_model/deflists.text +6 -0
  229. data/test/testcases/block/09_html/content_model/tables.html +14 -0
  230. data/test/testcases/block/09_html/content_model/tables.options +1 -0
  231. data/test/testcases/block/09_html/content_model/tables.text +14 -0
  232. data/test/testcases/block/09_html/html5_attributes.html +15 -0
  233. data/test/testcases/block/09_html/html5_attributes.text +15 -0
  234. data/test/testcases/block/09_html/html_after_block.html +7 -0
  235. data/test/testcases/block/09_html/html_after_block.text +5 -0
  236. data/test/testcases/block/09_html/html_and_codeblocks.html +15 -0
  237. data/test/testcases/block/09_html/html_and_codeblocks.options +1 -0
  238. data/test/testcases/block/09_html/html_and_codeblocks.text +13 -0
  239. data/test/testcases/block/09_html/html_and_headers.html +5 -0
  240. data/test/testcases/block/09_html/html_and_headers.text +6 -0
  241. data/test/testcases/block/09_html/html_to_native/code.html +10 -0
  242. data/test/testcases/block/09_html/html_to_native/code.text +9 -0
  243. data/test/testcases/block/09_html/html_to_native/comment.html +7 -0
  244. data/test/testcases/block/09_html/html_to_native/comment.text +8 -0
  245. data/test/testcases/block/09_html/html_to_native/emphasis.html +6 -0
  246. data/test/testcases/block/09_html/html_to_native/emphasis.text +6 -0
  247. data/test/testcases/block/09_html/html_to_native/entity.html +1 -0
  248. data/test/testcases/block/09_html/html_to_native/entity.text +1 -0
  249. data/test/testcases/block/09_html/html_to_native/header.html +6 -0
  250. data/test/testcases/block/09_html/html_to_native/header.options +2 -0
  251. data/test/testcases/block/09_html/html_to_native/header.text +6 -0
  252. data/test/testcases/block/09_html/html_to_native/list_dl.html +8 -0
  253. data/test/testcases/block/09_html/html_to_native/list_dl.text +8 -0
  254. data/test/testcases/block/09_html/html_to_native/list_ol.html +15 -0
  255. data/test/testcases/block/09_html/html_to_native/list_ol.text +17 -0
  256. data/test/testcases/block/09_html/html_to_native/list_ul.html +19 -0
  257. data/test/testcases/block/09_html/html_to_native/list_ul.text +22 -0
  258. data/test/testcases/block/09_html/html_to_native/options +1 -0
  259. data/test/testcases/block/09_html/html_to_native/paragraph.html +3 -0
  260. data/test/testcases/block/09_html/html_to_native/paragraph.text +4 -0
  261. data/test/testcases/block/09_html/html_to_native/table_normal.html +12 -0
  262. data/test/testcases/block/09_html/html_to_native/table_normal.text +12 -0
  263. data/test/testcases/block/09_html/html_to_native/table_simple.html +61 -0
  264. data/test/testcases/block/09_html/html_to_native/table_simple.text +71 -0
  265. data/test/testcases/block/09_html/html_to_native/typography.html +1 -0
  266. data/test/testcases/block/09_html/html_to_native/typography.text +1 -0
  267. data/test/testcases/block/09_html/invalid_html_1.html +5 -0
  268. data/test/testcases/block/09_html/invalid_html_1.text +5 -0
  269. data/test/testcases/block/09_html/invalid_html_2.html +5 -0
  270. data/test/testcases/block/09_html/invalid_html_2.text +5 -0
  271. data/test/testcases/block/09_html/markdown_attr.html +38 -0
  272. data/test/testcases/block/09_html/markdown_attr.text +38 -0
  273. data/test/testcases/block/09_html/not_parsed.html +24 -0
  274. data/test/testcases/block/09_html/not_parsed.text +24 -0
  275. data/test/testcases/block/09_html/parse_as_raw.html +35 -0
  276. data/test/testcases/block/09_html/parse_as_raw.htmlinput +34 -0
  277. data/test/testcases/block/09_html/parse_as_raw.options +1 -0
  278. data/test/testcases/block/09_html/parse_as_raw.text +33 -0
  279. data/test/testcases/block/09_html/parse_as_span.html +12 -0
  280. data/test/testcases/block/09_html/parse_as_span.htmlinput +12 -0
  281. data/test/testcases/block/09_html/parse_as_span.options +1 -0
  282. data/test/testcases/block/09_html/parse_as_span.text +9 -0
  283. data/test/testcases/block/09_html/parse_block_html.html +21 -0
  284. data/test/testcases/block/09_html/parse_block_html.options +1 -0
  285. data/test/testcases/block/09_html/parse_block_html.text +17 -0
  286. data/test/testcases/block/09_html/processing_instruction.html +12 -0
  287. data/test/testcases/block/09_html/processing_instruction.text +12 -0
  288. data/test/testcases/block/09_html/simple.html +60 -0
  289. data/test/testcases/block/09_html/simple.options +1 -0
  290. data/test/testcases/block/09_html/simple.text +55 -0
  291. data/test/testcases/block/09_html/standalone_image_in_div.htmlinput +7 -0
  292. data/test/testcases/block/09_html/standalone_image_in_div.text +8 -0
  293. data/test/testcases/block/09_html/textarea.html +8 -0
  294. data/test/testcases/block/09_html/textarea.text +8 -0
  295. data/test/testcases/block/09_html/xml.html +8 -0
  296. data/test/testcases/block/09_html/xml.text +7 -0
  297. data/test/testcases/block/10_ald/simple.html +2 -0
  298. data/test/testcases/block/10_ald/simple.text +8 -0
  299. data/test/testcases/block/11_ial/auto_id_and_ial.html +1 -0
  300. data/test/testcases/block/11_ial/auto_id_and_ial.options +1 -0
  301. data/test/testcases/block/11_ial/auto_id_and_ial.text +2 -0
  302. data/test/testcases/block/11_ial/nested.html +11 -0
  303. data/test/testcases/block/11_ial/nested.text +15 -0
  304. data/test/testcases/block/11_ial/simple.html +29 -0
  305. data/test/testcases/block/11_ial/simple.text +41 -0
  306. data/test/testcases/block/12_extension/comment.html +8 -0
  307. data/test/testcases/block/12_extension/comment.text +12 -0
  308. data/test/testcases/block/12_extension/ignored.html +8 -0
  309. data/test/testcases/block/12_extension/ignored.text +8 -0
  310. data/test/testcases/block/12_extension/nomarkdown.html +10 -0
  311. data/test/testcases/block/12_extension/nomarkdown.kramdown +20 -0
  312. data/test/testcases/block/12_extension/nomarkdown.latex +13 -0
  313. data/test/testcases/block/12_extension/nomarkdown.text +21 -0
  314. data/test/testcases/block/12_extension/options.html +21 -0
  315. data/test/testcases/block/12_extension/options.text +23 -0
  316. data/test/testcases/block/12_extension/options2.html +10 -0
  317. data/test/testcases/block/12_extension/options2.text +5 -0
  318. data/test/testcases/block/12_extension/options3.html +8 -0
  319. data/test/testcases/block/12_extension/options3.text +7 -0
  320. data/test/testcases/block/13_definition_list/auto_ids.html +15 -0
  321. data/test/testcases/block/13_definition_list/auto_ids.text +18 -0
  322. data/test/testcases/block/13_definition_list/definition_at_beginning.html +1 -0
  323. data/test/testcases/block/13_definition_list/definition_at_beginning.text +1 -0
  324. data/test/testcases/block/13_definition_list/deflist_ial.html +4 -0
  325. data/test/testcases/block/13_definition_list/deflist_ial.text +4 -0
  326. data/test/testcases/block/13_definition_list/item_ial.html +17 -0
  327. data/test/testcases/block/13_definition_list/item_ial.text +16 -0
  328. data/test/testcases/block/13_definition_list/multiple_terms.html +13 -0
  329. data/test/testcases/block/13_definition_list/multiple_terms.text +10 -0
  330. data/test/testcases/block/13_definition_list/no_def_list.html +2 -0
  331. data/test/testcases/block/13_definition_list/no_def_list.text +2 -0
  332. data/test/testcases/block/13_definition_list/para_wrapping.html +10 -0
  333. data/test/testcases/block/13_definition_list/para_wrapping.text +6 -0
  334. data/test/testcases/block/13_definition_list/separated_by_eob.html +8 -0
  335. data/test/testcases/block/13_definition_list/separated_by_eob.text +5 -0
  336. data/test/testcases/block/13_definition_list/simple.html +10 -0
  337. data/test/testcases/block/13_definition_list/simple.text +10 -0
  338. data/test/testcases/block/13_definition_list/styled_terms.html +4 -0
  339. data/test/testcases/block/13_definition_list/styled_terms.text +2 -0
  340. data/test/testcases/block/13_definition_list/too_much_space.html +3 -0
  341. data/test/testcases/block/13_definition_list/too_much_space.text +4 -0
  342. data/test/testcases/block/13_definition_list/with_blocks.html +38 -0
  343. data/test/testcases/block/13_definition_list/with_blocks.text +24 -0
  344. data/test/testcases/block/14_table/empty_tag_in_cell.html +8 -0
  345. data/test/testcases/block/14_table/empty_tag_in_cell.options +1 -0
  346. data/test/testcases/block/14_table/empty_tag_in_cell.text +1 -0
  347. data/test/testcases/block/14_table/errors.html +12 -0
  348. data/test/testcases/block/14_table/errors.text +13 -0
  349. data/test/testcases/block/14_table/escaping.html +52 -0
  350. data/test/testcases/block/14_table/escaping.text +19 -0
  351. data/test/testcases/block/14_table/footer.html +65 -0
  352. data/test/testcases/block/14_table/footer.text +25 -0
  353. data/test/testcases/block/14_table/header.html +117 -0
  354. data/test/testcases/block/14_table/header.text +39 -0
  355. data/test/testcases/block/14_table/no_table.html +3 -0
  356. data/test/testcases/block/14_table/no_table.text +3 -0
  357. data/test/testcases/block/14_table/simple.html +192 -0
  358. data/test/testcases/block/14_table/simple.text +53 -0
  359. data/test/testcases/block/14_table/table_with_footnote.html +25 -0
  360. data/test/testcases/block/14_table/table_with_footnote.latex +11 -0
  361. data/test/testcases/block/14_table/table_with_footnote.text +6 -0
  362. data/test/testcases/block/15_math/gh_128.html +1 -0
  363. data/test/testcases/block/15_math/gh_128.text +1 -0
  364. data/test/testcases/block/15_math/no_engine.html +3 -0
  365. data/test/testcases/block/15_math/no_engine.options +1 -0
  366. data/test/testcases/block/15_math/no_engine.text +2 -0
  367. data/test/testcases/block/15_math/normal.html +30 -0
  368. data/test/testcases/block/15_math/normal.text +30 -0
  369. data/test/testcases/block/16_toc/no_toc.html +14 -0
  370. data/test/testcases/block/16_toc/no_toc.text +16 -0
  371. data/test/testcases/block/16_toc/toc_exclude.html +35 -0
  372. data/test/testcases/block/16_toc/toc_exclude.options +1 -0
  373. data/test/testcases/block/16_toc/toc_exclude.text +19 -0
  374. data/test/testcases/block/16_toc/toc_levels.html +24 -0
  375. data/test/testcases/block/16_toc/toc_levels.options +2 -0
  376. data/test/testcases/block/16_toc/toc_levels.text +16 -0
  377. data/test/testcases/block/16_toc/toc_with_footnotes.html +13 -0
  378. data/test/testcases/block/16_toc/toc_with_footnotes.options +1 -0
  379. data/test/testcases/block/16_toc/toc_with_footnotes.text +6 -0
  380. data/test/testcases/block/16_toc/toc_with_links.html +8 -0
  381. data/test/testcases/block/16_toc/toc_with_links.options +2 -0
  382. data/test/testcases/block/16_toc/toc_with_links.text +8 -0
  383. data/test/testcases/cjk-line-break.html +4 -0
  384. data/test/testcases/cjk-line-break.options +1 -0
  385. data/test/testcases/cjk-line-break.text +12 -0
  386. data/test/testcases/encoding.html +46 -0
  387. data/test/testcases/encoding.text +28 -0
  388. data/test/testcases/man/example.man +123 -0
  389. data/test/testcases/man/example.text +85 -0
  390. data/test/testcases/man/heading-name-dash-description.man +4 -0
  391. data/test/testcases/man/heading-name-dash-description.text +1 -0
  392. data/test/testcases/man/heading-name-description.man +4 -0
  393. data/test/testcases/man/heading-name-description.text +2 -0
  394. data/test/testcases/man/heading-name-section-description.man +4 -0
  395. data/test/testcases/man/heading-name-section-description.text +1 -0
  396. data/test/testcases/man/heading-name-section.man +2 -0
  397. data/test/testcases/man/heading-name-section.text +1 -0
  398. data/test/testcases/man/heading-name.man +2 -0
  399. data/test/testcases/man/heading-name.text +1 -0
  400. data/test/testcases/man/sections.man +4 -0
  401. data/test/testcases/man/sections.text +11 -0
  402. data/test/testcases/man/text-escaping.man +8 -0
  403. data/test/testcases/man/text-escaping.text +7 -0
  404. data/test/testcases/span/01_link/empty.html +5 -0
  405. data/test/testcases/span/01_link/empty.text +5 -0
  406. data/test/testcases/span/01_link/empty_title.htmlinput +3 -0
  407. data/test/testcases/span/01_link/empty_title.text +7 -0
  408. data/test/testcases/span/01_link/image_in_a.html +5 -0
  409. data/test/testcases/span/01_link/image_in_a.text +5 -0
  410. data/test/testcases/span/01_link/imagelinks.html +15 -0
  411. data/test/testcases/span/01_link/imagelinks.text +18 -0
  412. data/test/testcases/span/01_link/inline.html +46 -0
  413. data/test/testcases/span/01_link/inline.text +48 -0
  414. data/test/testcases/span/01_link/latex_escaping.latex +6 -0
  415. data/test/testcases/span/01_link/latex_escaping.text +5 -0
  416. data/test/testcases/span/01_link/link_defs.html +9 -0
  417. data/test/testcases/span/01_link/link_defs.text +27 -0
  418. data/test/testcases/span/01_link/link_defs_with_ial.html +4 -0
  419. data/test/testcases/span/01_link/link_defs_with_ial.text +16 -0
  420. data/test/testcases/span/01_link/links_with_angle_brackets.html +3 -0
  421. data/test/testcases/span/01_link/links_with_angle_brackets.text +3 -0
  422. data/test/testcases/span/01_link/reference.html +37 -0
  423. data/test/testcases/span/01_link/reference.options +3 -0
  424. data/test/testcases/span/01_link/reference.text +53 -0
  425. data/test/testcases/span/02_emphasis/empty.html +3 -0
  426. data/test/testcases/span/02_emphasis/empty.text +3 -0
  427. data/test/testcases/span/02_emphasis/errors.html +9 -0
  428. data/test/testcases/span/02_emphasis/errors.text +9 -0
  429. data/test/testcases/span/02_emphasis/nesting.html +41 -0
  430. data/test/testcases/span/02_emphasis/nesting.text +36 -0
  431. data/test/testcases/span/02_emphasis/normal.html +65 -0
  432. data/test/testcases/span/02_emphasis/normal.options +1 -0
  433. data/test/testcases/span/02_emphasis/normal.text +63 -0
  434. data/test/testcases/span/03_codespan/empty.html +5 -0
  435. data/test/testcases/span/03_codespan/empty.text +5 -0
  436. data/test/testcases/span/03_codespan/errors.html +1 -0
  437. data/test/testcases/span/03_codespan/errors.text +1 -0
  438. data/test/testcases/span/03_codespan/highlighting-minted.latex +2 -0
  439. data/test/testcases/span/03_codespan/highlighting-minted.options +1 -0
  440. data/test/testcases/span/03_codespan/highlighting-minted.text +1 -0
  441. data/test/testcases/span/03_codespan/highlighting.html +1 -0
  442. data/test/testcases/span/03_codespan/highlighting.text +1 -0
  443. data/test/testcases/span/03_codespan/normal-css-class.html +1 -0
  444. data/test/testcases/span/03_codespan/normal-css-class.options +2 -0
  445. data/test/testcases/span/03_codespan/normal-css-class.text +1 -0
  446. data/test/testcases/span/03_codespan/normal.html +16 -0
  447. data/test/testcases/span/03_codespan/normal.text +16 -0
  448. data/test/testcases/span/03_codespan/rouge/disabled.html +1 -0
  449. data/test/testcases/span/03_codespan/rouge/disabled.options +4 -0
  450. data/test/testcases/span/03_codespan/rouge/disabled.text +1 -0
  451. data/test/testcases/span/03_codespan/rouge/simple.html +1 -0
  452. data/test/testcases/span/03_codespan/rouge/simple.options +1 -0
  453. data/test/testcases/span/03_codespan/rouge/simple.text +1 -0
  454. data/test/testcases/span/04_footnote/backlink_inline.html +79 -0
  455. data/test/testcases/span/04_footnote/backlink_inline.options +1 -0
  456. data/test/testcases/span/04_footnote/backlink_inline.text +38 -0
  457. data/test/testcases/span/04_footnote/backlink_text.html +9 -0
  458. data/test/testcases/span/04_footnote/backlink_text.options +1 -0
  459. data/test/testcases/span/04_footnote/backlink_text.text +3 -0
  460. data/test/testcases/span/04_footnote/definitions.html +17 -0
  461. data/test/testcases/span/04_footnote/definitions.latex +17 -0
  462. data/test/testcases/span/04_footnote/definitions.text +24 -0
  463. data/test/testcases/span/04_footnote/footnote_nr.html +12 -0
  464. data/test/testcases/span/04_footnote/footnote_nr.latex +2 -0
  465. data/test/testcases/span/04_footnote/footnote_nr.options +1 -0
  466. data/test/testcases/span/04_footnote/footnote_nr.text +4 -0
  467. data/test/testcases/span/04_footnote/footnote_prefix.html +12 -0
  468. data/test/testcases/span/04_footnote/footnote_prefix.options +1 -0
  469. data/test/testcases/span/04_footnote/footnote_prefix.text +4 -0
  470. data/test/testcases/span/04_footnote/inside_footnote.html +17 -0
  471. data/test/testcases/span/04_footnote/inside_footnote.text +9 -0
  472. data/test/testcases/span/04_footnote/markers.html +46 -0
  473. data/test/testcases/span/04_footnote/markers.latex +23 -0
  474. data/test/testcases/span/04_footnote/markers.options +2 -0
  475. data/test/testcases/span/04_footnote/markers.text +27 -0
  476. data/test/testcases/span/04_footnote/placement.html +11 -0
  477. data/test/testcases/span/04_footnote/placement.options +1 -0
  478. data/test/testcases/span/04_footnote/placement.text +8 -0
  479. data/test/testcases/span/04_footnote/regexp_problem.html +14 -0
  480. data/test/testcases/span/04_footnote/regexp_problem.options +2 -0
  481. data/test/testcases/span/04_footnote/regexp_problem.text +52 -0
  482. data/test/testcases/span/04_footnote/without_backlink.html +9 -0
  483. data/test/testcases/span/04_footnote/without_backlink.options +1 -0
  484. data/test/testcases/span/04_footnote/without_backlink.text +3 -0
  485. data/test/testcases/span/05_html/across_lines.html +1 -0
  486. data/test/testcases/span/05_html/across_lines.text +2 -0
  487. data/test/testcases/span/05_html/button.html +7 -0
  488. data/test/testcases/span/05_html/button.text +7 -0
  489. data/test/testcases/span/05_html/invalid.html +1 -0
  490. data/test/testcases/span/05_html/invalid.text +1 -0
  491. data/test/testcases/span/05_html/link_with_mailto.html +1 -0
  492. data/test/testcases/span/05_html/link_with_mailto.text +1 -0
  493. data/test/testcases/span/05_html/mark_element.html +3 -0
  494. data/test/testcases/span/05_html/mark_element.text +3 -0
  495. data/test/testcases/span/05_html/markdown_attr.html +6 -0
  496. data/test/testcases/span/05_html/markdown_attr.text +6 -0
  497. data/test/testcases/span/05_html/normal.html +43 -0
  498. data/test/testcases/span/05_html/normal.text +43 -0
  499. data/test/testcases/span/05_html/raw_span_elements.html +2 -0
  500. data/test/testcases/span/05_html/raw_span_elements.text +2 -0
  501. data/test/testcases/span/05_html/xml.html +5 -0
  502. data/test/testcases/span/05_html/xml.text +5 -0
  503. data/test/testcases/span/abbreviations/abbrev.html +21 -0
  504. data/test/testcases/span/abbreviations/abbrev.text +34 -0
  505. data/test/testcases/span/abbreviations/abbrev_defs.html +2 -0
  506. data/test/testcases/span/abbreviations/abbrev_defs.text +5 -0
  507. data/test/testcases/span/abbreviations/in_footnote.html +9 -0
  508. data/test/testcases/span/abbreviations/in_footnote.text +5 -0
  509. data/test/testcases/span/autolinks/url_links.html +15 -0
  510. data/test/testcases/span/autolinks/url_links.text +16 -0
  511. data/test/testcases/span/escaped_chars/normal.html +47 -0
  512. data/test/testcases/span/escaped_chars/normal.text +47 -0
  513. data/test/testcases/span/extension/comment.html +6 -0
  514. data/test/testcases/span/extension/comment.text +6 -0
  515. data/test/testcases/span/extension/ignored.html +1 -0
  516. data/test/testcases/span/extension/ignored.text +1 -0
  517. data/test/testcases/span/extension/nomarkdown.html +1 -0
  518. data/test/testcases/span/extension/nomarkdown.text +1 -0
  519. data/test/testcases/span/extension/options.html +1 -0
  520. data/test/testcases/span/extension/options.text +1 -0
  521. data/test/testcases/span/ial/simple.html +6 -0
  522. data/test/testcases/span/ial/simple.text +6 -0
  523. data/test/testcases/span/line_breaks/normal.html +11 -0
  524. data/test/testcases/span/line_breaks/normal.latex +12 -0
  525. data/test/testcases/span/line_breaks/normal.text +11 -0
  526. data/test/testcases/span/math/no_engine.html +1 -0
  527. data/test/testcases/span/math/no_engine.options +1 -0
  528. data/test/testcases/span/math/no_engine.text +1 -0
  529. data/test/testcases/span/math/normal.html +10 -0
  530. data/test/testcases/span/math/normal.text +10 -0
  531. data/test/testcases/span/text_substitutions/entities.html +6 -0
  532. data/test/testcases/span/text_substitutions/entities.options +1 -0
  533. data/test/testcases/span/text_substitutions/entities.text +6 -0
  534. data/test/testcases/span/text_substitutions/entities_as_char.html +1 -0
  535. data/test/testcases/span/text_substitutions/entities_as_char.options +2 -0
  536. data/test/testcases/span/text_substitutions/entities_as_char.text +1 -0
  537. data/test/testcases/span/text_substitutions/entities_as_input.html +1 -0
  538. data/test/testcases/span/text_substitutions/entities_as_input.options +1 -0
  539. data/test/testcases/span/text_substitutions/entities_as_input.text +1 -0
  540. data/test/testcases/span/text_substitutions/entities_numeric.html +1 -0
  541. data/test/testcases/span/text_substitutions/entities_numeric.options +1 -0
  542. data/test/testcases/span/text_substitutions/entities_numeric.text +1 -0
  543. data/test/testcases/span/text_substitutions/entities_symbolic.html +1 -0
  544. data/test/testcases/span/text_substitutions/entities_symbolic.options +1 -0
  545. data/test/testcases/span/text_substitutions/entities_symbolic.text +1 -0
  546. data/test/testcases/span/text_substitutions/greaterthan.html +1 -0
  547. data/test/testcases/span/text_substitutions/greaterthan.text +1 -0
  548. data/test/testcases/span/text_substitutions/lowerthan.html +1 -0
  549. data/test/testcases/span/text_substitutions/lowerthan.text +1 -0
  550. data/test/testcases/span/text_substitutions/typography.html +40 -0
  551. data/test/testcases/span/text_substitutions/typography.options +1 -0
  552. data/test/testcases/span/text_substitutions/typography.text +40 -0
  553. data/test/testcases/span/text_substitutions/typography_subst.html +3 -0
  554. data/test/testcases/span/text_substitutions/typography_subst.latex +4 -0
  555. data/test/testcases/span/text_substitutions/typography_subst.options +8 -0
  556. data/test/testcases/span/text_substitutions/typography_subst.text +3 -0
  557. metadata +659 -0
@@ -0,0 +1,284 @@
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ require 'kramdown/parser/kramdown/blank_line'
11
+ require 'kramdown/parser/kramdown/eob'
12
+ require 'kramdown/parser/kramdown/horizontal_rule'
13
+ require 'kramdown/parser/kramdown/extensions'
14
+
15
+ module Kramdown
16
+ module Parser
17
+ class Kramdown
18
+
19
+ LIST_ITEM_IAL = /^\s*(?:\{:(?!(?:#{ALD_ID_NAME})?:|\/)(#{ALD_ANY_CHARS}+)\})\s*/
20
+ LIST_ITEM_IAL_CHECK = /^#{LIST_ITEM_IAL}?\s*\n/
21
+
22
+ PARSE_FIRST_LIST_LINE_REGEXP_CACHE = Hash.new do |h, indentation|
23
+ indent_re = /^ {#{indentation}}/
24
+ content_re = /^(?:(?:\t| {4}){#{indentation / 4}} {#{indentation % 4}}|(?:\t| {4}){#{indentation / 4 + 1}}).*\S.*\n/
25
+ lazy_re = /(?!^ {0,#{[indentation, 3].min}}(?:#{IAL_BLOCK}|#{LAZY_END_HTML_STOP}|#{LAZY_END_HTML_START})).*\S.*\n/
26
+
27
+ h[indentation] = [content_re, lazy_re, indent_re]
28
+ end
29
+
30
+ # Used for parsing the first line of a list item or a definition, i.e. the line with list item
31
+ # marker or the definition marker.
32
+ def parse_first_list_line(indentation, content)
33
+ if content =~ self.class::LIST_ITEM_IAL_CHECK
34
+ indentation = 4
35
+ else
36
+ while content =~ /^ *\t/
37
+ temp = content.scan(/^ */).first.length + indentation
38
+ content.sub!(/^( *)(\t+)/) { $1 << " " * (4 - (temp % 4) + ($2.length - 1) * 4) }
39
+ end
40
+ indentation += content[/^ */].length
41
+ end
42
+ content.sub!(/^\s*/, '')
43
+
44
+ [content, indentation, *PARSE_FIRST_LIST_LINE_REGEXP_CACHE[indentation]]
45
+ end
46
+
47
+ PATTERN_TAIL = /[\t| ].*?\n/
48
+
49
+ LIST_START_UL = /^(#{OPT_SPACE}[+*-])(#{PATTERN_TAIL})/
50
+ LIST_START_OL = /^(#{OPT_SPACE}\d+\.)(#{PATTERN_TAIL})/
51
+ LIST_START = /#{LIST_START_UL}|#{LIST_START_OL}/
52
+
53
+ # Parse the ordered or unordered list at the current location.
54
+ def parse_list
55
+ start_line_number = @src.current_line_number
56
+ type, list_start_re = (@src.check(LIST_START_UL) ? [:ul, LIST_START_UL] : [:ol, LIST_START_OL])
57
+ list = new_block_el(type, nil, nil, location: start_line_number)
58
+
59
+ item = nil
60
+ content_re, lazy_re, indent_re = nil
61
+ eob_found = false
62
+ nested_list_found = false
63
+ last_is_blank = false
64
+ until @src.eos?
65
+ start_line_number = @src.current_line_number
66
+ if last_is_blank && @src.check(HR_START)
67
+ break
68
+ elsif @src.scan(EOB_MARKER)
69
+ eob_found = true
70
+ break
71
+ elsif @src.scan(list_start_re)
72
+ item = Element.new(:li, nil, nil, location: start_line_number)
73
+ item.value, indentation, content_re, lazy_re, indent_re =
74
+ parse_first_list_line(@src[1].length, @src[2])
75
+ list.children << item
76
+
77
+ item.value.sub!(self.class::LIST_ITEM_IAL) do
78
+ parse_attribute_list($1, item.options[:ial] ||= {})
79
+ ''
80
+ end
81
+
82
+ list_start_re = fetch_pattern(type, indentation)
83
+ nested_list_found = (item.value =~ LIST_START)
84
+ last_is_blank = false
85
+ item.value = [item.value]
86
+ elsif (result = @src.scan(content_re)) || (!last_is_blank && (result = @src.scan(lazy_re)))
87
+ result.sub!(/^(\t+)/) { " " * 4 * $1.length }
88
+ indentation_found = result.sub!(indent_re, '')
89
+ if !nested_list_found && indentation_found && result =~ LIST_START
90
+ item.value << +''
91
+ nested_list_found = true
92
+ elsif nested_list_found && !indentation_found && result =~ LIST_START
93
+ result = " " * (indentation + 4) << result
94
+ end
95
+ item.value.last << result
96
+ last_is_blank = false
97
+ elsif (result = @src.scan(BLANK_LINE))
98
+ nested_list_found = true
99
+ last_is_blank = true
100
+ item.value.last << result
101
+ else
102
+ break
103
+ end
104
+ end
105
+
106
+ @tree.children << list
107
+
108
+ last = nil
109
+ list.children.each do |it|
110
+ temp = Element.new(:temp, nil, nil, location: it.options[:location])
111
+
112
+ env = save_env
113
+ location = it.options[:location]
114
+ it.value.each do |val|
115
+ @src = ::Kramdown::Utils::StringScanner.new(val, location)
116
+ parse_blocks(temp)
117
+ location = @src.current_line_number
118
+ end
119
+ restore_env(env)
120
+
121
+ it.children = temp.children
122
+ it.value = nil
123
+
124
+ it_children = it.children
125
+ next if it_children.empty?
126
+
127
+ # Handle the case where an EOB marker is inserted by a block IAL for the first paragraph
128
+ it_children.delete_at(1) if it_children.first.type == :p &&
129
+ it_children.length >= 2 && it_children[1].type == :eob && it_children.first.options[:ial]
130
+
131
+ if it_children.first.type == :p &&
132
+ (it_children.length < 2 || it_children[1].type != :blank ||
133
+ (it == list.children.last && it_children.length == 2 && !eob_found)) &&
134
+ (list.children.last != it || list.children.size == 1 ||
135
+ list.children[0..-2].any? {|cit| !cit.children.first || cit.children.first.type != :p || cit.children.first.options[:transparent] })
136
+ it_children.first.children.first.value << "\n" if it_children.size > 1 && it_children[1].type != :blank
137
+ it_children.first.options[:transparent] = true
138
+ end
139
+
140
+ last = (it_children.last.type == :blank ? it_children.pop : nil)
141
+ end
142
+
143
+ @tree.children << last if !last.nil? && !eob_found
144
+
145
+ true
146
+ end
147
+ define_parser(:list, LIST_START)
148
+
149
+ DEFINITION_LIST_START = /^(#{OPT_SPACE}:)(#{PATTERN_TAIL})/
150
+
151
+ # Parse the ordered or unordered list at the current location.
152
+ def parse_definition_list
153
+ children = @tree.children
154
+ if !children.last || (children.length == 1 && children.last.type != :p) ||
155
+ (children.length >= 2 && children[-1].type != :p &&
156
+ (children[-1].type != :blank || children[-1].value != "\n" || children[-2].type != :p))
157
+ return false
158
+ end
159
+
160
+ first_as_para = false
161
+ deflist = new_block_el(:dl)
162
+ para = @tree.children.pop
163
+ if para.type == :blank
164
+ para = @tree.children.pop
165
+ first_as_para = true
166
+ end
167
+ # take location from preceding para which is the first definition term
168
+ deflist.options[:location] = para.options[:location]
169
+ para.children.first.value.split(/\n/).each do |term|
170
+ el = Element.new(:dt, nil, nil, location: @src.current_line_number)
171
+ term.sub!(self.class::LIST_ITEM_IAL) do
172
+ parse_attribute_list($1, el.options[:ial] ||= {})
173
+ ''
174
+ end
175
+ el.options[:raw_text] = term
176
+ el.children << Element.new(:raw_text, term)
177
+ deflist.children << el
178
+ end
179
+ deflist.options[:ial] = para.options[:ial]
180
+
181
+ item = nil
182
+ content_re, lazy_re, indent_re = nil
183
+ def_start_re = DEFINITION_LIST_START
184
+ last_is_blank = false
185
+ until @src.eos?
186
+ start_line_number = @src.current_line_number
187
+ if @src.scan(def_start_re)
188
+ item = Element.new(:dd, nil, nil, location: start_line_number)
189
+ item.options[:first_as_para] = first_as_para
190
+ item.value, indentation, content_re, lazy_re, indent_re =
191
+ parse_first_list_line(@src[1].length, @src[2])
192
+ deflist.children << item
193
+
194
+ item.value.sub!(self.class::LIST_ITEM_IAL) do |_match|
195
+ parse_attribute_list($1, item.options[:ial] ||= {})
196
+ ''
197
+ end
198
+
199
+ def_start_re = fetch_pattern(:dl, indentation)
200
+ first_as_para = false
201
+ last_is_blank = false
202
+ elsif @src.check(EOB_MARKER)
203
+ break
204
+ elsif (result = @src.scan(content_re)) || (!last_is_blank && (result = @src.scan(lazy_re)))
205
+ result.sub!(/^(\t+)/) { " " * ($1 ? 4 * $1.length : 0) }
206
+ result.sub!(indent_re, '')
207
+ item.value << result
208
+ first_as_para = false
209
+ last_is_blank = false
210
+ elsif (result = @src.scan(BLANK_LINE))
211
+ first_as_para = true
212
+ item.value << result
213
+ last_is_blank = true
214
+ else
215
+ break
216
+ end
217
+ end
218
+
219
+ last = nil
220
+ deflist.children.each do |it|
221
+ next if it.type == :dt
222
+
223
+ parse_blocks(it, it.value)
224
+ it.value = nil
225
+ it_children = it.children
226
+ next if it_children.empty?
227
+
228
+ last = (it_children.last.type == :blank ? it_children.pop : nil)
229
+
230
+ if it_children.first && it_children.first.type == :p && !it.options.delete(:first_as_para)
231
+ it_children.first.children.first.value << "\n" if it_children.size > 1
232
+ it_children.first.options[:transparent] = true
233
+ end
234
+ end
235
+
236
+ children = @tree.children
237
+ if children.length >= 1 && children.last.type == :dl
238
+ children[-1].children.concat(deflist.children)
239
+ elsif children.length >= 2 && children[-1].type == :blank &&
240
+ children[-2].type == :dl
241
+ children.pop
242
+ children[-1].children.concat(deflist.children)
243
+ else
244
+ children << deflist
245
+ end
246
+
247
+ children << last if last
248
+
249
+ true
250
+ end
251
+ define_parser(:definition_list, DEFINITION_LIST_START)
252
+
253
+ private
254
+
255
+ # precomputed patterns for indentations 1..4 and fallback expression
256
+ # to compute pattern when indentation is outside the 1..4 range.
257
+ def fetch_pattern(type, indentation)
258
+ if type == :ul
259
+ case indentation
260
+ when 1 then %r/^( {0}[+*-])(#{PATTERN_TAIL})/o
261
+ when 2 then %r/^( {0,1}[+*-])(#{PATTERN_TAIL})/o
262
+ when 3 then %r/^( {0,2}[+*-])(#{PATTERN_TAIL})/o
263
+ else %r/^( {0,3}[+*-])(#{PATTERN_TAIL})/o
264
+ end
265
+ elsif type == :ol
266
+ case indentation
267
+ when 1 then %r/^( {0}\d+\.)(#{PATTERN_TAIL})/o
268
+ when 2 then %r/^( {0,1}\d+\.)(#{PATTERN_TAIL})/o
269
+ when 3 then %r/^( {0,2}\d+\.)(#{PATTERN_TAIL})/o
270
+ else %r/^( {0,3}\d+\.)(#{PATTERN_TAIL})/o
271
+ end
272
+ elsif type == :dl
273
+ case indentation
274
+ when 1 then %r/^( {0}:)(#{PATTERN_TAIL})/o
275
+ when 2 then %r/^( {0,1}:)(#{PATTERN_TAIL})/o
276
+ when 3 then %r/^( {0,2}:)(#{PATTERN_TAIL})/o
277
+ else %r/^( {0,3}:)(#{PATTERN_TAIL})/o
278
+ end
279
+ end
280
+ end
281
+
282
+ end
283
+ end
284
+ end
@@ -0,0 +1,53 @@
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ require 'kramdown/parser/kramdown/block_boundary'
11
+
12
+ module Kramdown
13
+ module Parser
14
+ class Kramdown
15
+
16
+ BLOCK_MATH_START = /^#{OPT_SPACE}(\\)?\$\$(.*?)\$\$(\s*?\n)?/m
17
+
18
+ # Parse the math block at the current location.
19
+ def parse_block_math
20
+ start_line_number = @src.current_line_number
21
+ if !after_block_boundary?
22
+ return false
23
+ elsif @src[1]
24
+ @src.scan(/^#{OPT_SPACE}\\/o) if @src[3]
25
+ return false
26
+ end
27
+
28
+ saved_pos = @src.save_pos
29
+ @src.pos += @src.matched_size
30
+ data = @src[2].strip
31
+ if before_block_boundary?
32
+ @tree.children << new_block_el(:math, data, nil, category: :block, location: start_line_number)
33
+ true
34
+ else
35
+ @src.revert_pos(saved_pos)
36
+ false
37
+ end
38
+ end
39
+ define_parser(:block_math, BLOCK_MATH_START)
40
+
41
+ INLINE_MATH_START = /\$\$(.*?)\$\$/m
42
+
43
+ # Parse the inline math at the current location.
44
+ def parse_inline_math
45
+ start_line_number = @src.current_line_number
46
+ @src.pos += @src.matched_size
47
+ @tree.children << Element.new(:math, @src[1].strip, nil, category: :span, location: start_line_number)
48
+ end
49
+ define_parser(:inline_math, INLINE_MATH_START, '\$')
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,62 @@
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ require 'kramdown/parser/kramdown/blank_line'
11
+ require 'kramdown/parser/kramdown/extensions'
12
+ require 'kramdown/parser/kramdown/eob'
13
+ require 'kramdown/parser/kramdown/list'
14
+ require 'kramdown/parser/kramdown/html'
15
+
16
+ module Kramdown
17
+ module Parser
18
+ class Kramdown
19
+
20
+ LAZY_END_HTML_SPAN_ELEMENTS = HTML_SPAN_ELEMENTS + %w[script]
21
+ LAZY_END_HTML_START = /<(?>(?!(?:#{LAZY_END_HTML_SPAN_ELEMENTS.join('|')})\b)#{REXML::Parsers::BaseParser::UNAME_STR})/
22
+ LAZY_END_HTML_STOP = /<\/(?!(?:#{LAZY_END_HTML_SPAN_ELEMENTS.join('|')})\b)#{REXML::Parsers::BaseParser::UNAME_STR}\s*>/m
23
+
24
+ LAZY_END = /#{BLANK_LINE}|#{IAL_BLOCK_START}|#{EOB_MARKER}|^#{OPT_SPACE}#{LAZY_END_HTML_STOP}|^#{OPT_SPACE}#{LAZY_END_HTML_START}|\Z/
25
+
26
+ PARAGRAPH_START = /^#{OPT_SPACE}[^ \t].*?\n/
27
+ PARAGRAPH_MATCH = /^.*?\n/
28
+ PARAGRAPH_END = /#{LAZY_END}|#{DEFINITION_LIST_START}/
29
+
30
+ # Parse the paragraph at the current location.
31
+ def parse_paragraph
32
+ pos = @src.pos
33
+ start_line_number = @src.current_line_number
34
+ result = @src.scan(PARAGRAPH_MATCH)
35
+ until @src.match?(paragraph_end)
36
+ result << @src.scan(PARAGRAPH_MATCH)
37
+ end
38
+ result.rstrip!
39
+ if (last_child = @tree.children.last) && last_child.type == :p
40
+ last_item_in_para = last_child.children.last
41
+ if last_item_in_para && last_item_in_para.type == @text_type
42
+ joiner = (extract_string((pos - 3)...pos, @src) == " \n" ? " \n" : "\n")
43
+ last_item_in_para.value << joiner << result
44
+ else
45
+ add_text(result, last_child)
46
+ end
47
+ else
48
+ @tree.children << new_block_el(:p, nil, nil, location: start_line_number)
49
+ result.lstrip!
50
+ add_text(result, @tree.children.last)
51
+ end
52
+ true
53
+ end
54
+ define_parser(:paragraph, PARAGRAPH_START)
55
+
56
+ def paragraph_end
57
+ self.class::PARAGRAPH_END
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,174 @@
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown which is licensed under the MIT.
7
+ #++
8
+ #
9
+ #--
10
+ # Parts of this file are based on code from RubyPants:
11
+ #
12
+ # = RubyPants -- SmartyPants ported to Ruby
13
+ #
14
+ # Ported by Christian Neukirchen <mailto:chneukirchen@gmail.com>
15
+ # Copyright (C) 2004 Christian Neukirchen
16
+ #
17
+ # Incooporates ideas, comments and documentation by Chad Miller
18
+ # Copyright (C) 2004 Chad Miller
19
+ #
20
+ # Original SmartyPants by John Gruber
21
+ # Copyright (C) 2003 John Gruber
22
+ #
23
+ #
24
+ # = RubyPants -- SmartyPants ported to Ruby
25
+ #
26
+ #
27
+ # [snip]
28
+ #
29
+ # == Authors
30
+ #
31
+ # John Gruber did all of the hard work of writing this software in
32
+ # Perl for Movable Type and almost all of this useful documentation.
33
+ # Chad Miller ported it to Python to use with Pyblosxom.
34
+ #
35
+ # Christian Neukirchen provided the Ruby port, as a general-purpose
36
+ # library that follows the *Cloth API.
37
+ #
38
+ #
39
+ # == Copyright and License
40
+ #
41
+ # === SmartyPants license:
42
+ #
43
+ # Copyright (c) 2003 John Gruber
44
+ # (http://daringfireball.net)
45
+ # All rights reserved.
46
+ #
47
+ # Redistribution and use in source and binary forms, with or without
48
+ # modification, are permitted provided that the following conditions
49
+ # are met:
50
+ #
51
+ # * Redistributions of source code must retain the above copyright
52
+ # notice, this list of conditions and the following disclaimer.
53
+ #
54
+ # * Redistributions in binary form must reproduce the above copyright
55
+ # notice, this list of conditions and the following disclaimer in
56
+ # the documentation and/or other materials provided with the
57
+ # distribution.
58
+ #
59
+ # * Neither the name "SmartyPants" nor the names of its contributors
60
+ # may be used to endorse or promote products derived from this
61
+ # software without specific prior written permission.
62
+ #
63
+ # This software is provided by the copyright holders and contributors
64
+ # "as is" and any express or implied warranties, including, but not
65
+ # limited to, the implied warranties of merchantability and fitness
66
+ # for a particular purpose are disclaimed. In no event shall the
67
+ # copyright owner or contributors be liable for any direct, indirect,
68
+ # incidental, special, exemplary, or consequential damages (including,
69
+ # but not limited to, procurement of substitute goods or services;
70
+ # loss of use, data, or profits; or business interruption) however
71
+ # caused and on any theory of liability, whether in contract, strict
72
+ # liability, or tort (including negligence or otherwise) arising in
73
+ # any way out of the use of this software, even if advised of the
74
+ # possibility of such damage.
75
+ #
76
+ # === RubyPants license
77
+ #
78
+ # RubyPants is a derivative work of SmartyPants and smartypants.py.
79
+ #
80
+ # Redistribution and use in source and binary forms, with or without
81
+ # modification, are permitted provided that the following conditions
82
+ # are met:
83
+ #
84
+ # * Redistributions of source code must retain the above copyright
85
+ # notice, this list of conditions and the following disclaimer.
86
+ #
87
+ # * Redistributions in binary form must reproduce the above copyright
88
+ # notice, this list of conditions and the following disclaimer in
89
+ # the documentation and/or other materials provided with the
90
+ # distribution.
91
+ #
92
+ # This software is provided by the copyright holders and contributors
93
+ # "as is" and any express or implied warranties, including, but not
94
+ # limited to, the implied warranties of merchantability and fitness
95
+ # for a particular purpose are disclaimed. In no event shall the
96
+ # copyright owner or contributors be liable for any direct, indirect,
97
+ # incidental, special, exemplary, or consequential damages (including,
98
+ # but not limited to, procurement of substitute goods or services;
99
+ # loss of use, data, or profits; or business interruption) however
100
+ # caused and on any theory of liability, whether in contract, strict
101
+ # liability, or tort (including negligence or otherwise) arising in
102
+ # any way out of the use of this software, even if advised of the
103
+ # possibility of such damage.
104
+ #
105
+ # == Links
106
+ #
107
+ # John Gruber:: http://daringfireball.net
108
+ # SmartyPants:: http://daringfireball.net/projects/smartypants
109
+ #
110
+ # Chad Miller:: http://web.chad.org
111
+ #
112
+ # Christian Neukirchen:: http://kronavita.de/chris
113
+ #
114
+ #++
115
+ #
116
+
117
+ module Kramdown
118
+ module Parser
119
+ class Kramdown
120
+
121
+ SQ_PUNCT = '[!"#\$\%\'()*+,\-.\/:;<=>?\@\[\\\\\]\^_`{|}~]'
122
+ SQ_CLOSE = %![^\ \\\\\t\r\n\\[{(-]!
123
+
124
+ SQ_RULES = [
125
+ [/("|')(?=[_*]{1,2}\S)/, [:lquote1]],
126
+ [/("|')(?=#{SQ_PUNCT}(?!\.\.)\B)/, [:rquote1]],
127
+ # Special case for double sets of quotes, e.g.:
128
+ # <p>He said, "'Quoted' words in a larger quote."</p>
129
+ [/(\s?)"'(?=\w)/, [1, :ldquo, :lsquo]],
130
+ [/(\s?)'"(?=\w)/, [1, :lsquo, :ldquo]],
131
+ # Special case for decade abbreviations (the '80s):
132
+ [/(\s?)'(?=\d\ds)/, [1, :rsquo]],
133
+
134
+ # Get most opening single/double quotes:
135
+ [/(\s)('|")(?=\w)/, [1, :lquote2]],
136
+ # Single/double closing quotes:
137
+ [/(#{SQ_CLOSE})('|")/, [1, :rquote2]],
138
+ # Special case for e.g. "<i>Custer</i>'s Last Stand."
139
+ [/("|')(?=\s|s\b|$)/, [:rquote1]],
140
+ # Any remaining single quotes should be opening ones:
141
+ [/(.?)'/m, [1, :lsquo]],
142
+ [/(.?)"/m, [1, :ldquo]],
143
+ ] # '"
144
+
145
+ SQ_SUBSTS = {
146
+ [:rquote1, '"'] => :rdquo,
147
+ [:rquote1, "'"] => :rsquo,
148
+ [:rquote2, '"'] => :rdquo,
149
+ [:rquote2, "'"] => :rsquo,
150
+ [:lquote1, '"'] => :ldquo,
151
+ [:lquote1, "'"] => :lsquo,
152
+ [:lquote2, '"'] => :ldquo,
153
+ [:lquote2, "'"] => :lsquo,
154
+ }
155
+ SMART_QUOTES_RE = /[^\\]?["']/
156
+
157
+ # Parse the smart quotes at current location.
158
+ def parse_smart_quotes
159
+ start_line_number = @src.current_line_number
160
+ substs = SQ_RULES.find {|reg, _subst| @src.scan(reg) }[1]
161
+ substs.each do |subst|
162
+ if subst.kind_of?(Integer)
163
+ add_text(@src[subst])
164
+ else
165
+ val = SQ_SUBSTS[[subst, @src[subst.to_s[-1, 1].to_i]]] || subst
166
+ @tree.children << Element.new(:smart_quote, val, nil, location: start_line_number)
167
+ end
168
+ end
169
+ end
170
+ define_parser(:smart_quotes, SMART_QUOTES_RE, '[^\\\\]?["\']')
171
+
172
+ end
173
+ end
174
+ end