kramdown-asciidoc 1.0.0.alpha.13 → 1.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (462) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +24 -0
  3. data/Gemfile +5 -0
  4. data/README.adoc +16 -16
  5. data/kramdown-asciidoc.gemspec +5 -7
  6. data/lib/kramdown-asciidoc.rb +7 -2
  7. data/lib/kramdown-asciidoc/api.rb +83 -18
  8. data/lib/kramdown-asciidoc/cli.rb +1 -1
  9. data/lib/kramdown-asciidoc/converter.rb +12 -51
  10. data/lib/kramdown-asciidoc/kramdown_ext/parser/base.rb +8 -1
  11. data/lib/kramdown-asciidoc/kramdown_ext/parser/html.rb +5 -1
  12. data/lib/kramdown-asciidoc/preprocessors.rb +64 -0
  13. data/lib/kramdown-asciidoc/version.rb +1 -1
  14. data/lib/kramdown-asciidoc/writer.rb +8 -0
  15. metadata +5 -897
  16. data/Rakefile +0 -3
  17. data/spec/api_spec.rb +0 -228
  18. data/spec/cli_spec.rb +0 -300
  19. data/spec/converter_spec.rb +0 -271
  20. data/spec/scenario_spec.rb +0 -25
  21. data/spec/scenarios/a/bare-interdoc-xref.adoc +0 -1
  22. data/spec/scenarios/a/bare-interdoc-xref.md +0 -1
  23. data/spec/scenarios/a/bare-url.adoc +0 -1
  24. data/spec/scenarios/a/bare-url.md +0 -1
  25. data/spec/scenarios/a/containing-inline-image.adoc +0 -5
  26. data/spec/scenarios/a/containing-inline-image.md +0 -5
  27. data/spec/scenarios/a/double-underscore-in-url.adoc +0 -1
  28. data/spec/scenarios/a/double-underscore-in-url.md +0 -1
  29. data/spec/scenarios/a/interdoc-xref.adoc +0 -1
  30. data/spec/scenarios/a/interdoc-xref.md +0 -1
  31. data/spec/scenarios/a/internal.adoc +0 -5
  32. data/spec/scenarios/a/internal.md +0 -5
  33. data/spec/scenarios/a/local.adoc +0 -1
  34. data/spec/scenarios/a/local.md +0 -1
  35. data/spec/scenarios/a/no-auto-links.adoc +0 -3
  36. data/spec/scenarios/a/no-auto-links.md +0 -3
  37. data/spec/scenarios/a/no-auto-links.opts +0 -1
  38. data/spec/scenarios/a/url-matches-text.adoc +0 -2
  39. data/spec/scenarios/a/url-matches-text.md +0 -2
  40. data/spec/scenarios/a/url-with-text.adoc +0 -1
  41. data/spec/scenarios/a/url-with-text.md +0 -1
  42. data/spec/scenarios/attributes/sorting.adoc +0 -6
  43. data/spec/scenarios/attributes/sorting.md +0 -3
  44. data/spec/scenarios/attributes/sorting.opts +0 -3
  45. data/spec/scenarios/blockquote/attribution-separated.adoc +0 -5
  46. data/spec/scenarios/blockquote/attribution-separated.md +0 -5
  47. data/spec/scenarios/blockquote/attribution.adoc +0 -5
  48. data/spec/scenarios/blockquote/attribution.md +0 -3
  49. data/spec/scenarios/blockquote/basic.adoc +0 -3
  50. data/spec/scenarios/blockquote/basic.md +0 -1
  51. data/spec/scenarios/blockquote/deep-nested.adoc +0 -17
  52. data/spec/scenarios/blockquote/deep-nested.md +0 -6
  53. data/spec/scenarios/blockquote/list.adoc +0 -5
  54. data/spec/scenarios/blockquote/list.md +0 -3
  55. data/spec/scenarios/blockquote/multiple-lines.adoc +0 -5
  56. data/spec/scenarios/blockquote/multiple-lines.md +0 -3
  57. data/spec/scenarios/blockquote/nested.adoc +0 -7
  58. data/spec/scenarios/blockquote/nested.md +0 -3
  59. data/spec/scenarios/br/leading-tag.adoc +0 -2
  60. data/spec/scenarios/br/leading-tag.md +0 -2
  61. data/spec/scenarios/br/tag-followed-by-newline.adoc +0 -3
  62. data/spec/scenarios/br/tag-followed-by-newline.md +0 -3
  63. data/spec/scenarios/br/tag-in-table-cell.adoc +0 -4
  64. data/spec/scenarios/br/tag-in-table-cell.md +0 -1
  65. data/spec/scenarios/br/tag-preceded-by-space.adoc +0 -3
  66. data/spec/scenarios/br/tag-preceded-by-space.md +0 -1
  67. data/spec/scenarios/br/tag.adoc +0 -3
  68. data/spec/scenarios/br/tag.md +0 -1
  69. data/spec/scenarios/br/trailing-double-space.adoc +0 -3
  70. data/spec/scenarios/br/trailing-double-space.md +0 -3
  71. data/spec/scenarios/codeblock/command-prompt.adoc +0 -1
  72. data/spec/scenarios/codeblock/command-prompt.md +0 -1
  73. data/spec/scenarios/codeblock/contiguous-lines.adoc +0 -3
  74. data/spec/scenarios/codeblock/contiguous-lines.md +0 -3
  75. data/spec/scenarios/codeblock/dlist-like.adoc +0 -4
  76. data/spec/scenarios/codeblock/dlist-like.md +0 -2
  77. data/spec/scenarios/codeblock/fenced/command-prompt.adoc +0 -1
  78. data/spec/scenarios/codeblock/fenced/command-prompt.md +0 -3
  79. data/spec/scenarios/codeblock/fenced/language.adoc +0 -8
  80. data/spec/scenarios/codeblock/fenced/language.md +0 -7
  81. data/spec/scenarios/codeblock/fenced/non-contiguous-command-prompts.adoc +0 -6
  82. data/spec/scenarios/codeblock/fenced/non-contiguous-command-prompts.md +0 -5
  83. data/spec/scenarios/codeblock/fenced/without-language.adoc +0 -5
  84. data/spec/scenarios/codeblock/fenced/without-language.md +0 -5
  85. data/spec/scenarios/codeblock/list-like.adoc +0 -5
  86. data/spec/scenarios/codeblock/list-like.md +0 -3
  87. data/spec/scenarios/codeblock/non-contiguous-command-prompts.adoc +0 -6
  88. data/spec/scenarios/codeblock/non-contiguous-command-prompts.md +0 -3
  89. data/spec/scenarios/codeblock/non-contiguous-lines.adoc +0 -7
  90. data/spec/scenarios/codeblock/non-contiguous-lines.md +0 -5
  91. data/spec/scenarios/codespan/caret.adoc +0 -1
  92. data/spec/scenarios/codespan/caret.md +0 -1
  93. data/spec/scenarios/codespan/constrained-triple.adoc +0 -1
  94. data/spec/scenarios/codespan/constrained-triple.md +0 -1
  95. data/spec/scenarios/codespan/constrained.adoc +0 -1
  96. data/spec/scenarios/codespan/constrained.md +0 -1
  97. data/spec/scenarios/codespan/literal.adoc +0 -15
  98. data/spec/scenarios/codespan/literal.md +0 -15
  99. data/spec/scenarios/codespan/plus-plus.adoc +0 -1
  100. data/spec/scenarios/codespan/plus-plus.md +0 -1
  101. data/spec/scenarios/codespan/possessive.adoc +0 -3
  102. data/spec/scenarios/codespan/possessive.md +0 -3
  103. data/spec/scenarios/codespan/quoted.adoc +0 -1
  104. data/spec/scenarios/codespan/quoted.md +0 -1
  105. data/spec/scenarios/codespan/smart-quotes.adoc +0 -1
  106. data/spec/scenarios/codespan/smart-quotes.md +0 -1
  107. data/spec/scenarios/codespan/star-star.adoc +0 -1
  108. data/spec/scenarios/codespan/star-star.md +0 -1
  109. data/spec/scenarios/codespan/unconstrained.adoc +0 -7
  110. data/spec/scenarios/codespan/unconstrained.md +0 -7
  111. data/spec/scenarios/dl/compound-only.adoc +0 -16
  112. data/spec/scenarios/dl/compound-only.md +0 -13
  113. data/spec/scenarios/dl/compound.adoc +0 -11
  114. data/spec/scenarios/dl/compound.md +0 -7
  115. data/spec/scenarios/dl/empty-dd.adoc +0 -3
  116. data/spec/scenarios/dl/empty-dd.md +0 -4
  117. data/spec/scenarios/dl/nested-bookended.adoc +0 -8
  118. data/spec/scenarios/dl/nested-bookended.md +0 -6
  119. data/spec/scenarios/dl/nested-mixed.adoc +0 -11
  120. data/spec/scenarios/dl/nested-mixed.md +0 -11
  121. data/spec/scenarios/dl/nested.adoc +0 -15
  122. data/spec/scenarios/dl/nested.md +0 -23
  123. data/spec/scenarios/dl/simple.adoc +0 -9
  124. data/spec/scenarios/dl/simple.md +0 -10
  125. data/spec/scenarios/em/asterisks.adoc +0 -1
  126. data/spec/scenarios/em/asterisks.md +0 -1
  127. data/spec/scenarios/em/constrained.adoc +0 -1
  128. data/spec/scenarios/em/constrained.md +0 -1
  129. data/spec/scenarios/em/strong.adoc +0 -1
  130. data/spec/scenarios/em/strong.md +0 -1
  131. data/spec/scenarios/em/unconstrained.adoc +0 -4
  132. data/spec/scenarios/em/unconstrained.md +0 -4
  133. data/spec/scenarios/entity/numeric.adoc +0 -1
  134. data/spec/scenarios/entity/numeric.md +0 -1
  135. data/spec/scenarios/entity/reverse.adoc +0 -5
  136. data/spec/scenarios/entity/reverse.md +0 -5
  137. data/spec/scenarios/heading/anchor-with-dot.adoc +0 -2
  138. data/spec/scenarios/heading/anchor-with-dot.md +0 -1
  139. data/spec/scenarios/heading/auto_ids/auto-id-prefix.adoc +0 -11
  140. data/spec/scenarios/heading/auto_ids/auto-id-prefix.md +0 -7
  141. data/spec/scenarios/heading/auto_ids/auto-id-prefix.opts +0 -2
  142. data/spec/scenarios/heading/auto_ids/character-reference.adoc +0 -8
  143. data/spec/scenarios/heading/auto_ids/character-reference.md +0 -5
  144. data/spec/scenarios/heading/auto_ids/character-reference.opts +0 -1
  145. data/spec/scenarios/heading/auto_ids/disabled.adoc +0 -3
  146. data/spec/scenarios/heading/auto_ids/disabled.md +0 -3
  147. data/spec/scenarios/heading/auto_ids/disabled.opts +0 -3
  148. data/spec/scenarios/heading/auto_ids/dot-separator.adoc +0 -2
  149. data/spec/scenarios/heading/auto_ids/dot-separator.md +0 -1
  150. data/spec/scenarios/heading/auto_ids/dot-separator.opts +0 -2
  151. data/spec/scenarios/heading/auto_ids/explicit-id.adoc +0 -14
  152. data/spec/scenarios/heading/auto_ids/explicit-id.md +0 -9
  153. data/spec/scenarios/heading/auto_ids/explicit-id.opts +0 -1
  154. data/spec/scenarios/heading/auto_ids/kramdown-input-character-reference.adoc +0 -8
  155. data/spec/scenarios/heading/auto_ids/kramdown-input-character-reference.md +0 -5
  156. data/spec/scenarios/heading/auto_ids/kramdown-input-character-reference.opts +0 -2
  157. data/spec/scenarios/heading/auto_ids/kramdown-input.adoc +0 -14
  158. data/spec/scenarios/heading/auto_ids/kramdown-input.md +0 -9
  159. data/spec/scenarios/heading/auto_ids/kramdown-input.opts +0 -2
  160. data/spec/scenarios/heading/auto_ids/no-ids.adoc +0 -14
  161. data/spec/scenarios/heading/auto_ids/no-ids.md +0 -9
  162. data/spec/scenarios/heading/auto_ids/no-ids.opts +0 -1
  163. data/spec/scenarios/heading/block-title.adoc +0 -11
  164. data/spec/scenarios/heading/block-title.md +0 -11
  165. data/spec/scenarios/heading/formatting.adoc +0 -1
  166. data/spec/scenarios/heading/formatting.md +0 -1
  167. data/spec/scenarios/heading/lazy_ids/auto-ids-sync-id-attrs.adoc +0 -7
  168. data/spec/scenarios/heading/lazy_ids/auto-ids-sync-id-attrs.md +0 -5
  169. data/spec/scenarios/heading/lazy_ids/auto-ids-sync-id-attrs.opts +0 -5
  170. data/spec/scenarios/heading/lazy_ids/auto-ids.adoc +0 -10
  171. data/spec/scenarios/heading/lazy_ids/auto-ids.md +0 -7
  172. data/spec/scenarios/heading/lazy_ids/auto-ids.opts +0 -4
  173. data/spec/scenarios/heading/lazy_ids/explicit-ids-dot-separator.adoc +0 -9
  174. data/spec/scenarios/heading/lazy_ids/explicit-ids-dot-separator.md +0 -7
  175. data/spec/scenarios/heading/lazy_ids/explicit-ids-dot-separator.opts +0 -3
  176. data/spec/scenarios/heading/lazy_ids/explicit-ids-empty-prefix.adoc +0 -9
  177. data/spec/scenarios/heading/lazy_ids/explicit-ids-empty-prefix.md +0 -7
  178. data/spec/scenarios/heading/lazy_ids/explicit-ids-empty-prefix.opts +0 -3
  179. data/spec/scenarios/heading/lazy_ids/explicit-ids-empty-separator.adoc +0 -9
  180. data/spec/scenarios/heading/lazy_ids/explicit-ids-empty-separator.md +0 -7
  181. data/spec/scenarios/heading/lazy_ids/explicit-ids-empty-separator.opts +0 -3
  182. data/spec/scenarios/heading/lazy_ids/explicit-ids-zero-separator.adoc +0 -7
  183. data/spec/scenarios/heading/lazy_ids/explicit-ids-zero-separator.md +0 -5
  184. data/spec/scenarios/heading/lazy_ids/explicit-ids-zero-separator.opts +0 -3
  185. data/spec/scenarios/heading/lazy_ids/explicit-ids.adoc +0 -15
  186. data/spec/scenarios/heading/lazy_ids/explicit-ids.md +0 -13
  187. data/spec/scenarios/heading/lazy_ids/explicit-ids.opts +0 -1
  188. data/spec/scenarios/heading/leading-anchor.adoc +0 -2
  189. data/spec/scenarios/heading/leading-anchor.md +0 -1
  190. data/spec/scenarios/heading/not-block-title.adoc +0 -8
  191. data/spec/scenarios/heading/not-block-title.md +0 -7
  192. data/spec/scenarios/heading/offset.adoc +0 -5
  193. data/spec/scenarios/heading/offset.md +0 -5
  194. data/spec/scenarios/heading/offset.opts +0 -1
  195. data/spec/scenarios/heading/out-of-sequence.adoc +0 -23
  196. data/spec/scenarios/heading/out-of-sequence.md +0 -21
  197. data/spec/scenarios/heading/outline.adoc +0 -13
  198. data/spec/scenarios/heading/outline.md +0 -13
  199. data/spec/scenarios/heading/surrounding-anchor.adoc +0 -2
  200. data/spec/scenarios/heading/surrounding-anchor.md +0 -1
  201. data/spec/scenarios/hr/around-block.adoc +0 -5
  202. data/spec/scenarios/hr/around-block.md +0 -5
  203. data/spec/scenarios/hr/between-blocks.adoc +0 -5
  204. data/spec/scenarios/hr/between-blocks.md +0 -5
  205. data/spec/scenarios/hr/dashes.adoc +0 -1
  206. data/spec/scenarios/hr/dashes.md +0 -1
  207. data/spec/scenarios/html_element/abbr.adoc +0 -1
  208. data/spec/scenarios/html_element/abbr.md +0 -1
  209. data/spec/scenarios/html_element/admonition.adoc +0 -5
  210. data/spec/scenarios/html_element/admonition.md +0 -7
  211. data/spec/scenarios/html_element/div-mixed.adoc +0 -1
  212. data/spec/scenarios/html_element/div-mixed.md +0 -4
  213. data/spec/scenarios/html_element/div-text-only.adoc +0 -1
  214. data/spec/scenarios/html_element/div-text-only.md +0 -1
  215. data/spec/scenarios/html_element/empty-p.adoc +0 -5
  216. data/spec/scenarios/html_element/empty-p.md +0 -5
  217. data/spec/scenarios/html_element/heading-with-class.adoc +0 -7
  218. data/spec/scenarios/html_element/heading-with-class.md +0 -5
  219. data/spec/scenarios/html_element/heading-with-id.adoc +0 -2
  220. data/spec/scenarios/html_element/heading-with-id.md +0 -1
  221. data/spec/scenarios/html_element/image-with-id.adoc +0 -2
  222. data/spec/scenarios/html_element/image-with-id.md +0 -1
  223. data/spec/scenarios/html_element/img-with-alt-and-width.adoc +0 -1
  224. data/spec/scenarios/html_element/img-with-alt-and-width.md +0 -1
  225. data/spec/scenarios/html_element/img-with-percentage-width-css.adoc +0 -1
  226. data/spec/scenarios/html_element/img-with-percentage-width-css.md +0 -1
  227. data/spec/scenarios/html_element/img-with-percentage-width.adoc +0 -1
  228. data/spec/scenarios/html_element/img-with-percentage-width.md +0 -1
  229. data/spec/scenarios/html_element/img-with-width-css.adoc +0 -1
  230. data/spec/scenarios/html_element/img-with-width-css.md +0 -1
  231. data/spec/scenarios/html_element/img-with-width.adoc +0 -1
  232. data/spec/scenarios/html_element/img-with-width.md +0 -1
  233. data/spec/scenarios/html_element/img.adoc +0 -2
  234. data/spec/scenarios/html_element/img.md +0 -1
  235. data/spec/scenarios/html_element/mark.adoc +0 -1
  236. data/spec/scenarios/html_element/mark.md +0 -1
  237. data/spec/scenarios/html_element/native.adoc +0 -1
  238. data/spec/scenarios/html_element/native.md +0 -1
  239. data/spec/scenarios/html_element/pre-code-with-language.adoc +0 -6
  240. data/spec/scenarios/html_element/pre-code-with-language.md +0 -4
  241. data/spec/scenarios/html_element/span.adoc +0 -3
  242. data/spec/scenarios/html_element/span.md +0 -3
  243. data/spec/scenarios/html_element/strike.adoc +0 -1
  244. data/spec/scenarios/html_element/strike.md +0 -1
  245. data/spec/scenarios/html_element/sub.adoc +0 -1
  246. data/spec/scenarios/html_element/sub.md +0 -1
  247. data/spec/scenarios/html_element/sup.adoc +0 -1
  248. data/spec/scenarios/html_element/sup.md +0 -1
  249. data/spec/scenarios/html_element/unrecognized-admonition.adoc +0 -5
  250. data/spec/scenarios/html_element/unrecognized-admonition.md +0 -5
  251. data/spec/scenarios/img/block-in-list.adoc +0 -5
  252. data/spec/scenarios/img/block-in-list.md +0 -5
  253. data/spec/scenarios/img/block-with-alt.adoc +0 -1
  254. data/spec/scenarios/img/block-with-alt.md +0 -1
  255. data/spec/scenarios/img/block-with-link-and-alt.adoc +0 -1
  256. data/spec/scenarios/img/block-with-link-and-alt.md +0 -1
  257. data/spec/scenarios/img/block-with-link.adoc +0 -1
  258. data/spec/scenarios/img/block-with-link.md +0 -1
  259. data/spec/scenarios/img/block.adoc +0 -1
  260. data/spec/scenarios/img/block.md +0 -1
  261. data/spec/scenarios/img/imagesdir.adoc +0 -4
  262. data/spec/scenarios/img/imagesdir.md +0 -3
  263. data/spec/scenarios/img/imagesdir.opts +0 -2
  264. data/spec/scenarios/img/implicit-imagesdir.adoc +0 -3
  265. data/spec/scenarios/img/implicit-imagesdir.md +0 -3
  266. data/spec/scenarios/img/implicit-imagesdir.opts +0 -1
  267. data/spec/scenarios/img/inline-with-alt.adoc +0 -1
  268. data/spec/scenarios/img/inline-with-alt.md +0 -1
  269. data/spec/scenarios/img/inline-with-link-and-alt.adoc +0 -1
  270. data/spec/scenarios/img/inline-with-link-and-alt.md +0 -1
  271. data/spec/scenarios/img/inline-with-link.adoc +0 -1
  272. data/spec/scenarios/img/inline-with-link.md +0 -1
  273. data/spec/scenarios/img/inline.adoc +0 -1
  274. data/spec/scenarios/img/inline.md +0 -1
  275. data/spec/scenarios/ol/compound-separated.adoc +0 -29
  276. data/spec/scenarios/ol/compound-separated.md +0 -25
  277. data/spec/scenarios/ol/compound.adoc +0 -29
  278. data/spec/scenarios/ol/compound.md +0 -20
  279. data/spec/scenarios/ol/formatted.adoc +0 -3
  280. data/spec/scenarios/ol/formatted.md +0 -3
  281. data/spec/scenarios/ol/mixed-separated.adoc +0 -6
  282. data/spec/scenarios/ol/mixed-separated.md +0 -11
  283. data/spec/scenarios/ol/mixed.adoc +0 -6
  284. data/spec/scenarios/ol/mixed.md +0 -6
  285. data/spec/scenarios/ol/nested-mixed.adoc +0 -8
  286. data/spec/scenarios/ol/nested-mixed.md +0 -8
  287. data/spec/scenarios/ol/nested-separated.adoc +0 -7
  288. data/spec/scenarios/ol/nested-separated.md +0 -13
  289. data/spec/scenarios/ol/nested.adoc +0 -7
  290. data/spec/scenarios/ol/nested.md +0 -7
  291. data/spec/scenarios/ol/simple-separated.adoc +0 -4
  292. data/spec/scenarios/ol/simple-separated.md +0 -7
  293. data/spec/scenarios/ol/simple.adoc +0 -4
  294. data/spec/scenarios/ol/simple.md +0 -4
  295. data/spec/scenarios/p/admonition/emphasis.adoc +0 -11
  296. data/spec/scenarios/p/admonition/emphasis.md +0 -11
  297. data/spec/scenarios/p/admonition/in-blockquote.adoc +0 -1
  298. data/spec/scenarios/p/admonition/in-blockquote.md +0 -1
  299. data/spec/scenarios/p/admonition/in-compound-blockquote.adoc +0 -5
  300. data/spec/scenarios/p/admonition/in-compound-blockquote.md +0 -3
  301. data/spec/scenarios/p/admonition/in-list-item.adoc +0 -6
  302. data/spec/scenarios/p/admonition/in-list-item.md +0 -6
  303. data/spec/scenarios/p/admonition/label-only.adoc +0 -1
  304. data/spec/scenarios/p/admonition/label-only.md +0 -1
  305. data/spec/scenarios/p/admonition/plain.adoc +0 -13
  306. data/spec/scenarios/p/admonition/plain.md +0 -13
  307. data/spec/scenarios/p/admonition/strong-emphasis.adoc +0 -11
  308. data/spec/scenarios/p/admonition/strong-emphasis.md +0 -11
  309. data/spec/scenarios/p/multiple-lines.adoc +0 -2
  310. data/spec/scenarios/p/multiple-lines.md +0 -2
  311. data/spec/scenarios/p/sequential.adoc +0 -3
  312. data/spec/scenarios/p/sequential.md +0 -3
  313. data/spec/scenarios/p/single-line.adoc +0 -1
  314. data/spec/scenarios/p/single-line.md +0 -1
  315. data/spec/scenarios/root/body-only.adoc +0 -1
  316. data/spec/scenarios/root/body-only.md +0 -1
  317. data/spec/scenarios/root/book-doctype.adoc +0 -10
  318. data/spec/scenarios/root/book-doctype.md +0 -9
  319. data/spec/scenarios/root/header-and-body.adoc +0 -3
  320. data/spec/scenarios/root/header-and-body.md +0 -3
  321. data/spec/scenarios/root/header-only.adoc +0 -1
  322. data/spec/scenarios/root/header-only.md +0 -1
  323. data/spec/scenarios/smart_quote/apostrophe.adoc +0 -1
  324. data/spec/scenarios/smart_quote/apostrophe.md +0 -1
  325. data/spec/scenarios/smart_quote/double-quotes.adoc +0 -1
  326. data/spec/scenarios/smart_quote/double-quotes.md +0 -1
  327. data/spec/scenarios/smart_quote/single-quotes.adoc +0 -1
  328. data/spec/scenarios/smart_quote/single-quotes.md +0 -1
  329. data/spec/scenarios/strong/constrained.adoc +0 -1
  330. data/spec/scenarios/strong/constrained.md +0 -1
  331. data/spec/scenarios/strong/menu.adoc +0 -3
  332. data/spec/scenarios/strong/menu.md +0 -1
  333. data/spec/scenarios/strong/nested-emphasis.adoc +0 -1
  334. data/spec/scenarios/strong/nested-emphasis.md +0 -1
  335. data/spec/scenarios/strong/unconstrained.adoc +0 -8
  336. data/spec/scenarios/strong/unconstrained.md +0 -8
  337. data/spec/scenarios/table/alignment.adoc +0 -19
  338. data/spec/scenarios/table/alignment.md +0 -8
  339. data/spec/scenarios/table/cell-with-image.adoc +0 -9
  340. data/spec/scenarios/table/cell-with-image.md +0 -4
  341. data/spec/scenarios/table/cell-with-pipe.adoc +0 -5
  342. data/spec/scenarios/table/cell-with-pipe.md +0 -1
  343. data/spec/scenarios/table/header.adoc +0 -9
  344. data/spec/scenarios/table/header.md +0 -4
  345. data/spec/scenarios/table/no-header.adoc +0 -8
  346. data/spec/scenarios/table/no-header.md +0 -2
  347. data/spec/scenarios/table/single-column-with-header.adoc +0 -6
  348. data/spec/scenarios/table/single-column-with-header.md +0 -4
  349. data/spec/scenarios/table/single-column-without-header.adoc +0 -4
  350. data/spec/scenarios/table/single-column-without-header.md +0 -2
  351. data/spec/scenarios/text/attribute-reference.adoc +0 -1
  352. data/spec/scenarios/text/attribute-reference.md +0 -1
  353. data/spec/scenarios/text/caret.adoc +0 -1
  354. data/spec/scenarios/text/caret.md +0 -1
  355. data/spec/scenarios/text/lte.adoc +0 -1
  356. data/spec/scenarios/text/lte.md +0 -1
  357. data/spec/scenarios/text/nbsp.adoc +0 -1
  358. data/spec/scenarios/text/nbsp.md +0 -1
  359. data/spec/scenarios/text/plus-plus.adoc +0 -6
  360. data/spec/scenarios/text/plus-plus.md +0 -5
  361. data/spec/scenarios/text/right-arrow.adoc +0 -1
  362. data/spec/scenarios/text/right-arrow.md +0 -1
  363. data/spec/scenarios/text/typographic_sym/apostrophe.adoc +0 -3
  364. data/spec/scenarios/text/typographic_sym/apostrophe.md +0 -3
  365. data/spec/scenarios/text/typographic_sym/double-quotes.adoc +0 -1
  366. data/spec/scenarios/text/typographic_sym/double-quotes.md +0 -1
  367. data/spec/scenarios/text/typographic_sym/ellipsis.adoc +0 -1
  368. data/spec/scenarios/text/typographic_sym/ellipsis.md +0 -1
  369. data/spec/scenarios/text/typographic_sym/mdash.adoc +0 -1
  370. data/spec/scenarios/text/typographic_sym/mdash.md +0 -1
  371. data/spec/scenarios/text/typographic_sym/ndash.adoc +0 -1
  372. data/spec/scenarios/text/typographic_sym/ndash.md +0 -1
  373. data/spec/scenarios/text/typographic_sym/single-quotes.adoc +0 -1
  374. data/spec/scenarios/text/typographic_sym/single-quotes.md +0 -1
  375. data/spec/scenarios/trailing_space.adoc +0 -7
  376. data/spec/scenarios/trailing_space.md +0 -7
  377. data/spec/scenarios/typographic_sym/ellipsis.adoc +0 -1
  378. data/spec/scenarios/typographic_sym/ellipsis.md +0 -1
  379. data/spec/scenarios/typographic_sym/mdash.adoc +0 -1
  380. data/spec/scenarios/typographic_sym/mdash.md +0 -1
  381. data/spec/scenarios/typographic_sym/ndash.adoc +0 -1
  382. data/spec/scenarios/typographic_sym/ndash.md +0 -1
  383. data/spec/scenarios/ul/blockquote.adoc +0 -5
  384. data/spec/scenarios/ul/blockquote.md +0 -2
  385. data/spec/scenarios/ul/compound-nested.adoc +0 -23
  386. data/spec/scenarios/ul/compound-nested.md +0 -19
  387. data/spec/scenarios/ul/compound-only.adoc +0 -5
  388. data/spec/scenarios/ul/compound-only.md +0 -3
  389. data/spec/scenarios/ul/compound-separated.adoc +0 -41
  390. data/spec/scenarios/ul/compound-separated.md +0 -32
  391. data/spec/scenarios/ul/compound.adoc +0 -41
  392. data/spec/scenarios/ul/compound.md +0 -26
  393. data/spec/scenarios/ul/formatted.adoc +0 -3
  394. data/spec/scenarios/ul/formatted.md +0 -3
  395. data/spec/scenarios/ul/inside-delimited-block.adoc +0 -9
  396. data/spec/scenarios/ul/inside-delimited-block.md +0 -7
  397. data/spec/scenarios/ul/nested-bookended.adoc +0 -7
  398. data/spec/scenarios/ul/nested-bookended.md +0 -7
  399. data/spec/scenarios/ul/nested-separated.adoc +0 -11
  400. data/spec/scenarios/ul/nested-separated.md +0 -21
  401. data/spec/scenarios/ul/nested.adoc +0 -11
  402. data/spec/scenarios/ul/nested.md +0 -11
  403. data/spec/scenarios/ul/simple-separated.adoc +0 -3
  404. data/spec/scenarios/ul/simple-separated.md +0 -5
  405. data/spec/scenarios/ul/simple.adoc +0 -3
  406. data/spec/scenarios/ul/simple.md +0 -3
  407. data/spec/scenarios/wrap/containing-line-comment.adoc +0 -3
  408. data/spec/scenarios/wrap/containing-line-comment.md +0 -3
  409. data/spec/scenarios/wrap/containing-line-comment.opts +0 -1
  410. data/spec/scenarios/wrap/none.adoc +0 -1
  411. data/spec/scenarios/wrap/none.md +0 -4
  412. data/spec/scenarios/wrap/none.opts +0 -1
  413. data/spec/scenarios/wrap/preserve.adoc +0 -5
  414. data/spec/scenarios/wrap/preserve.md +0 -5
  415. data/spec/scenarios/wrap/preserve.opts +0 -1
  416. data/spec/scenarios/wrap/ventilate-exclamation.adoc +0 -3
  417. data/spec/scenarios/wrap/ventilate-exclamation.md +0 -1
  418. data/spec/scenarios/wrap/ventilate-exclamation.opts +0 -1
  419. data/spec/scenarios/wrap/ventilate-french.adoc +0 -3
  420. data/spec/scenarios/wrap/ventilate-french.md +0 -1
  421. data/spec/scenarios/wrap/ventilate-french.opts +0 -1
  422. data/spec/scenarios/wrap/ventilate-question.adoc +0 -3
  423. data/spec/scenarios/wrap/ventilate-question.md +0 -3
  424. data/spec/scenarios/wrap/ventilate-question.opts +0 -1
  425. data/spec/scenarios/wrap/ventilate-table-cell.adoc +0 -9
  426. data/spec/scenarios/wrap/ventilate-table-cell.md +0 -3
  427. data/spec/scenarios/wrap/ventilate-table-cell.opts +0 -1
  428. data/spec/scenarios/wrap/ventilate-with-comments.adoc +0 -5
  429. data/spec/scenarios/wrap/ventilate-with-comments.md +0 -5
  430. data/spec/scenarios/wrap/ventilate-with-comments.opts +0 -1
  431. data/spec/scenarios/wrap/ventilate.adoc +0 -2
  432. data/spec/scenarios/wrap/ventilate.md +0 -6
  433. data/spec/scenarios/wrap/ventilate.opts +0 -1
  434. data/spec/scenarios/xml_comment/above-block.adoc +0 -7
  435. data/spec/scenarios/xml_comment/above-block.md +0 -5
  436. data/spec/scenarios/xml_comment/above-header.adoc +0 -13
  437. data/spec/scenarios/xml_comment/above-header.md +0 -16
  438. data/spec/scenarios/xml_comment/at-start-of-line.adoc +0 -9
  439. data/spec/scenarios/xml_comment/at-start-of-line.md +0 -4
  440. data/spec/scenarios/xml_comment/block.adoc +0 -7
  441. data/spec/scenarios/xml_comment/block.md +0 -6
  442. data/spec/scenarios/xml_comment/line-adjacent-to-text.adoc +0 -2
  443. data/spec/scenarios/xml_comment/line-adjacent-to-text.md +0 -1
  444. data/spec/scenarios/xml_comment/line-empty.adoc +0 -7
  445. data/spec/scenarios/xml_comment/line-empty.md +0 -9
  446. data/spec/scenarios/xml_comment/line-offset-by-space.adoc +0 -1
  447. data/spec/scenarios/xml_comment/line-offset-by-space.md +0 -1
  448. data/spec/scenarios/xml_comment/line.adoc +0 -1
  449. data/spec/scenarios/xml_comment/line.md +0 -1
  450. data/spec/scenarios/xml_comment/list-separator.adoc +0 -7
  451. data/spec/scenarios/xml_comment/list-separator.md +0 -7
  452. data/spec/scenarios/xml_comment/mixed.adoc +0 -7
  453. data/spec/scenarios/xml_comment/mixed.md +0 -6
  454. data/spec/scenarios/xml_comment/multiline-span.adoc +0 -8
  455. data/spec/scenarios/xml_comment/multiline-span.md +0 -7
  456. data/spec/scenarios/xml_comment/p-separator.adoc +0 -5
  457. data/spec/scenarios/xml_comment/p-separator.md +0 -5
  458. data/spec/scenarios/xml_comment/styled.adoc +0 -6
  459. data/spec/scenarios/xml_comment/styled.md +0 -6
  460. data/spec/scenarios/xml_comment/surrounded-by-spaces.adoc +0 -3
  461. data/spec/scenarios/xml_comment/surrounded-by-spaces.md +0 -1
  462. data/spec/spec_helper.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f703fb6eabd74ef5641f298a7d7bc2fadce80e5fe9b97d1965abad29a5f5a4d6
