kramdown-asciidoc 1.0.0.alpha.3 → 1.0.0.alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +25 -0
  3. data/README.adoc +3 -2
  4. data/bin/kramdoc +1 -1
  5. data/kramdown-asciidoc.gemspec +3 -3
  6. data/lib/kramdown-asciidoc.rb +2 -3
  7. data/lib/kramdown-asciidoc/converter.rb +85 -47
  8. data/lib/kramdown-asciidoc/version.rb +1 -1
  9. data/spec/converter_spec.rb +139 -10
  10. data/spec/integration_spec.rb +3 -5
  11. data/spec/{fixtures → scenarios}/a/bare-url.adoc +0 -0
  12. data/spec/{fixtures → scenarios}/a/bare-url.md +0 -0
  13. data/spec/{fixtures → scenarios}/a/containing-inline-image.adoc +0 -0
  14. data/spec/{fixtures → scenarios}/a/containing-inline-image.md +0 -0
  15. data/spec/{fixtures → scenarios}/a/double-underscore-in-url.adoc +0 -0
  16. data/spec/{fixtures → scenarios}/a/double-underscore-in-url.md +0 -0
  17. data/spec/{fixtures → scenarios}/a/interdoc-xref.adoc +0 -0
  18. data/spec/{fixtures → scenarios}/a/interdoc-xref.md +0 -0
  19. data/spec/{fixtures → scenarios}/a/internal.adoc +0 -0
  20. data/spec/{fixtures → scenarios}/a/internal.md +0 -0
  21. data/spec/{fixtures → scenarios}/a/local.adoc +0 -0
  22. data/spec/{fixtures → scenarios}/a/local.md +0 -0
  23. data/spec/scenarios/a/url-matches-text.adoc +2 -0
  24. data/spec/scenarios/a/url-matches-text.md +2 -0
  25. data/spec/{fixtures → scenarios}/a/url-with-text.adoc +0 -0
  26. data/spec/{fixtures → scenarios}/a/url-with-text.md +0 -0
  27. data/spec/{fixtures/blockquote/with-attribution.adoc → scenarios/blockquote/attribution-separated.adoc} +0 -0
  28. data/spec/scenarios/blockquote/attribution-separated.md +4 -0
  29. data/spec/{fixtures → scenarios}/blockquote/basic.adoc +0 -0
  30. data/spec/{fixtures → scenarios}/blockquote/basic.md +0 -0
  31. data/spec/scenarios/blockquote/deep-nested.adoc +14 -0
  32. data/spec/scenarios/blockquote/deep-nested.md +6 -0
  33. data/spec/{fixtures → scenarios}/blockquote/list.adoc +0 -0
  34. data/spec/{fixtures → scenarios}/blockquote/list.md +0 -0
  35. data/spec/{fixtures → scenarios}/blockquote/multiple-lines.adoc +0 -0
  36. data/spec/{fixtures → scenarios}/blockquote/multiple-lines.md +0 -0
  37. data/spec/{fixtures → scenarios}/blockquote/nested.adoc +0 -0
  38. data/spec/{fixtures → scenarios}/blockquote/nested.md +0 -0
  39. data/spec/scenarios/blockquote/with-attribution.adoc +5 -0
  40. data/spec/{fixtures → scenarios}/blockquote/with-attribution.md +0 -0
  41. data/spec/scenarios/br/leading-tag.adoc +2 -0
  42. data/spec/scenarios/br/leading-tag.md +2 -0
  43. data/spec/{fixtures → scenarios}/br/tag-followed-by-newline.adoc +0 -0
  44. data/spec/{fixtures → scenarios}/br/tag-followed-by-newline.md +0 -0
  45. data/spec/{fixtures → scenarios}/br/tag-in-table-cell.adoc +0 -0
  46. data/spec/{fixtures → scenarios}/br/tag-in-table-cell.md +0 -0
  47. data/spec/{fixtures → scenarios}/br/tag-preceded-by-space.adoc +0 -0
  48. data/spec/{fixtures → scenarios}/br/tag-preceded-by-space.md +0 -0
  49. data/spec/{fixtures → scenarios}/br/tag.adoc +0 -0
  50. data/spec/{fixtures → scenarios}/br/tag.md +0 -0
  51. data/spec/{fixtures → scenarios}/br/trailing-double-space.adoc +0 -0
  52. data/spec/{fixtures → scenarios}/br/trailing-double-space.md +0 -0
  53. data/spec/scenarios/codeblock/contiguous-lines.adoc +3 -0
  54. data/spec/{fixtures → scenarios}/codeblock/contiguous-lines.md +0 -0
  55. data/spec/{fixtures → scenarios}/codeblock/fenced/with-command-prompt.adoc +0 -0
  56. data/spec/{fixtures → scenarios}/codeblock/fenced/with-command-prompt.md +0 -0
  57. data/spec/{fixtures → scenarios}/codeblock/fenced/with-language.adoc +0 -0
  58. data/spec/{fixtures → scenarios}/codeblock/fenced/with-language.md +0 -0
  59. data/spec/{fixtures → scenarios}/codeblock/fenced/with-non-contiguous-command-prompts.adoc +3 -2
  60. data/spec/{fixtures → scenarios}/codeblock/fenced/with-non-contiguous-command-prompts.md +0 -0
  61. data/spec/{fixtures → scenarios}/codeblock/fenced/without-language.adoc +0 -0
  62. data/spec/{fixtures → scenarios}/codeblock/fenced/without-language.md +0 -0
  63. data/spec/{fixtures → scenarios}/codeblock/non-contiguous-lines.adoc +2 -2
  64. data/spec/{fixtures → scenarios}/codeblock/non-contiguous-lines.md +0 -0
  65. data/spec/{fixtures → scenarios}/codeblock/with-command-prompt.adoc +0 -0
  66. data/spec/{fixtures → scenarios}/codeblock/with-command-prompt.md +0 -0
  67. data/spec/{fixtures → scenarios}/codeblock/with-non-contiguous-command-prompts.adoc +3 -2
  68. data/spec/{fixtures → scenarios}/codeblock/with-non-contiguous-command-prompts.md +0 -0
  69. data/spec/{fixtures → scenarios}/codespan/constrained.adoc +0 -0
  70. data/spec/{fixtures → scenarios}/codespan/constrained.md +0 -0
  71. data/spec/{fixtures → scenarios}/codespan/literal.adoc +0 -0
  72. data/spec/{fixtures → scenarios}/codespan/literal.md +0 -0
  73. data/spec/scenarios/dlist/compound.adoc +13 -0
  74. data/spec/scenarios/dlist/compound.md +7 -0
  75. data/spec/scenarios/dlist/nested-mixed.adoc +11 -0
  76. data/spec/scenarios/dlist/nested-mixed.md +11 -0
  77. data/spec/scenarios/dlist/nested.adoc +23 -0
  78. data/spec/scenarios/dlist/nested.md +23 -0
  79. data/spec/scenarios/dlist/simple.adoc +5 -0
  80. data/spec/scenarios/dlist/simple.md +5 -0
  81. data/spec/{fixtures → scenarios}/em/asterisks.adoc +0 -0
  82. data/spec/{fixtures → scenarios}/em/asterisks.md +0 -0
  83. data/spec/scenarios/em/constrained.adoc +1 -0
  84. data/spec/scenarios/em/constrained.md +1 -0
  85. data/spec/scenarios/em/strong.adoc +1 -0
  86. data/spec/scenarios/em/strong.md +1 -0
  87. data/spec/{fixtures → scenarios}/entity/numeric.adoc +0 -0
  88. data/spec/{fixtures → scenarios}/entity/numeric.md +0 -0
  89. data/spec/{fixtures → scenarios}/entity/reverse.adoc +0 -0
  90. data/spec/{fixtures → scenarios}/entity/reverse.md +0 -0
  91. data/spec/{fixtures → scenarios}/heading/block-title.adoc +1 -0
  92. data/spec/{fixtures → scenarios}/heading/block-title.md +3 -1
  93. data/spec/{fixtures → scenarios}/heading/not-block-title.adoc +0 -0
  94. data/spec/{fixtures → scenarios}/heading/not-block-title.md +0 -0
  95. data/spec/{fixtures → scenarios}/heading/out-of-sequence.adoc +0 -0
  96. data/spec/{fixtures → scenarios}/heading/out-of-sequence.md +0 -0
  97. data/spec/{fixtures → scenarios}/heading/outline.adoc +0 -0
  98. data/spec/{fixtures → scenarios}/heading/outline.md +0 -0
  99. data/spec/{fixtures → scenarios}/heading/with-anchor.adoc +0 -0
  100. data/spec/{fixtures → scenarios}/heading/with-anchor.md +0 -0
  101. data/spec/{fixtures → scenarios}/heading/with-formatting.adoc +0 -0
  102. data/spec/{fixtures → scenarios}/heading/with-formatting.md +0 -0
  103. data/spec/scenarios/hr/around-block.adoc +5 -0
  104. data/spec/scenarios/hr/around-block.md +5 -0
  105. data/spec/{fixtures → scenarios}/hr/between-blocks.adoc +0 -0
  106. data/spec/{fixtures → scenarios}/hr/between-blocks.md +0 -0
  107. data/spec/{fixtures → scenarios}/hr/dashes.adoc +0 -0
  108. data/spec/{fixtures → scenarios}/hr/dashes.md +0 -0
  109. data/spec/{fixtures → scenarios}/html_element/abbr.adoc +0 -0
  110. data/spec/{fixtures → scenarios}/html_element/abbr.md +0 -0
  111. data/spec/{fixtures → scenarios}/html_element/admonition.adoc +0 -0
  112. data/spec/{fixtures → scenarios}/html_element/admonition.md +0 -0
  113. data/spec/{fixtures → scenarios}/html_element/empty-p.adoc +0 -0
  114. data/spec/{fixtures → scenarios}/html_element/empty-p.md +0 -0
  115. data/spec/{fixtures → scenarios}/html_element/heading-with-class.adoc +0 -0
  116. data/spec/{fixtures → scenarios}/html_element/heading-with-class.md +0 -0
  117. data/spec/{fixtures → scenarios}/html_element/heading-with-id.adoc +0 -0
  118. data/spec/{fixtures → scenarios}/html_element/heading-with-id.md +0 -0
  119. data/spec/{fixtures → scenarios}/html_element/img-with-alt-and-width.adoc +0 -0
  120. data/spec/{fixtures → scenarios}/html_element/img-with-alt-and-width.md +0 -0
  121. data/spec/scenarios/html_element/img-with-percentage-width-css.adoc +1 -0
  122. data/spec/scenarios/html_element/img-with-percentage-width-css.md +1 -0
  123. data/spec/scenarios/html_element/img-with-percentage-width.adoc +1 -0
  124. data/spec/scenarios/html_element/img-with-percentage-width.md +1 -0
  125. data/spec/{fixtures/html_element/img-with-css-width.adoc → scenarios/html_element/img-with-width-css.adoc} +0 -0
  126. data/spec/{fixtures/html_element/img-with-css-width.md → scenarios/html_element/img-with-width-css.md} +0 -0
  127. data/spec/{fixtures → scenarios}/html_element/img-with-width.adoc +0 -0
  128. data/spec/{fixtures → scenarios}/html_element/img-with-width.md +0 -0
  129. data/spec/{fixtures → scenarios}/html_element/img.adoc +0 -0
  130. data/spec/{fixtures → scenarios}/html_element/img.md +0 -0
  131. data/spec/{fixtures → scenarios}/html_element/native.adoc +0 -0
  132. data/spec/{fixtures → scenarios}/html_element/native.md +0 -0
  133. data/spec/scenarios/html_element/pre-code-with-language.adoc +6 -0
  134. data/spec/scenarios/html_element/pre-code-with-language.md +4 -0
  135. data/spec/scenarios/html_element/strike.adoc +1 -0
  136. data/spec/scenarios/html_element/strike.md +1 -0
  137. data/spec/{fixtures → scenarios}/html_element/sub.adoc +0 -0
  138. data/spec/{fixtures → scenarios}/html_element/sub.md +0 -0
  139. data/spec/{fixtures → scenarios}/html_element/sup.adoc +0 -0
  140. data/spec/{fixtures → scenarios}/html_element/sup.md +0 -0
  141. data/spec/scenarios/img/block-in-list.adoc +5 -0
  142. data/spec/scenarios/img/block-in-list.md +5 -0
  143. data/spec/{fixtures → scenarios}/img/block-with-alt.adoc +0 -0
  144. data/spec/{fixtures → scenarios}/img/block-with-alt.md +0 -0
  145. data/spec/{fixtures → scenarios}/img/block-with-link-and-alt.adoc +0 -0
  146. data/spec/{fixtures → scenarios}/img/block-with-link-and-alt.md +0 -0
  147. data/spec/{fixtures → scenarios}/img/block-with-link.adoc +0 -0
  148. data/spec/{fixtures → scenarios}/img/block-with-link.md +0 -0
  149. data/spec/{fixtures → scenarios}/img/block.adoc +0 -0
  150. data/spec/{fixtures → scenarios}/img/block.md +0 -0
  151. data/spec/{fixtures → scenarios}/img/imagesdir.adoc +0 -0
  152. data/spec/{fixtures → scenarios}/img/imagesdir.md +0 -0
  153. data/spec/{fixtures → scenarios}/img/imagesdir.opts +0 -0
  154. data/spec/{fixtures → scenarios}/img/implicit-imagesdir.adoc +0 -0
  155. data/spec/{fixtures → scenarios}/img/implicit-imagesdir.md +0 -0
  156. data/spec/{fixtures → scenarios}/img/implicit-imagesdir.opts +0 -0
  157. data/spec/{fixtures → scenarios}/img/inline-with-alt.adoc +0 -0
  158. data/spec/{fixtures → scenarios}/img/inline-with-alt.md +0 -0
  159. data/spec/{fixtures → scenarios}/img/inline-with-link-and-alt.adoc +0 -0
  160. data/spec/{fixtures → scenarios}/img/inline-with-link-and-alt.md +0 -0
  161. data/spec/{fixtures → scenarios}/img/inline-with-link.adoc +0 -0
  162. data/spec/{fixtures → scenarios}/img/inline-with-link.md +0 -0
  163. data/spec/{fixtures → scenarios}/img/inline.adoc +0 -0
  164. data/spec/{fixtures → scenarios}/img/inline.md +0 -0
  165. data/spec/{fixtures → scenarios}/ol/compound-separated.adoc +5 -1
  166. data/spec/{fixtures/ol/compound.md → scenarios/ol/compound-separated.md} +8 -1
  167. data/spec/{fixtures → scenarios}/ol/compound.adoc +5 -1
  168. data/spec/{fixtures/ol/compound-separated.md → scenarios/ol/compound.md} +3 -6
  169. data/spec/scenarios/ol/formatted.adoc +3 -0
  170. data/spec/scenarios/ol/formatted.md +3 -0
  171. data/spec/{fixtures → scenarios}/ol/mixed-separated.adoc +0 -0
  172. data/spec/{fixtures → scenarios}/ol/mixed-separated.md +0 -0
  173. data/spec/{fixtures → scenarios}/ol/mixed.adoc +0 -0
  174. data/spec/{fixtures → scenarios}/ol/mixed.md +0 -0
  175. data/spec/scenarios/ol/nested-mixed.adoc +8 -0
  176. data/spec/scenarios/ol/nested-mixed.md +8 -0
  177. data/spec/{fixtures → scenarios}/ol/nested-separated.adoc +0 -0
  178. data/spec/{fixtures → scenarios}/ol/nested-separated.md +0 -0
  179. data/spec/{fixtures → scenarios}/ol/nested.adoc +0 -0
  180. data/spec/{fixtures → scenarios}/ol/nested.md +0 -0
  181. data/spec/{fixtures → scenarios}/ol/simple-separated.adoc +0 -0
  182. data/spec/{fixtures → scenarios}/ol/simple-separated.md +0 -0
  183. data/spec/{fixtures → scenarios}/ol/simple.adoc +0 -0
  184. data/spec/{fixtures → scenarios}/ol/simple.md +0 -0
  185. data/spec/{fixtures → scenarios}/p/admonition/emphasis.adoc +0 -0
  186. data/spec/{fixtures → scenarios}/p/admonition/emphasis.md +0 -0
  187. data/spec/{fixtures → scenarios}/p/admonition/in-list-item.adoc +0 -0
  188. data/spec/{fixtures → scenarios}/p/admonition/in-list-item.md +0 -0
  189. data/spec/{fixtures → scenarios}/p/admonition/plain.adoc +0 -0
  190. data/spec/{fixtures → scenarios}/p/admonition/plain.md +0 -0
  191. data/spec/{fixtures → scenarios}/p/admonition/strong-emphasis.adoc +0 -0
  192. data/spec/{fixtures → scenarios}/p/admonition/strong-emphasis.md +0 -0
  193. data/spec/{fixtures → scenarios}/p/multiple-lines.adoc +0 -0
  194. data/spec/{fixtures → scenarios}/p/multiple-lines.md +0 -0
  195. data/spec/{fixtures → scenarios}/p/sequential.adoc +0 -0
  196. data/spec/{fixtures → scenarios}/p/sequential.md +0 -0
  197. data/spec/{fixtures → scenarios}/p/single-line.adoc +0 -0
  198. data/spec/{fixtures → scenarios}/p/single-line.md +0 -0
  199. data/spec/{fixtures → scenarios}/root/body-only.adoc +0 -0
  200. data/spec/{fixtures → scenarios}/root/body-only.md +0 -0
  201. data/spec/{fixtures → scenarios}/root/book-doctype.adoc +0 -0
  202. data/spec/{fixtures → scenarios}/root/book-doctype.md +0 -0
  203. data/spec/{fixtures → scenarios}/root/header-and-body.adoc +0 -0
  204. data/spec/{fixtures → scenarios}/root/header-and-body.md +0 -0
  205. data/spec/{fixtures → scenarios}/root/header-only.adoc +0 -0
  206. data/spec/{fixtures → scenarios}/root/header-only.md +0 -0
  207. data/spec/{fixtures → scenarios}/smart_quote/apostrophe.adoc +0 -0
  208. data/spec/{fixtures → scenarios}/smart_quote/apostrophe.md +0 -0
  209. data/spec/{fixtures → scenarios}/smart_quote/double-quotes.adoc +0 -0
  210. data/spec/{fixtures → scenarios}/smart_quote/double-quotes.md +0 -0
  211. data/spec/{fixtures → scenarios}/smart_quote/single-quotes.adoc +0 -0
  212. data/spec/{fixtures → scenarios}/smart_quote/single-quotes.md +0 -0
  213. data/spec/scenarios/strong/constrained.adoc +1 -0
  214. data/spec/scenarios/strong/constrained.md +1 -0
  215. data/spec/scenarios/strong/menu.adoc +3 -0
  216. data/spec/scenarios/strong/menu.md +1 -0
  217. data/spec/{fixtures → scenarios}/strong/nested-emphasis.adoc +0 -0
  218. data/spec/{fixtures → scenarios}/strong/nested-emphasis.md +0 -0
  219. data/spec/{fixtures → scenarios}/table/alignment.adoc +0 -0
  220. data/spec/{fixtures → scenarios}/table/alignment.md +0 -0
  221. data/spec/scenarios/table/cell-with-image.adoc +9 -0
  222. data/spec/scenarios/table/cell-with-image.md +4 -0
  223. data/spec/{fixtures → scenarios}/table/cell-with-pipe.adoc +0 -0
  224. data/spec/{fixtures → scenarios}/table/cell-with-pipe.md +0 -0
  225. data/spec/{fixtures → scenarios}/table/single-column-with-header.adoc +0 -0
  226. data/spec/{fixtures → scenarios}/table/single-column-with-header.md +0 -0
  227. data/spec/{fixtures → scenarios}/table/single-column-without-header.adoc +0 -0
  228. data/spec/{fixtures → scenarios}/table/single-column-without-header.md +0 -0
  229. data/spec/{fixtures → scenarios}/table/with-header.adoc +0 -0
  230. data/spec/{fixtures → scenarios}/table/with-header.md +0 -0
  231. data/spec/{fixtures → scenarios}/table/without-header.adoc +0 -0
  232. data/spec/{fixtures → scenarios}/table/without-header.md +0 -0
  233. data/spec/{fixtures → scenarios}/text/caret.adoc +0 -0
  234. data/spec/{fixtures → scenarios}/text/caret.md +0 -0
  235. data/spec/{fixtures → scenarios}/text/lte.adoc +0 -0
  236. data/spec/{fixtures → scenarios}/text/lte.md +0 -0
  237. data/spec/{fixtures → scenarios}/text/plus-plus.adoc +0 -0
  238. data/spec/{fixtures → scenarios}/text/plus-plus.md +0 -0
  239. data/spec/{fixtures → scenarios}/text/typographic_sym/apostrophe.adoc +0 -0
  240. data/spec/{fixtures → scenarios}/text/typographic_sym/apostrophe.md +0 -0
  241. data/spec/{fixtures → scenarios}/text/typographic_sym/double-quotes.adoc +0 -0
  242. data/spec/{fixtures → scenarios}/text/typographic_sym/double-quotes.md +0 -0
  243. data/spec/{fixtures → scenarios}/text/typographic_sym/ellipsis.adoc +0 -0
  244. data/spec/{fixtures → scenarios}/text/typographic_sym/ellipsis.md +0 -0
  245. data/spec/{fixtures → scenarios}/text/typographic_sym/mdash.adoc +0 -0
  246. data/spec/{fixtures → scenarios}/text/typographic_sym/mdash.md +0 -0
  247. data/spec/{fixtures → scenarios}/text/typographic_sym/ndash.adoc +0 -0
  248. data/spec/{fixtures → scenarios}/text/typographic_sym/ndash.md +0 -0
  249. data/spec/{fixtures → scenarios}/text/typographic_sym/single-quotes.adoc +0 -0
  250. data/spec/{fixtures → scenarios}/text/typographic_sym/single-quotes.md +0 -0
  251. data/spec/scenarios/trailing_space.adoc +7 -0
  252. data/spec/scenarios/trailing_space.md +7 -0
  253. data/spec/{fixtures → scenarios}/typographic_sym/ellipsis.adoc +0 -0
  254. data/spec/{fixtures → scenarios}/typographic_sym/ellipsis.md +0 -0
  255. data/spec/{fixtures → scenarios}/typographic_sym/mdash.adoc +0 -0
  256. data/spec/{fixtures → scenarios}/typographic_sym/mdash.md +0 -0
  257. data/spec/{fixtures → scenarios}/typographic_sym/ndash.adoc +0 -0
  258. data/spec/{fixtures → scenarios}/typographic_sym/ndash.md +0 -0
  259. data/spec/scenarios/ul/blockquote.adoc +5 -0
  260. data/spec/scenarios/ul/blockquote.md +2 -0
  261. data/spec/scenarios/ul/compound-nested.adoc +21 -0
  262. data/spec/scenarios/ul/compound-nested.md +17 -0
  263. data/spec/{fixtures → scenarios}/ul/compound-separated.adoc +5 -1
  264. data/spec/{fixtures/ul/compound.md → scenarios/ul/compound-separated.md} +8 -1
  265. data/spec/{fixtures → scenarios}/ul/compound.adoc +5 -1
  266. data/spec/{fixtures/ul/compound-separated.md → scenarios/ul/compound.md} +3 -6
  267. data/spec/scenarios/ul/formatted.adoc +3 -0
  268. data/spec/scenarios/ul/formatted.md +3 -0
  269. data/spec/{fixtures → scenarios}/ul/nested-separated.adoc +0 -0
  270. data/spec/{fixtures → scenarios}/ul/nested-separated.md +0 -0
  271. data/spec/{fixtures → scenarios}/ul/nested.adoc +0 -0
  272. data/spec/{fixtures → scenarios}/ul/nested.md +0 -0
  273. data/spec/{fixtures → scenarios}/ul/simple-separated.adoc +0 -0
  274. data/spec/{fixtures → scenarios}/ul/simple-separated.md +0 -0
  275. data/spec/{fixtures → scenarios}/ul/simple.adoc +0 -0
  276. data/spec/{fixtures → scenarios}/ul/simple.md +0 -0
  277. data/spec/{fixtures → scenarios}/xml_comment/above-header.adoc +0 -0
  278. data/spec/{fixtures → scenarios}/xml_comment/above-header.md +0 -0
  279. data/spec/scenarios/xml_comment/at-start-of-line.adoc +9 -0
  280. data/spec/scenarios/xml_comment/at-start-of-line.md +4 -0
  281. data/spec/{fixtures → scenarios}/xml_comment/block.adoc +0 -0
  282. data/spec/{fixtures → scenarios}/xml_comment/block.md +0 -0
  283. data/spec/{fixtures → scenarios}/xml_comment/line-offset-by-space.adoc +0 -0
  284. data/spec/{fixtures → scenarios}/xml_comment/line-offset-by-space.md +0 -0
  285. data/spec/{fixtures → scenarios}/xml_comment/line.adoc +0 -0
  286. data/spec/{fixtures → scenarios}/xml_comment/line.md +0 -0
  287. data/spec/{fixtures → scenarios}/xml_comment/list-separator.adoc +1 -1
  288. data/spec/{fixtures → scenarios}/xml_comment/list-separator.md +0 -0
  289. data/spec/{fixtures → scenarios}/xml_comment/mixed.adoc +0 -0
  290. data/spec/{fixtures → scenarios}/xml_comment/mixed.md +0 -0
  291. data/spec/{fixtures → scenarios}/xml_comment/multiline-span.adoc +0 -0
  292. data/spec/{fixtures → scenarios}/xml_comment/multiline-span.md +0 -0
  293. data/spec/{fixtures → scenarios}/xml_comment/styled.adoc +0 -0
  294. data/spec/{fixtures → scenarios}/xml_comment/styled.md +0 -0
  295. metadata +574 -482
  296. data/spec/fixtures/a/url-matches-text.adoc +0 -1
  297. data/spec/fixtures/a/url-matches-text.md +0 -1
  298. data/spec/fixtures/codeblock/contiguous-lines.adoc +0 -5
  299. data/spec/fixtures/em/constrained.adoc +0 -1
  300. data/spec/fixtures/em/constrained.md +0 -1
  301. data/spec/fixtures/strong/constrained.adoc +0 -1
  302. data/spec/fixtures/strong/constrained.md +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e95a5d12ba8c16a4dffb8257066dda516b072943947fa156ef5e94914451b36d
4
- data.tar.gz: 1381d930ab4aaa34f9ec2bf1ccf274357c76f061a0f4715336bacd6fee7e3124
3
+ metadata.gz: 53feb28cc869ddb3f85b8806d347ca52198d57f723505c65bad3ebc20390fd67
4
+ data.tar.gz: a33879646334f075770400e329ba801e9aa0865d36d2bcc98e6392edd5dd1b84
5
5
  SHA512:
6
- metadata.gz: b3acf70f81410433141239ed11bfc9fb3d498eddeecffad94144a98386aac5146b80ab4609dd3b673609961fefedad7ef5f4a21e05ef34859f3d4915e5e48062
7
- data.tar.gz: cdc0863d2926c1488a263ec73f067ca201038192f35b25c79872507d5da6b81ef70cf53134d40e770c9edbd6170f98079cdd0d05ddc2d33b1b1c80c0ff74b3ea
6
+ metadata.gz: 6428d7de7c8aa6a729b4ccb14b825afcff1855f4b3ec8f9786469c020eb8694b284276ee41e7b9f0e19743e703ba6de1e6ac11c2a408a992e99d5f8a90a40355
7
+ data.tar.gz: ff5cb27de8a2416771e40125015e2fe2fc8c5cdb60adbe8b4cad363761b13598c97a72b0fa75962181b92c8971ef29a7e0e77f5b4bb41b8712abd6d17bc6360d
@@ -5,6 +5,31 @@
5
5
  This document provides a high-level view of the changes to {project-name} by release.