4
- data.tar.gz: 18c3c1f8f4f2006381b83561badf425e56762216c92d64cc42aae640058ded82
3
+ metadata.gz: fbe551c7f58e65076b32bccc18a15c31d4ad2f7a6e7510ff37095e1782d0bd90
4
+ data.tar.gz: 1bbf3ccce901f2b9dd470a09a9f54fe257461922cbb1ef959cbc9071a3d72bca
5
5
  SHA512:
6
- metadata.gz: 1f51c28d5cfa7d9c7fb8c1f32e5502a052b0e0030f782c0f4e4f6814c792a36d9f9e03663013d84b338021e0524fefb0fcf54b8a381078f22ebb56cd1f645f06
7
- data.tar.gz: 768357f79d874791c79aa6f4a0c1df5f3eaa3fff1648b03f1465d5648ba64ab62279823a2e9133950e42904fdb75c84462db830a1ceecfc2e50d1d60f6b7fafe
6
+ metadata.gz: e1ee0ea89e5769051d486a231f15f1c9e6ad0ad7e8a1094573d4cf2fa994b8c2a581db49b65486b188101c16dbf16ce05f032ca17d598cd360cfbaf1c243bcbb
7
+ data.tar.gz: '0381ac4bade1dc05edcc5825e3acbc4074ef9ed692ea8074e7eab89d69f20074c06478d4bd9407441263a261b0a132a0e385d2798f551a62529cc57bc149ec89'
data/CHANGELOG.adoc CHANGED
@@ -5,6 +5,26 @@
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.rc.1 (2018-11-06) - @mojavelinux
9
+
10
+ === Added
11
+
12
+ * ventilate prose on semi-colon following non-space character
13
+ * add :preprocessors option to convert API; apply default preprocessors if not set; apply none if falsy (#23)
14
+ * add :postprocessors option to convert API; takes precedence over :postprocess option (#67)
15
+ * accept IO object as input to convert method (#49)
16
+ * accept File object as input to convert_file method (#49)
17
+ * add API docs to public API methods
18
+
19
+ === Changed
20
+
21
+ * remove whitespace in front of leading XML comment (so a block comment isn't mistaken for an inline comment)
22
+ * drop empty XML comment unless it comes after a list
23
+
24
+ === Details
25
+
26
+ {uri-repo}/releases/tag/v1.0.0.rc.1[git tag] | {uri-repo}/compare/v1.0.0.alpha.13\...v1.0.0.rc.1[full diff]
27
+
8
28
  == 1.0.0.alpha.13 (2018-08-21) - @mojavelinux
9
29
 
10
30
  === Added
@@ -25,6 +45,10 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
25
45
 
26
46
  * enclose codeblock content in literal block delimiters if content starts with a list marker (#57)
27
47
 
48
+ === Details
49
+
50
+ {uri-repo}/releases/tag/v1.0.0.alpha.13[git tag] | {uri-repo}/compare/v1.0.0.alpha.12\...v1.0.0.alpha.13[full diff]
51
+
28
52
  == 1.0.0.alpha.12 (2018-08-11) - @mojavelinux
29
53
 
30
54
  === Added
data/Gemfile CHANGED
@@ -1,3 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ group :docs do
6
+ gem 'yard'
7
+ gem 'asciidoctor'
8
+ end
data/README.adoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = {project-name} (Markdown to AsciiDoc)
2
2
  Dan Allen <https://github.com/mojavelinux>
3
- v1.0.0.alpha.13, 2018-08-21
3
+ v1.0.0.rc.1, 2018-11-06
4
4
  // Aliases:
5
5
  :project-name: Kramdown AsciiDoc
6
6
  :project-handle: kramdown-asciidoc
@@ -25,26 +25,26 @@ endif::[]
25
25
  :uri-kramdown: https://kramdown.gettalong.org
26
26
  :uri-rvm: https://rvm.io
27
27
  :uri-rvm-install: https://rvm.io/rvm/install
28
- :uri-docs-api: https://www.rubydoc.info/github/asciidoctor/kramdown-asciidoc/master
28
+ :uri-api-docs: https://www.rubydoc.info/github/asciidoctor/kramdown-asciidoc/master
29
29
  :uri-ci-appveyor: https://ci.appveyor.com/project/asciidoctor/kramdown-asciidoc
30
- :img-ci-appveyor: https://ci.appveyor.com/api/projects/status/2pwvdbcoeux1ifb5/branch/master?svg=true
30
+ :img-uri-ci-appveyor: https://ci.appveyor.com/api/projects/status/2pwvdbcoeux1ifb5/branch/master?svg=true
31
31
  :uri-ci-travis: https://travis-ci.org/asciidoctor/kramdown-asciidoc
32
- :uri-ci-travis-img: https://img.shields.io/travis/asciidoctor/kramdown-asciidoc/master.svg
32
+ :img-uri-ci-travis: https://img.shields.io/travis/asciidoctor/kramdown-asciidoc/master.svg
33
33
  :uri-gem: https://rubygems.org/gems/kramdown-asciidoc
34
- :uri-gem-img: https://img.shields.io/gem/v/kramdown-asciidoc.svg?label=gem
34
+ :img-uri-gem: https://img.shields.io/gem/v/kramdown-asciidoc.svg?label=gem
35
35
 
36
36
  ifdef::status[]
37
- image:{uri-gem-img}[Gem Version,link={uri-gem}]
38
- image:{uri-ci-travis-img}[Build Status (Travis CI),link={uri-ci-travis}]
39
- image:{img-ci-appveyor}[Build Status (AppVeyor),link={uri-ci-appveyor}]
37
+ image:{img-uri-gem}[Gem Version,link={uri-gem}]
38
+ image:{img-uri-ci-travis}[Build Status (Travis CI),link={uri-ci-travis}]
39
+ image:{img-uri-ci-appveyor}[Build Status (AppVeyor),link={uri-ci-appveyor}]
40
40
  endif::[]
41
41
 
42
- {uri-repo}[{project-name}] (gem: *{project-handle}*) is a {uri-kramdown}[kramdown] extension for converting Markdown documents to {uri-asciidoc}[AsciiDoc].
42
+ {uri-repo}[{project-name}] (gem: *{project-handle}*, command: `kramdoc`) is a {uri-kramdown}[kramdown] extension for converting Markdown documents to {uri-asciidoc}[AsciiDoc].
43
43
  Notably, the converter generates modern AsciiDoc syntax suitable for use with {uri-asciidoctor}[Asciidoctor].
44
44
 
45
45
  == Prerequisites
46
46
 
47
- To install and run {project-name}, you need Ruby 2.4 or better installed and a few RubyGems (aka gems).
47
+ To install and run {project-name}, you need Ruby 2.3 or better installed and a few RubyGems (aka gems).
48
48
  We'll explain how to install the gems in the next section.
49
49
 
50
50
  To check whether you have Ruby installed, and which version, run the following command:
@@ -164,15 +164,15 @@ If these values do not match the defaults in AsciiDoc, the `idprefix` and/or `id
164
164
 
165
165
  == API
166
166
 
167
- In additional to the command-line interface, {project-name} also provides a porcelain API (see {uri-docs-api}[API docs]).
167
+ In additional to the command-line interface, {project-name} also provides a porcelain API (see {uri-api-docs}[API docs]).
168
168
  We use the term "`porcelain`" because the API hides the details of registering the converter, preprocessing the Markdown document, parsing the document with kramdown, and calling the converter method to transform the parse tree to AsciiDoc.
169
169
 
170
- The API consists of two static methods:
170
+ The API consists of two static methods in the Kramdoc module:
171
171
 
172
- * `Kramdoc.convert(source, opts)` - convert a Markdown string to AsciiDoc
173
- * `Kramdoc.convert_file(file, opts)` - convert a Markdown file to AsciiDoc
172
+ * `Kramdoc.convert(source, opts)` - convert a Markdown string or IO object to AsciiDoc
173
+ * `Kramdoc.convert_file(file, opts)` - convert a Markdown file object or path to AsciiDoc
174
174
 
175
- NOTE: `Kramdoc` is shorthand for `Kramdown::AsciiDoc` to align with the name of the CLI.
175
+ NOTE: `Kramdoc` is a shorthand for `Kramdown::AsciiDoc` to align with the name of the CLI.
176
176
 
177
177
  Both API methods accept the source as the first argument and an options hash as the second.
178
178
 
@@ -220,7 +220,7 @@ Kramdoc.convert markdown, to: 'result.adoc'
220
220
 
221
221
  The input string is automatically converted to UTF-8.
222
222
 
223
- For more information about the API, refer to the {uri-docs-api}[API documentation].
223
+ For more information about the API, refer to the {uri-api-docs}[API documentation].
224
224
 
225
225
  == Development
226
226
 
@@ -17,23 +17,21 @@ Gem::Specification.new do |s|
17
17
  'mailing_list_uri' => 'http://discuss.asciidoctor.org',
18
18
  'source_code_uri' => 'https://github.com/asciidoctor/kramdown-asciidoc'
19
19
  }
20
- #s.required_ruby_version = '>= 2.4.0'
20
+ # NOTE required ruby version is informational only; it's not enforced since it can't be overridden and can cause builds to break
21
+ #s.required_ruby_version = '>= 2.3.0'
21
22
 
22
23
  files = begin
23
24
  (result = Open3.popen3('git ls-files -z') {|_, out| out.read }.split ?\0).empty? ? Dir['**/*'] : result
24
25
  rescue
25
26
  Dir['**/*']
26
27
  end
27
- s.files = files.grep %r/^(?:lib\/.+|Gemfile|Rakefile|(?:CHANGELOG|CONTRIBUTING|LICENSE|README)\.adoc|#{s.name}\.gemspec)$/
28
- s.test_files = files.grep %r/^(?:spec\/.+)$/
28
+ #s.files = files.grep %r/^(?:lib\/.+|Gemfile|Rakefile|(?:CHANGELOG|CONTRIBUTING|LICENSE|README)\.adoc|#{s.name}\.gemspec)$/
29
+ #s.test_files = files.grep %r/^(?:spec\/.+)$/
30
+ s.files = files.grep %r/^(?:lib\/.+|Gemfile|(?:CHANGELOG|LICENSE|README)\.adoc|#{s.name}\.gemspec)$/
29
31
  s.executables = ['kramdoc']
30
32
 
31
33
  s.require_paths = ['lib']
32
34
 
33
- #s.has_rdoc = true
34
- #s.rdoc_options = ['--charset=UTF-8']
35
- #s.extra_rdoc_files = ['CHANGELOG.adoc', 'LICENSE.adoc']
36
-
37
35
  s.add_runtime_dependency 'kramdown', '~> 1.17.0'
38
36
  s.add_development_dependency 'deep-cover-core', '~> 0.6.3'
39
37
  s.add_development_dependency 'rake', '~> 12.3.1'
@@ -2,8 +2,13 @@ require 'kramdown'
2
2
  require_relative 'kramdown-asciidoc/kramdown_ext/parser/base'
3
3
  require_relative 'kramdown-asciidoc/kramdown_ext/parser/html'
4
4
  require_relative 'kramdown-asciidoc/core_ext/regexp/is_match'
5
- require_relative 'kramdown-asciidoc/api'
6
- require_relative 'kramdown-asciidoc/converter'
5
+ require_relative 'kramdown-asciidoc/preprocessors'
7
6
  require_relative 'kramdown-asciidoc/writer'
7
+ require_relative 'kramdown-asciidoc/converter'
8
+ require_relative 'kramdown-asciidoc/api'
9
+ # register AsciiDoc converter with kramdown
10
+ Kramdown::Converter::Asciidoc = Kramdown::AsciiDoc::Converter
11
+ # add Kramdoc alias
12
+ Kramdoc = Kramdown::AsciiDoc
8
13
  autoload :Pathname, 'pathname'
9
14
  autoload :YAML, 'yaml'
@@ -1,21 +1,57 @@
1
1
  module Kramdown; module AsciiDoc
2
- CR = ?\r
3
- LF = ?\n
4
- UTF_8 = ::Encoding::UTF_8
2
+ DEFAULT_PARSER_OPTS = {
3
+ auto_ids: false,
4
+ hard_wrap: false,
5
+ html_to_native: true,
6
+ input: 'GFM',
7
+ }
5
8
 
9
+ DEFAULT_PREPROCESSORS = [
10
+ (Preprocessors.method :extract_front_matter),
11
+ (Preprocessors.method :replace_toc),
12
+ (Preprocessors.method :snap_leading_comment),
13
+ ]
14
+
15
+ # Converts a Markdown string to an AsciiDoc string and either returns the result or writes it to a file.
16
+ #
17
+ # @param markdown [String, IO] the Markdown source to convert to AsciiDoc.
18
+ # @param opts [Hash] additional options to configure the behavior of the converter.
19
+ # @option opts [Boolean] :auto_ids (false) controls whether converter automatically generates an explicit ID for any
20
+ # section title (aka heading) that doesn't already have an ID assigned to it.
21
+ # @option opts [String] :auto_id_prefix (nil) the prefix to add to an auto-generated ID.
22
+ # @option opts [String] :auto_id_separator ('-') the separator to use in auto-generated IDs.
23
+ # @option opts [Boolean] :lazy_ids (false) controls whether to drop the ID if it matches the auto-generated ID value.
24
+ # @option opts [Symbol] :wrap (:preserve) the line wrapping behavior to apply (:preserve, :ventilate, or :none).
25
+ # @option opts [Integer] :heading_offset (0) the heading offset to apply to heading levels.
26
+ # @option opts [Boolean] :auto_links (true) whether to allow raw URLs to be recognized as links.
27
+ # @option opts [Hash] :attributes ({}) AsciiDoc attributes to add to the document header of the output document.
28
+ # @option opts [Symbol] :encode (true) whether to reencode the source to UTF-8.
29
+ # @option opts [Array<Proc>] :preprocessors ([]) a list of preprocessors functions to execute on the cleaned Markdown source.
30
+ # @option opts [Array<Proc>] :postprocessors ([]) a list of functions through which to run the output document.
31
+ # @option opts [Proc] :postprocess (nil) a function through which to run the output document (if :postprocessors is falsy).
32
+ # @option opts [String, Pathname] :to (nil) the path to which to write the output document.
33
+ #
34
+ # @return [String, nil] the converted AsciiDoc or nil if the :to option is specified.
6
35
  def self.convert markdown, opts = {}
7
- unless opts[:encode] == false || (markdown.encoding == UTF_8 && !(markdown.include? CR))
36
+ if markdown.respond_to? :read
37
+ markdown = markdown.read
38
+ encode = true
39
+ else
40
+ encode = opts[:encode]
41
+ end
42
+ unless encode == false || (markdown.encoding == UTF_8 && !(markdown.include? CR))
8
43
  markdown = markdown.encode UTF_8, universal_newline: true
9
44
  end
10
45
  markdown = markdown.rstrip
11
46
  markdown = markdown.slice 1, markdown.length while markdown.start_with? LF
12
- parser_opts = ::Kramdown::AsciiDoc::DEFAULT_PARSER_OPTS.merge opts
47
+ parser_opts = DEFAULT_PARSER_OPTS.merge opts
13
48
  attributes = (parser_opts[:attributes] = (parser_opts[:attributes] || {}).dup)
14
- markdown = ::Kramdown::AsciiDoc.extract_front_matter markdown, attributes
15
- markdown = ::Kramdown::AsciiDoc.replace_toc markdown, attributes
49
+ ((opts.fetch :preprocessors, DEFAULT_PREPROCESSORS) || []).each do |preprocessor|
50
+ markdown = preprocessor[markdown, attributes]
51
+ end
16
52
  asciidoc = (kramdown_doc = ::Kramdown::Document.new markdown, parser_opts).to_asciidoc
17
- if (postprocess = opts[:postprocess])
18
- asciidoc = (postprocess.arity == 1 ? postprocess[asciidoc] : postprocess[asciidoc, kramdown_doc]) || asciidoc
53
+ (opts[:postprocessors] || Array(opts[:postprocess])).each do |postprocessor|
54
+ asciidoc = (postprocessor.arity == 1 ? postprocessor[asciidoc] : postprocessor[asciidoc, kramdown_doc]) || asciidoc
19
55
  end
20
56
  asciidoc += LF unless asciidoc.empty?
21
57
  if (to = opts[:to])
@@ -31,18 +67,47 @@ module Kramdown; module AsciiDoc
31
67
  end
32
68
  end
33
69
 
70
+ # Converts a Markdown file to AsciiDoc and writes the result to a file or the specified destination.
71
+ #
72
+ # @param markdown_file [String, File] the Markdown file or file path to convert to AsciiDoc.
73
+ # @param opts [Hash] additional options to configure the behavior of the converter.
74
+ # @option opts [Boolean] :auto_ids (false) controls whether converter automatically generates an explicit ID for any
75
+ # section title (aka heading) that doesn't already have an ID assigned to it.
76
+ # @option opts [String] :auto_id_prefix (nil) the prefix to add to an auto-generated ID.
77
+ # @option opts [String] :auto_id_separator ('-') the separator to use in auto-generated IDs.
78
+ # @option opts [Boolean] :lazy_ids (false) controls whether to drop the ID if it matches the auto-generated ID value.
79
+ # @option opts [Symbol] :wrap (:preserve) the line wrapping behavior to apply (:preserve, :ventilate, or :none).
80
+ # @option opts [Integer] :heading_offset (0) the heading offset to apply to heading levels.
81
+ # @option opts [Boolean] :auto_links (true) whether to allow raw URLs to be recognized as links.
82
+ # @option opts [Hash] :attributes ({}) AsciiDoc attributes to add to the document header of the output document.
83
+ # @option opts [Array<Proc>] :preprocessors ([]) a list of preprocessors functions to execute on the cleaned Markdown source.
84
+ # @option opts [Array<Proc>] :postprocessors ([]) a list of functions through which to run the output document.
85
+ # @option opts [Proc] :postprocess (nil) a function through which to run the output document (if :postprocessors is falsy).
86
+ # @option opts [String, Pathname] :to (nil) the path to which to write the output document.
87
+ #
88
+ # @return [String, nil] the converted document if the :to option is specified and is falsy, otherwise nil.
34
89
  def self.convert_file markdown_file, opts = {}
35
- markdown = ::IO.read markdown_file, mode: 'r:UTF-8', newline: :universal
90
+ if ::File === markdown_file
91
+ markdown = markdown_file.read
92
+ markdown_file = markdown_file.path
93
+ encode = true
94
+ else
95
+ markdown = ::IO.read markdown_file, mode: 'r:UTF-8', newline: :universal
96
+ encode = false
97
+ end
36
98
  if (to = opts[:to])
37
99
  to = ::Pathname.new to.to_s unless ::Pathname === to || (to.respond_to? :write)
38
- else
39
- unless opts.key? :to
40
- to = (::Pathname.new markdown_file).sub_ext '.adoc'
41
- raise ::IOError, %(input and output cannot be the same file: #{markdown_file}) if to.to_s == markdown_file.to_s
42
- end
100
+ elsif !(opts.key? :to)
101
+ to = (::Pathname.new markdown_file).sub_ext '.adoc'
102
+ raise ::IOError, %(input and output cannot be the same file: #{markdown_file}) if to.to_s == markdown_file.to_s
43
103
  end
44
- convert markdown, (opts.merge to: to, encode: false)
104
+ convert markdown, (opts.merge to: to, encode: encode)
45
105
  end
46
- end; end
47
106
 
48
- Kramdoc = Kramdown::AsciiDoc
107
+ private
108
+
109
+ CR = ?\r
110
+ LF = ?\n
111
+ TAB = ?\t
112
+ UTF_8 = ::Encoding::UTF_8
113
+ end; end
@@ -109,7 +109,7 @@ module Kramdown; module AsciiDoc
109
109
  pipe_out = (output_file = options.delete :output_file) == '-'
110
110
  if pipe_in
111
111
  options[:to] = pipe_out || !output_file ? $stdout : output_file
112
- ::Kramdoc.convert $stdin.read, options
112
+ ::Kramdoc.convert $stdin, options
113
113
  elsif output_file && !pipe_out && (::File.expand_path input_file) == (::File.expand_path output_file)
114
114
  $stderr.write %(kramdoc: input and output cannot be the same file: #{input_file}\n)
115
115
  return 1
@@ -1,50 +1,8 @@
1
1
  # encoding: UTF-8
2
2
  module Kramdown; module AsciiDoc
3
- using CoreExt
4
-
5
- DEFAULT_PARSER_OPTS = {
6
- auto_ids: false,
7
- hard_wrap: false,
8
- html_to_native: true,
9
- input: 'GFM',
10
- }
11
-
12
- TocDirectiveTip = '<!-- TOC '
13
- TocDirectiveRx = /^<!-- TOC .*<!-- \/TOC -->/m
14
-
15
- # TODO return original source if YAML can't be parsed
16
- def self.extract_front_matter source, attributes
17
- if (line_i = (lines = source.each_line).first) && line_i.chomp == '---'
18
- lines = lines.drop 1
19
- front_matter = []
20
- while (line = lines.shift) && line.chomp != '---'
21
- front_matter << line
22
- end
23
- return source unless line && line.chomp == '---' && !(front_matter.include? ?\n)
24
- lines.shift while (line = lines[0]) && line == ?\n
25
- (::YAML.load front_matter.join).each do |key, val|
26
- if key == 'layout'
27
- attributes['page-layout'] = val unless val == 'default'
28
- else
29
- attributes[key] = val.to_s
30
- end
31
- end unless front_matter.empty?
32
- lines.join
33
- else
34
- source
35
- end
36
- end
37
-
38
- def self.replace_toc source, attributes
39
- if source.include? TocDirectiveTip
40
- attributes['toc'] = 'macro'
41
- source.gsub TocDirectiveRx, 'toc::[]'
42
- else
43
- source
44
- end
45
- end
46
-
47
3
  class Converter < ::Kramdown::Converter::Base
4
+ using CoreExt
5
+
48
6
  RESOLVE_ENTITY_TABLE = { 38 => '&', 60 => '<', 62 => '>', 124 => '|' }
49
7
  ADMON_LABELS = %w(Note Tip Caution Warning Important Attention Hint).map {|l| [l, l] }.to_h
50
8
  ADMON_MARKERS = ADMON_LABELS.map {|l, _| %(#{l}: ) }
@@ -54,7 +12,7 @@ module Kramdown; module AsciiDoc
54
12
  BLOCK_TYPES = [:p, :blockquote, :codeblock, :table]
55
13
  DLIST_MARKERS = %w(:: ;; ::: ::::)
56
14
  NON_DEFAULT_TABLE_ALIGNMENTS = [:center, :right]
57
- PUNCTUATION = %w(. ? !)
15
+ STOP_PUNCTUATION = %w(. ? ! ;)
58
16
  # FIXME here we reverse the smart quotes; add option to allow them (needs to be handled carefully)
59
17
  SMART_QUOTE_ENTITY_TO_MARKUP = { ldquo: ?", rdquo: ?", lsquo: ?', rsquo: ?' }
60
18
  TYPOGRAPHIC_SYMBOL_TO_MARKUP = {
@@ -83,13 +41,13 @@ module Kramdown; module AsciiDoc
83
41
 
84
42
  CommentPrefixRx = /^ *! ?/m
85
43
  CssPropDelimRx = /\s*;\s*/
86
- FullStopRx = /(?<=\S\.|.\?|.!)\p{Blank}+/
87
44
  InadvertentReplacementsRx = /[-=]>|<[-=]|\.\.\.|\{\p{Word}[\p{Word}-]*\}/
88
45
  InvalidIdCharsRx = /&(?:[a-z][a-z]+\d{0,2}|#\d\d\d{0,4}|#x[\da-f][\da-f][\da-f]{0,3});|[^ \p{Word}\-.]+?/
89
46
  ListMarkerRx = /^[ \t]*(?:(?:-|\*\*{0,4}|\.\.{0,4}|\d+\.|[a-zA-Z]\.|[IVXivx]+\))[ \t]|.*?(?::::{0,2}|;;)(?:$|[ \t]))/
90
47
  MenuRefRx = /^([\p{Word}&].*?)\s>\s([\p{Word}&].*(?:\s>\s|$))+/
91
48
  ReplaceableTextRx = /[-=]>|<[-=]| -- |\p{Word}--\p{Word}|\*\*|\.\.\.|&\S+;|\{\p{Word}[\p{Word}-]*\}|(?:https?|ftp):\/\/\p{Word}|\((?:C|R|TM)\)/
92
49
  SmartApostropheRx = /\b’\b/
50
+ StopPunctRx = /(?<=\S[.;]|.\?|.!)\p{Blank}+/
93
51
  TrailingSpaceRx = / +$/
94
52
  TypographicSymbolRx = /[“”‘’—–…]/
95
53
  UriSchemeRx = /(?:https?|ftp):\/\/\p{Word}/
@@ -617,8 +575,13 @@ module Kramdown; module AsciiDoc
617
575
 
618
576
  def convert_xml_comment el, opts
619
577
  writer = opts[:writer]
620
- XmlCommentRx =~ el.value
621
- lines = (($1.include? ' !') ? ($1.gsub CommentPrefixRx, '').strip : $1.strip).split LF
578
+ if (val = (XmlCommentRx.match el.value)[1]).include? ' !'
579
+ lines = (val.gsub CommentPrefixRx, '').strip.split LF
580
+ elsif (val = val.strip).empty? && !writer.follows_list?
581
+ return
582
+ else
583
+ lines = val.split LF
584
+ end
622
585
  #siblings = (parent = opts[:parent]) ? parent.children : []
623
586
  if (el.options[:category] == :block)# || (!opts[:result][-1] && siblings[-1] == el)
624
587
  writer.start_block
@@ -730,7 +693,7 @@ module Kramdown; module AsciiDoc
730
693
  end
731
694
  if ventilate
732
695
  result.map {|line|
733
- (line.start_with? '//') || !(PUNCTUATION.any? {|punc| line.include? punc }) ? line : (line.gsub FullStopRx, LF)
696
+ (line.start_with? '//') || !(STOP_PUNCTUATION.any? {|punc| line.include? punc }) ? line : (line.gsub StopPunctRx, LF)
734
697
  }.join LF
735
698
  else
736
699
  result.join LF
@@ -779,5 +742,3 @@ module Kramdown; module AsciiDoc
779
742
  end
780
743
  end
781
744
  end; end
782
-
783
- Kramdown::Converter::Asciidoc = Kramdown::AsciiDoc::Converter
@@ -1,5 +1,12 @@
1
1
  class Kramdown::Parser::Base
2
- # Overload parse to force value of :auto_ids option to false; handled by converter instead
2
+ # Overload the parse method to force value of the :auto_ids option to false.
3
+ #
4
+ # The :auto_ids logic is handled instead by the Kramdown::AsciiDoc::Converter class
5
+ #
6
+ # @param source [String] the Markdown source string to parse.
7
+ # @param options [Hash] additional options to configure parsing.
8
+ #
9
+ # @return [Array<Kramdown::Element, Array>] a tuple of the document root element and a list of warning objects.
3
10
  def self.parse source, options
4
11
  (parser = new source, (options.merge auto_ids: false, auto_id_stripping: false)).parse
5
12
  [parser.root, parser.warnings]
@@ -1,5 +1,9 @@
1
1
  class Kramdown::Parser::Html::ElementConverter
2
- # Overload convert_br to add the :html_tag option to indicate this br element originates from an HTML tag
2
+ # Overload the convert_br method to add the :html_tag option to indicate this element originates from an HTML tag.
3
+ #
4
+ # @param el [Kramdown::Element] The element that represents an HTML br tag.
5
+ #
6
+ # @return [void]
3
7
  def convert_br el
4
8
  el.options.replace location: el.options[:location], html_tag: true
5
9
  el.type = el.value.to_sym