6
6
  For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.
7
7
 
8
+ == 1.0.0.alpha.4 (2018-06-12) - @mojavelinux
9
+
10
+ === Added
11
+
12
+ * convert description (aka definition) lists (#8)
13
+ * detect menu reference and convert to inline menu macro
14
+ * add blank line above nested list that follows compound list item
15
+ * convert codeblock with non-contiguous lines beginning with a command prompt to a source,console listing block
16
+ * use list continuation to attach blockquote to list item
17
+ * handle case when HTML br element appears at start of paragraph
18
+ * allow blockquotes to be nested to an arbitrary depth
19
+ * remove trailing spaces from output
20
+ * convert deleted text span
21
+
22
+ === Changed
23
+
24
+ * use title from front matter as document title if explicit document title (level 1 heading) is absent
25
+ * automatically convert newlines to LF when reading file
26
+ * convert indented codeblock to literal (indented) paragraph
27
+ * change separator comment from //- to //
28
+ * mark br converted from HTML br element
29
+ * round CSS width value for image
30
+ * upgrade kramdown to 1.17.0
31
+ * use correct casing for kramdown in README and library metadata
32
+
8
33
  == 1.0.0.alpha.3 (2018-05-31) - @mojavelinux
9
34
 
10
35
  === Added
@@ -1,6 +1,6 @@
1
1
  = {project-name} (Markdown to AsciiDoc)
2
2
  Dan Allen <https://github.com/mojavelinux>
3
- v1.0.0.alpha.3, 2018-05-31
3
+ v1.0.0.alpha.4, 2018-06-12
4
4
  // Aliases:
5
5
  :project-name: Kramdown AsciiDoc
6
6
  :project-handle: kramdown-asciidoc
@@ -22,6 +22,7 @@ endif::[]
22
22
  :uri-repo: https://github.com/asciidoctor/kramdown-asciidoc
23
23
  :uri-asciidoc: https://asciidoctor.org/docs/what-is-asciidoc/#what-is-asciidoc
24
24
  :uri-asciidoctor: https://asciidoctor.org
25
+ :uri-kramdown: https://kramdown.gettalong.org
25
26
  :uri-rvm: https://rvm.io
26
27
  :uri-rvm-install: https://rvm.io/rvm/install
27
28
  :uri-ci-travis: https://travis-ci.org/asciidoctor/kramdown-asciidoc
@@ -34,7 +35,7 @@ image:{uri-gem-img}[Gem Version,link={uri-gem}]
34
35
  image:{uri-ci-travis-img}[Build Status (Travis CI),link={uri-ci-travis}]
35
36
  endif::[]
36
37
 
37
- {uri-repo}[{project-name}] (gem: *{project-handle}*) is a Kramdown extension for converting Markdown documents to {uri-asciidoc}[AsciiDoc].
38
+ {uri-repo}[{project-name}] (gem: *{project-handle}*) is a {uri-kramdown}[kramdown] extension for converting Markdown documents to {uri-asciidoc}[AsciiDoc].
38
39
  Notably, the converter generates modern AsciiDoc syntax suitable for use with {uri-asciidoctor}[Asciidoctor].
39
40
 
40
41
  == Prerequisites
@@ -12,7 +12,7 @@ unless infile
12
12
  exit 1
13
13
  end
14
14
  outfile = %(#{infile.slice 0, infile.length - (File.extname infile).length}.adoc)
15
- input = (IO.read infile, open_args: ['rb:UTF-8']).rstrip
15
+ input = (IO.read infile, mode: 'r:UTF-8', newline: :universal).rstrip
16
16
  input = input.slice 1, input.length while input.start_with? ?\n
17
17
  attributes = {}
18
18
  input = Kramdown::AsciiDoc.extract_front_matter input, attributes
@@ -4,8 +4,8 @@ require 'open3' unless defined? Open3
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'kramdown-asciidoc'
6
6
  s.version = Kramdown::AsciiDoc::VERSION
7
- s.summary = 'A Markdown to AsciiDoc converter based on Kramdown'
8
- s.description = 'A Kramdown extension for converting Markdown documents to AsciiDoc.'
7
+ s.summary = 'A Markdown to AsciiDoc converter based on kramdown'
8
+ s.description = 'A kramdown extension for converting Markdown documents to AsciiDoc.'
9
9
 
10
10
  s.authors = ['Dan Allen']
11
11
  s.email = ['dan.j.allen@gmail.com']
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
34
34
  #s.rdoc_options = ['--charset=UTF-8']
35
35
  #s.extra_rdoc_files = ['CHANGELOG.adoc', 'LICENSE.adoc']
36
36
 
37
- s.add_runtime_dependency 'kramdown', '~> 1.16.2'
37
+ s.add_runtime_dependency 'kramdown', '~> 1.17.0'
38
38
  s.add_development_dependency 'rake', '~> 12.3.1'
39
39
  s.add_development_dependency 'rspec', '~> 3.7.0'
40
40
  s.add_development_dependency 'simplecov', '~> 0.16.1'
@@ -2,12 +2,11 @@ require 'kramdown'
2
2
  require_relative 'kramdown-asciidoc/converter'
3
3
  autoload :YAML, 'yaml'
4
4
 
5
- # REMOVE once Kramdown > 1.16.2 is released
6
5
  class Kramdown::Parser::Html::ElementConverter
7
6
  def convert_br el
8
- el.options.clear
7
+ el.options.replace location: el.options[:location], html_tag: true
9
8
  el.type = el.value.to_sym
10
- el.value = ''
9
+ el.value = nil
11
10
  nil
12
11
  end
13
12
  end
@@ -19,24 +19,23 @@ module Kramdown; module AsciiDoc
19
19
  end
20
20
  end
21
21
 
22
+ # TODO return original source if YAML can't be parsed
22
23
  def self.extract_front_matter source, attributes
23
- if (line_i = (lines = source.each_line).next) && line_i.chomp == '---'
24
+ if (line_i = (lines = source.each_line).first) && line_i.chomp == '---'
24
25
  lines = lines.drop 1
25
26
  front_matter = []
26
27
  while (line = lines.shift) && line.chomp != '---'
27
28
  front_matter << line
28
29
  end
30
+ return source unless line && line.chomp == '---' && !(front_matter.include? ?\n)
29
31
  lines.shift while (line = lines[0]) && line == ?\n
30
32
  (::YAML.load front_matter.join).each do |key, val|
31
- case key
32
- when 'title'
33
- # skip
34
- when 'layout'
33
+ if key == 'layout'
35
34
  attributes['page-layout'] = val unless val == 'default'
36
35
  else
37
36
  attributes[key] = val.to_s
38
37
  end
39
- end
38
+ end unless front_matter.empty?
40
39
  lines.join
41
40
  else
42
41
  source
@@ -49,6 +48,7 @@ module Kramdown; module AsciiDoc
49
48
  ADMON_MARKERS = ADMON_LABELS.map {|l, _| %(#{l}: ) }
50
49
  ADMON_FORMATTED_MARKERS = ADMON_LABELS.map {|l, _| [%(#{l}:), l] }.to_h
51
50
  ADMON_TYPE_MAP = ADMON_LABELS.map {|l, _| [l, l.upcase] }.to_h.merge 'Attention' => 'IMPORTANT'
51
+ DLIST_MARKERS = %w(:: ;; ::: ::::)
52
52
  # FIXME here we reverse the smart quotes; add option to allow them (needs to be handled carefully)
53
53
  SMART_QUOTE_ENTITY_TO_MARKUP = { ldquo: ?", rdquo: ?", lsquo: ?', rsquo: ?' }
54
54
  TYPOGRAPHIC_SYMBOL_TO_MARKUP = {
@@ -80,8 +80,10 @@ module Kramdown; module AsciiDoc
80
80
  ApostropheRx = /\b’\b/
81
81
  CommentPrefixRx = /^ *! ?/m
82
82
  CssPropDelimRx = /\s*;\s*/
83
+ MenuRefRx = /^([\p{Word}&].*?)\s>\s([\p{Word}&].*(?:\s>\s|$))+/
83
84
  ReplaceableTextRx = /[-=]>|<[-=]|\.\.\./
84
85
  StartOfLinesRx = /^/m
86
+ TrailingSpaceRx = / +$/
85
87
  TypographicSymbolRx = /[“”‘’—–…]/
86
88
  XmlCommentRx = /\A<!--(.*)-->\Z/m
87
89
 
@@ -104,7 +106,10 @@ module Kramdown; module AsciiDoc
104
106
 
105
107
  def convert_root el, opts
106
108
  el = extract_prologue el, opts
107
- body = %(#{inner el, (opts.merge rstrip: true)}#{LF})
109
+ body = %(#{(inner el, (opts.merge rstrip: true)).gsub TrailingSpaceRx, ''}#{LF})
110
+ if (fallback_doctitle = @attributes.delete 'title')
111
+ @header << %(= #{fallback_doctitle}) if @header.empty?
112
+ end
108
113
  @attributes.each {|k, v| @header << %(:#{k}: #{v}) } unless @attributes.empty?
109
114
  @header.empty? ? body : %(#{@header.join LF}#{body == LF ? '' : LFx2}#{body})
110
115
  end
@@ -150,7 +155,7 @@ module Kramdown; module AsciiDoc
150
155
  alias convert_header convert_heading
151
156
 
152
157
  def convert_p el, opts
153
- if (parent = opts[:parent]) && parent.type == :li
158
+ if (parent = opts[:parent]) && (parent.type == :li || parent.type == :dd)
154
159
  # NOTE :prev option not set indicates primary text; convert_li appends LF
155
160
  return inner el, opts unless opts[:prev]
156
161
  parent.options[:compound] = true
@@ -185,9 +190,18 @@ module Kramdown; module AsciiDoc
185
190
  # TODO detect admonition masquerading as blockquote
186
191
  def convert_blockquote el, opts
187
192
  result = []
188
- # TODO support more than one level of nesting
189
- boundary = (parent = opts[:parent]) && parent.type == :blockquote ? '______' : '____'
190
- contents = inner el, (opts.merge rstrip: true)
193
+ if (parent = opts[:parent]) && (parent.type == :li || parent.type == :dd)
194
+ parent.options[:compound] = true
195
+ list_continuation = %(#{LF}+)
196
+ suffix = ''
197
+ else
198
+ suffix = LFx2
199
+ end
200
+ if (current_line = opts[:result].pop)
201
+ opts[:result] << current_line.chomp
202
+ end
203
+ boundary = '____' + ((depth = opts[:blockquote_depth] || 0) > 0 ? '__' * depth : '')
204
+ contents = inner el, (opts.merge rstrip: true, blockquote_depth: depth + 1)
191
205
  if (contents.include? LF) && ((attribution_line = (lines = contents.split LF).pop).start_with? '-- ')
192
206
  attribution = attribution_line.slice 3, attribution_line.length
193
207
  result << %([,#{attribution}])
@@ -197,12 +211,13 @@ module Kramdown; module AsciiDoc
197
211
  result << boundary
198
212
  result << contents
199
213
  result << boundary
200
- %(#{result.join LF}#{LFx2})
214
+ result.unshift list_continuation if list_continuation
215
+ %(#{result.join LF}#{suffix})
201
216
  end
202
217
 
203
218
  def convert_codeblock el, opts
204
219
  result = []
205
- if (parent = opts[:parent]) && parent.type == :li
220
+ if (parent = opts[:parent]) && (parent.type == :li || parent.type == :dd)
206
221
  parent.options[:compound] = true
207
222
  if (current_line = opts[:result].pop)
208
223
  opts[:result] << current_line.chomp
@@ -214,24 +229,23 @@ module Kramdown; module AsciiDoc
214
229
  end
215
230
  contents = el.value.rstrip
216
231
  if (lang = el.attr['class'])
217
- lang = lang.slice 9, lang.length if lang.start_with? 'language-'
232
+ # NOTE Kramdown always prefixes class with language-
218
233
  # TODO remap lang if requested
219
- result << %([source,#{lang}])
220
- end
221
- if !lang && (contents.start_with? '$ ')
222
- # QUESTION should we make these a source,console block?
223
- if contents.include? LFx2
224
- result << '....'
225
- result << contents
226
- result << '....'
227
- else
228
- list_continuation = LF if list_continuation
229
- result << (contents.gsub StartOfLinesRx, ' ')
230
- end
231
- else
234
+ result << %([source,#{lang = lang.slice 9, lang.length}])
235
+ elsif (prompt = contents.start_with? '$ ')
236
+ result << %([source,#{lang = 'console'}]) if contents.include? LFx2
237
+ end
238
+ if lang || (el.options[:fenced] && !prompt)
232
239
  result << '----'
233
240
  result << contents
234
241
  result << '----'
242
+ elsif !prompt && (contents.include? LFx2)
243
+ result << '....'
244
+ result << contents
245
+ result << '....'
246
+ else
247
+ list_continuation = LF if list_continuation
248
+ result << (contents.gsub StartOfLinesRx, ' ')
235
249
  end
236
250
  result.unshift list_continuation if list_continuation
237
251
  %(#{result.join LF}#{suffix})
@@ -239,29 +253,44 @@ module Kramdown; module AsciiDoc
239
253
 
240
254
  def convert_ul el, opts
241
255
  # TODO create do_in_level block
242
- level = opts[:level] ? (opts[:level] += 1) : (opts[:level] = 1)
256
+ level = opts[:list_level] ? (opts[:list_level] += 1) : (opts[:list_level] = 1)
243
257
  # REVIEW this is whack
244
- prefix = (parent = opts[:parent]) && parent.type == :li && !opts[:result][-1] ? LF : ''
258
+ if (parent = opts[:parent]) && (parent.type == :li || parent.type == :dd)
259
+ prefix = parent.options[:compound] ? LFx2 : (opts[:result][-1] ? '' : LF)
260
+ else
261
+ prefix = ''
262
+ end
245
263
  contents = inner el, (opts.merge rstrip: true)
246
264
  if level == 1
247
265
  suffix = LFx2
248
- opts.delete :level
266
+ opts.delete :list_level
249
267
  else
250
268
  suffix = LF
251
- opts[:level] -= 1
269
+ opts[:list_level] -= 1
252
270
  end
253
271
  %(#{prefix}#{contents}#{suffix})
254
272
  end
255
273
 
256
274
  alias convert_ol convert_ul
275
+ alias convert_dl convert_ul
257
276
 
258
277
  def convert_li el, opts
259
278
  prefix = (prev = opts[:prev]) && prev.options[:compound] ? LF : ''
260
279
  marker = opts[:parent].type == :ol ? '.' : '*'
261
- indent = (level = opts[:level]) - 1
280
+ indent = (level = opts[:list_level]) - 1
262
281
  %(#{prefix}#{indent > 0 ? ' ' * indent : ''}#{marker * level} #{(inner el, (opts.merge rstrip: true))}#{LF})
263
282
  end
264
283
 
284
+ def convert_dt el, opts
285
+ prefix = opts[:prev] ? LF : ''
286
+ marker = DLIST_MARKERS[opts[:list_level] - 1]
287
+ %(#{prefix}#{inner el, opts}#{marker}#{LF})
288
+ end
289
+
290
+ def convert_dd el, opts
291
+ %(#{inner el, (opts.merge rstrip: true)}#{LF})
292
+ end
293
+
265
294
  def convert_table el, opts
266
295
  head = nil
267
296
  cols = (alignments = el.options[:alignment]).size
@@ -324,14 +353,23 @@ module Kramdown; module AsciiDoc
324
353
  end
325
354
 
326
355
  def convert_strong el, opts
327
- %(*#{inner el, opts}*)
356
+ content = inner el, opts
357
+ if (content.include? ' > ') && MenuRefRx =~ content
358
+ @attributes['experimental'] = ''
359
+ %(menu:#{$1}[#{$2}])
360
+ else
361
+ %(*#{content}*)
362
+ end
328
363
  end
329
364
 
330
365
  # NOTE this logic assumes the :hard_wrap option is disabled in the parser
331
366
  def convert_br el, opts
332
- prefix = ((opts[:result][-1] || '').end_with? ' ') ? '' : ' '
333
- # if @attr is set, this is a <br> HTML tag
334
- if el.instance_variable_get :@attr
367
+ if (current_line = opts[:result][-1])
368
+ prefix = (current_line.end_with? ' ') ? '' : ' '
369
+ else
370
+ prefix = '{blank} '
371
+ end
372
+ if el.options[:html_tag]
335
373
  siblings = opts[:parent].children
336
374
  suffix = (next_el = siblings[(siblings.index el) + 1] || VoidElement).type == :text && (next_el.value.start_with? LF) ? '' : LF
337
375
  else
@@ -379,22 +417,20 @@ module Kramdown; module AsciiDoc
379
417
  else
380
418
  macro_prefix = 'image:'
381
419
  end
382
- macro_attrs = []
420
+ macro_attrs = [nil]
383
421
  if (alt_text = el.attr['alt'])
384
- macro_attrs << alt_text unless alt_text.empty?
422
+ macro_attrs[0] = alt_text unless alt_text.empty?
385
423
  end
386
424
  if (width = el.attr['width'])
387
- macro_attrs << '' if macro_attrs.empty?
388
425
  macro_attrs << width
389
426
  elsif (css = el.attr['style']) && (width_css = (css.split CssPropDelimRx).find {|p| p.start_with? 'width:' })
390
- macro_attrs << '' if macro_attrs.empty?
391
427
  width = (width_css.slice (width_css.index ':') + 1, width_css.length).strip
392
- unless width.end_with? '%'
393
- width = width.to_f
394
- width = width.to_i if width == width.to_i
395
- end
428
+ width = width.to_f.round unless width.end_with? '%'
396
429
  macro_attrs << width
397
430
  end
431
+ if macro_attrs.size == 1 && (alt_text = macro_attrs.pop)
432
+ macro_attrs << alt_text
433
+ end
398
434
  if (url = opts[:url])
399
435
  macro_attrs << %(link=#{url})
400
436
  end
@@ -425,6 +461,8 @@ module Kramdown; module AsciiDoc
425
461
  contents = inner el, (opts.merge rstrip: el.options[:category] == :block)
426
462
  attrs = (attrs = el.attr).empty? ? '' : attrs.map {|k, v| %( #{k}="#{v}") }.join
427
463
  case tagname
464
+ when 'del'
465
+ %([.line-through]##{contents}#)
428
466
  when 'sup'
429
467
  %(^#{contents}^)
430
468
  when 'sub'
@@ -440,7 +478,7 @@ module Kramdown; module AsciiDoc
440
478
  #siblings = (parent = opts[:parent]) ? parent.children : []
441
479
  if (el.options[:category] == :block)# || (!opts[:result][-1] && siblings[-1] == el)
442
480
  if comment_text.empty?
443
- %(//-#{LFx2})
481
+ %(//#{LFx2})
444
482
  elsif comment_text.include? LF
445
483
  %(////#{LF}#{comment_text}#{LF}////#{LFx2})
446
484
  else
@@ -476,7 +514,7 @@ module Kramdown; module AsciiDoc
476
514
  el
477
515
  end
478
516
 
479
- def inner el, opts = {}
517
+ def inner el, opts
480
518
  rstrip = opts.delete :rstrip
481
519
  result = []
482
520
  prev = nil
@@ -487,7 +525,7 @@ module Kramdown; module AsciiDoc
487
525
  rstrip ? result.join.rstrip : result.join
488
526
  end
489
527
 
490
- def clone el, properties = {}
528
+ def clone el, properties
491
529
  el = el.dup
492
530
  properties.each do |name, value|
493
531
  el.send %(#{name}=).to_sym, value
@@ -1,3 +1,3 @@
1
1
  module Kramdown; module AsciiDoc
2
- VERSION = '1.0.0.alpha.3'
2
+ VERSION = '1.0.0.alpha.4'
3
3
  end; end
@@ -8,6 +8,7 @@ describe Kramdown::AsciiDoc::Converter do
8
8
 
9
9
  context '#convert' do
10
10
  let (:input) { %(# Document Title\n\nBody text.) }
11
+
11
12
  it 'adds line feed (EOL) to end of output document' do
12
13
  (expect converter.convert root).to end_with %(\n)
13
14
  (expect doc.to_asciidoc).to end_with %(\n)
@@ -45,8 +46,7 @@ describe Kramdown::AsciiDoc::Converter do
45
46
  ...
46
47
  EOS
47
48
 
48
- attributes = {}
49
- (expect Kramdown::AsciiDoc.replace_toc input, attributes).to be input
49
+ (expect Kramdown::AsciiDoc.replace_toc input, (attributes = {})).to be input
50
50
  (expect attributes).to be_empty
51
51
  end
52
52
 
@@ -81,8 +81,7 @@ describe Kramdown::AsciiDoc::Converter do
81
81
  ...
82
82
  EOS
83
83
 
84
- attributes = {}
85
- (expect Kramdown::AsciiDoc.replace_toc input, attributes).to eql expected
84
+ (expect Kramdown::AsciiDoc.replace_toc input, (attributes = {})).to eql expected
86
85
  (expect attributes['toc']).to eql 'macro'
87
86
  end
88
87
  end
@@ -99,20 +98,25 @@ describe Kramdown::AsciiDoc::Converter do
99
98
  more content
100
99
  EOS
101
100
 
102
- attributes = {}
103
- (expect Kramdown::AsciiDoc.extract_front_matter input, attributes).to be input
101
+ (expect Kramdown::AsciiDoc.extract_front_matter input, (attributes = {})).to be input
102
+ (expect attributes).to be_empty
103
+ end
104
+
105
+ it 'does not modify source if source is empty' do
106
+ input = ''
107
+
108
+ (expect Kramdown::AsciiDoc.extract_front_matter input, (attributes = {})).to be input
104
109
  (expect attributes).to be_empty
105
110
  end
106
111
 
107
112
  it 'extracts front matter and assigns entries to attributes' do
108
113
  input = <<~EOS
109
114
  ---
110
- title: Introduction
115
+ title: Introduction From Front Matter
111
116
  description: An introduction to this amazing technology.
112
117
  keywords: buzz, transformative
113
118
  layout: default
114
119
  ---
115
-
116
120
  # Introduction
117
121
 
118
122
  When using this technology, anything is possible.
@@ -125,12 +129,137 @@ describe Kramdown::AsciiDoc::Converter do
125
129
  EOS
126
130
 
127
131
  expected_attributes = {
132
+ 'title' => 'Introduction From Front Matter',
128
133
  'description' => 'An introduction to this amazing technology.',
129
134
  'keywords' => 'buzz, transformative',
130
135
  }
131
136
 
132
- attributes = {}
133
- (expect Kramdown::AsciiDoc.extract_front_matter input, attributes).to eql expected
137
+ (expect Kramdown::AsciiDoc.extract_front_matter input, (attributes = {})).to eql expected
138
+ (expect attributes).to eql expected_attributes
139
+ end
140
+
141
+ it 'ignores title from front matter if explicit document title is present' do
142
+ input = <<~EOS
143
+ ---
144
+ title: Document Title From Front Matter
145
+ description: An introduction to this amazing technology.
146
+ ---
147
+ # Introduction
148
+
149
+ When using this technology, anything is possible.
150
+ EOS
151
+
152
+ expected = <<~EOS
153
+ = Introduction
154
+ :description: An introduction to this amazing technology.
155
+
156
+ When using this technology, anything is possible.
157
+ EOS
158
+
159
+ # FIXME can we reuse our lets to handle this test?
160
+ input = Kramdown::AsciiDoc.extract_front_matter input, (attributes = {})
161
+ doc = Kramdown::Document.new input, (opts.merge attributes: attributes)
162
+ (expect doc.to_asciidoc).to eql expected
163
+ end
164
+
165
+ it 'uses title from front matter as document title if explicit document title is absent' do
166
+ input = <<~EOS
167
+ ---
168
+ title: Introduction
169
+ description: An introduction to this amazing technology.
170
+ ---
171
+
172
+ When using this technology, anything is possible.
173
+ EOS
174
+
175
+ expected = <<~EOS
176
+ = Introduction
177
+ :description: An introduction to this amazing technology.
178
+
179
+ When using this technology, anything is possible.
180
+ EOS
181
+
182
+ # FIXME can we reuse our lets to handle this test?
183
+ input = Kramdown::AsciiDoc.extract_front_matter input, (attributes = {})
184
+ doc = Kramdown::Document.new input, (opts.merge attributes: attributes)
185
+ (expect doc.to_asciidoc).to eql expected
186
+ end
187
+
188
+ it 'assigns non-default layout in front matter to page-layout attribute' do
189
+ input = <<~EOS
190
+ ---
191
+ layout: home
192
+ ---
193
+ Welcome home!
194
+ EOS
195
+
196
+ expected = <<~EOS
197
+ Welcome home!
198
+ EOS
199
+
200
+ expected_attributes = {
201
+ 'page-layout' => 'home'
202
+ }
203
+
204
+ (expect Kramdown::AsciiDoc.extract_front_matter input, (attributes = {})).to eql expected
205
+ (expect attributes).to eql expected_attributes
206
+ end
207
+
208
+ it 'returns empty document when it only contains front matter' do
209
+ input = <<~EOS
210
+ ---
211
+ description: This page is intentionally left blank.
212
+ ---
213
+ EOS
214
+
215
+ expected_attributes = {
216
+ 'description' => 'This page is intentionally left blank.'
217
+ }
218
+
219
+ (expect Kramdown::AsciiDoc.extract_front_matter input, (attributes = {})).to be_empty
220
+ (expect attributes).to eql expected_attributes
221
+ end
222
+
223
+ it 'removes empty front matter' do
224
+ input = <<~EOS
225
+ ---
226
+ ---
227
+ Move along. There's no front matter to see here.
228
+ EOS
229
+
230
+ expected = <<~EOS
231
+ Move along. There's no front matter to see here.
232
+ EOS
233
+
234
+ (expect Kramdown::AsciiDoc.extract_front_matter input, (attributes = {})).to eql expected
235
+ (expect attributes).to be_empty
236
+ end
237
+
238
+ it 'does not remove leading hr' do
239
+ input = '---'
240
+
241
+ (expect Kramdown::AsciiDoc.extract_front_matter input, (attributes = {})).to eql input
242
+ (expect attributes).to be_empty
243
+ end
244
+
245
+ it 'removes blank lines between front matter and body' do
246
+ input = <<~EOS
247
+ ---
248
+ description: Just another page.
249
+ ---
250
+
251
+ Another page.
252
+ EOS
253
+
254
+ expected = <<~EOS
255
+ Another page.
256
+ EOS
257
+
258
+ expected_attributes = {
259
+ 'description' => 'Just another page.'
260
+ }
261
+
262
+ (expect Kramdown::AsciiDoc.extract_front_matter input, (attributes = {})).to eql expected
134
263
  (expect attributes).to eql expected_attributes
135
264
  end
136
265
  end