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.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +24 -0
- data/Gemfile +5 -0
- data/README.adoc +16 -16
- data/kramdown-asciidoc.gemspec +5 -7
- data/lib/kramdown-asciidoc.rb +7 -2
- data/lib/kramdown-asciidoc/api.rb +83 -18
- data/lib/kramdown-asciidoc/cli.rb +1 -1
- data/lib/kramdown-asciidoc/converter.rb +12 -51
- data/lib/kramdown-asciidoc/kramdown_ext/parser/base.rb +8 -1
- data/lib/kramdown-asciidoc/kramdown_ext/parser/html.rb +5 -1
- data/lib/kramdown-asciidoc/preprocessors.rb +64 -0
- data/lib/kramdown-asciidoc/version.rb +1 -1
- data/lib/kramdown-asciidoc/writer.rb +8 -0
- metadata +5 -897
- data/Rakefile +0 -3
- data/spec/api_spec.rb +0 -228
- data/spec/cli_spec.rb +0 -300
- data/spec/converter_spec.rb +0 -271
- data/spec/scenario_spec.rb +0 -25
- data/spec/scenarios/a/bare-interdoc-xref.adoc +0 -1
- data/spec/scenarios/a/bare-interdoc-xref.md +0 -1
- data/spec/scenarios/a/bare-url.adoc +0 -1
- data/spec/scenarios/a/bare-url.md +0 -1
- data/spec/scenarios/a/containing-inline-image.adoc +0 -5
- data/spec/scenarios/a/containing-inline-image.md +0 -5
- data/spec/scenarios/a/double-underscore-in-url.adoc +0 -1
- data/spec/scenarios/a/double-underscore-in-url.md +0 -1
- data/spec/scenarios/a/interdoc-xref.adoc +0 -1
- data/spec/scenarios/a/interdoc-xref.md +0 -1
- data/spec/scenarios/a/internal.adoc +0 -5
- data/spec/scenarios/a/internal.md +0 -5
- data/spec/scenarios/a/local.adoc +0 -1
- data/spec/scenarios/a/local.md +0 -1
- data/spec/scenarios/a/no-auto-links.adoc +0 -3
- data/spec/scenarios/a/no-auto-links.md +0 -3
- data/spec/scenarios/a/no-auto-links.opts +0 -1
- data/spec/scenarios/a/url-matches-text.adoc +0 -2
- data/spec/scenarios/a/url-matches-text.md +0 -2
- data/spec/scenarios/a/url-with-text.adoc +0 -1
- data/spec/scenarios/a/url-with-text.md +0 -1
- data/spec/scenarios/attributes/sorting.adoc +0 -6
- data/spec/scenarios/attributes/sorting.md +0 -3
- data/spec/scenarios/attributes/sorting.opts +0 -3
- data/spec/scenarios/blockquote/attribution-separated.adoc +0 -5
- data/spec/scenarios/blockquote/attribution-separated.md +0 -5
- data/spec/scenarios/blockquote/attribution.adoc +0 -5
- data/spec/scenarios/blockquote/attribution.md +0 -3
- data/spec/scenarios/blockquote/basic.adoc +0 -3
- data/spec/scenarios/blockquote/basic.md +0 -1
- data/spec/scenarios/blockquote/deep-nested.adoc +0 -17
- data/spec/scenarios/blockquote/deep-nested.md +0 -6
- data/spec/scenarios/blockquote/list.adoc +0 -5
- data/spec/scenarios/blockquote/list.md +0 -3
- data/spec/scenarios/blockquote/multiple-lines.adoc +0 -5
- data/spec/scenarios/blockquote/multiple-lines.md +0 -3
- data/spec/scenarios/blockquote/nested.adoc +0 -7
- data/spec/scenarios/blockquote/nested.md +0 -3
- data/spec/scenarios/br/leading-tag.adoc +0 -2
- data/spec/scenarios/br/leading-tag.md +0 -2
- data/spec/scenarios/br/tag-followed-by-newline.adoc +0 -3
- data/spec/scenarios/br/tag-followed-by-newline.md +0 -3
- data/spec/scenarios/br/tag-in-table-cell.adoc +0 -4
- data/spec/scenarios/br/tag-in-table-cell.md +0 -1
- data/spec/scenarios/br/tag-preceded-by-space.adoc +0 -3
- data/spec/scenarios/br/tag-preceded-by-space.md +0 -1
- data/spec/scenarios/br/tag.adoc +0 -3
- data/spec/scenarios/br/tag.md +0 -1
- data/spec/scenarios/br/trailing-double-space.adoc +0 -3
- data/spec/scenarios/br/trailing-double-space.md +0 -3
- data/spec/scenarios/codeblock/command-prompt.adoc +0 -1
- data/spec/scenarios/codeblock/command-prompt.md +0 -1
- data/spec/scenarios/codeblock/contiguous-lines.adoc +0 -3
- data/spec/scenarios/codeblock/contiguous-lines.md +0 -3
- data/spec/scenarios/codeblock/dlist-like.adoc +0 -4
- data/spec/scenarios/codeblock/dlist-like.md +0 -2
- data/spec/scenarios/codeblock/fenced/command-prompt.adoc +0 -1
- data/spec/scenarios/codeblock/fenced/command-prompt.md +0 -3
- data/spec/scenarios/codeblock/fenced/language.adoc +0 -8
- data/spec/scenarios/codeblock/fenced/language.md +0 -7
- data/spec/scenarios/codeblock/fenced/non-contiguous-command-prompts.adoc +0 -6
- data/spec/scenarios/codeblock/fenced/non-contiguous-command-prompts.md +0 -5
- data/spec/scenarios/codeblock/fenced/without-language.adoc +0 -5
- data/spec/scenarios/codeblock/fenced/without-language.md +0 -5
- data/spec/scenarios/codeblock/list-like.adoc +0 -5
- data/spec/scenarios/codeblock/list-like.md +0 -3
- data/spec/scenarios/codeblock/non-contiguous-command-prompts.adoc +0 -6
- data/spec/scenarios/codeblock/non-contiguous-command-prompts.md +0 -3
- data/spec/scenarios/codeblock/non-contiguous-lines.adoc +0 -7
- data/spec/scenarios/codeblock/non-contiguous-lines.md +0 -5
- data/spec/scenarios/codespan/caret.adoc +0 -1
- data/spec/scenarios/codespan/caret.md +0 -1
- data/spec/scenarios/codespan/constrained-triple.adoc +0 -1
- data/spec/scenarios/codespan/constrained-triple.md +0 -1
- data/spec/scenarios/codespan/constrained.adoc +0 -1
- data/spec/scenarios/codespan/constrained.md +0 -1
- data/spec/scenarios/codespan/literal.adoc +0 -15
- data/spec/scenarios/codespan/literal.md +0 -15
- data/spec/scenarios/codespan/plus-plus.adoc +0 -1
- data/spec/scenarios/codespan/plus-plus.md +0 -1
- data/spec/scenarios/codespan/possessive.adoc +0 -3
- data/spec/scenarios/codespan/possessive.md +0 -3
- data/spec/scenarios/codespan/quoted.adoc +0 -1
- data/spec/scenarios/codespan/quoted.md +0 -1
- data/spec/scenarios/codespan/smart-quotes.adoc +0 -1
- data/spec/scenarios/codespan/smart-quotes.md +0 -1
- data/spec/scenarios/codespan/star-star.adoc +0 -1
- data/spec/scenarios/codespan/star-star.md +0 -1
- data/spec/scenarios/codespan/unconstrained.adoc +0 -7
- data/spec/scenarios/codespan/unconstrained.md +0 -7
- data/spec/scenarios/dl/compound-only.adoc +0 -16
- data/spec/scenarios/dl/compound-only.md +0 -13
- data/spec/scenarios/dl/compound.adoc +0 -11
- data/spec/scenarios/dl/compound.md +0 -7
- data/spec/scenarios/dl/empty-dd.adoc +0 -3
- data/spec/scenarios/dl/empty-dd.md +0 -4
- data/spec/scenarios/dl/nested-bookended.adoc +0 -8
- data/spec/scenarios/dl/nested-bookended.md +0 -6
- data/spec/scenarios/dl/nested-mixed.adoc +0 -11
- data/spec/scenarios/dl/nested-mixed.md +0 -11
- data/spec/scenarios/dl/nested.adoc +0 -15
- data/spec/scenarios/dl/nested.md +0 -23
- data/spec/scenarios/dl/simple.adoc +0 -9
- data/spec/scenarios/dl/simple.md +0 -10
- data/spec/scenarios/em/asterisks.adoc +0 -1
- data/spec/scenarios/em/asterisks.md +0 -1
- data/spec/scenarios/em/constrained.adoc +0 -1
- data/spec/scenarios/em/constrained.md +0 -1
- data/spec/scenarios/em/strong.adoc +0 -1
- data/spec/scenarios/em/strong.md +0 -1
- data/spec/scenarios/em/unconstrained.adoc +0 -4
- data/spec/scenarios/em/unconstrained.md +0 -4
- data/spec/scenarios/entity/numeric.adoc +0 -1
- data/spec/scenarios/entity/numeric.md +0 -1
- data/spec/scenarios/entity/reverse.adoc +0 -5
- data/spec/scenarios/entity/reverse.md +0 -5
- data/spec/scenarios/heading/anchor-with-dot.adoc +0 -2
- data/spec/scenarios/heading/anchor-with-dot.md +0 -1
- data/spec/scenarios/heading/auto_ids/auto-id-prefix.adoc +0 -11
- data/spec/scenarios/heading/auto_ids/auto-id-prefix.md +0 -7
- data/spec/scenarios/heading/auto_ids/auto-id-prefix.opts +0 -2
- data/spec/scenarios/heading/auto_ids/character-reference.adoc +0 -8
- data/spec/scenarios/heading/auto_ids/character-reference.md +0 -5
- data/spec/scenarios/heading/auto_ids/character-reference.opts +0 -1
- data/spec/scenarios/heading/auto_ids/disabled.adoc +0 -3
- data/spec/scenarios/heading/auto_ids/disabled.md +0 -3
- data/spec/scenarios/heading/auto_ids/disabled.opts +0 -3
- data/spec/scenarios/heading/auto_ids/dot-separator.adoc +0 -2
- data/spec/scenarios/heading/auto_ids/dot-separator.md +0 -1
- data/spec/scenarios/heading/auto_ids/dot-separator.opts +0 -2
- data/spec/scenarios/heading/auto_ids/explicit-id.adoc +0 -14
- data/spec/scenarios/heading/auto_ids/explicit-id.md +0 -9
- data/spec/scenarios/heading/auto_ids/explicit-id.opts +0 -1
- data/spec/scenarios/heading/auto_ids/kramdown-input-character-reference.adoc +0 -8
- data/spec/scenarios/heading/auto_ids/kramdown-input-character-reference.md +0 -5
- data/spec/scenarios/heading/auto_ids/kramdown-input-character-reference.opts +0 -2
- data/spec/scenarios/heading/auto_ids/kramdown-input.adoc +0 -14
- data/spec/scenarios/heading/auto_ids/kramdown-input.md +0 -9
- data/spec/scenarios/heading/auto_ids/kramdown-input.opts +0 -2
- data/spec/scenarios/heading/auto_ids/no-ids.adoc +0 -14
- data/spec/scenarios/heading/auto_ids/no-ids.md +0 -9
- data/spec/scenarios/heading/auto_ids/no-ids.opts +0 -1
- data/spec/scenarios/heading/block-title.adoc +0 -11
- data/spec/scenarios/heading/block-title.md +0 -11
- data/spec/scenarios/heading/formatting.adoc +0 -1
- data/spec/scenarios/heading/formatting.md +0 -1
- data/spec/scenarios/heading/lazy_ids/auto-ids-sync-id-attrs.adoc +0 -7
- data/spec/scenarios/heading/lazy_ids/auto-ids-sync-id-attrs.md +0 -5
- data/spec/scenarios/heading/lazy_ids/auto-ids-sync-id-attrs.opts +0 -5
- data/spec/scenarios/heading/lazy_ids/auto-ids.adoc +0 -10
- data/spec/scenarios/heading/lazy_ids/auto-ids.md +0 -7
- data/spec/scenarios/heading/lazy_ids/auto-ids.opts +0 -4
- data/spec/scenarios/heading/lazy_ids/explicit-ids-dot-separator.adoc +0 -9
- data/spec/scenarios/heading/lazy_ids/explicit-ids-dot-separator.md +0 -7
- data/spec/scenarios/heading/lazy_ids/explicit-ids-dot-separator.opts +0 -3
- data/spec/scenarios/heading/lazy_ids/explicit-ids-empty-prefix.adoc +0 -9
- data/spec/scenarios/heading/lazy_ids/explicit-ids-empty-prefix.md +0 -7
- data/spec/scenarios/heading/lazy_ids/explicit-ids-empty-prefix.opts +0 -3
- data/spec/scenarios/heading/lazy_ids/explicit-ids-empty-separator.adoc +0 -9
- data/spec/scenarios/heading/lazy_ids/explicit-ids-empty-separator.md +0 -7
- data/spec/scenarios/heading/lazy_ids/explicit-ids-empty-separator.opts +0 -3
- data/spec/scenarios/heading/lazy_ids/explicit-ids-zero-separator.adoc +0 -7
- data/spec/scenarios/heading/lazy_ids/explicit-ids-zero-separator.md +0 -5
- data/spec/scenarios/heading/lazy_ids/explicit-ids-zero-separator.opts +0 -3
- data/spec/scenarios/heading/lazy_ids/explicit-ids.adoc +0 -15
- data/spec/scenarios/heading/lazy_ids/explicit-ids.md +0 -13
- data/spec/scenarios/heading/lazy_ids/explicit-ids.opts +0 -1
- data/spec/scenarios/heading/leading-anchor.adoc +0 -2
- data/spec/scenarios/heading/leading-anchor.md +0 -1
- data/spec/scenarios/heading/not-block-title.adoc +0 -8
- data/spec/scenarios/heading/not-block-title.md +0 -7
- data/spec/scenarios/heading/offset.adoc +0 -5
- data/spec/scenarios/heading/offset.md +0 -5
- data/spec/scenarios/heading/offset.opts +0 -1
- data/spec/scenarios/heading/out-of-sequence.adoc +0 -23
- data/spec/scenarios/heading/out-of-sequence.md +0 -21
- data/spec/scenarios/heading/outline.adoc +0 -13
- data/spec/scenarios/heading/outline.md +0 -13
- data/spec/scenarios/heading/surrounding-anchor.adoc +0 -2
- data/spec/scenarios/heading/surrounding-anchor.md +0 -1
- data/spec/scenarios/hr/around-block.adoc +0 -5
- data/spec/scenarios/hr/around-block.md +0 -5
- data/spec/scenarios/hr/between-blocks.adoc +0 -5
- data/spec/scenarios/hr/between-blocks.md +0 -5
- data/spec/scenarios/hr/dashes.adoc +0 -1
- data/spec/scenarios/hr/dashes.md +0 -1
- data/spec/scenarios/html_element/abbr.adoc +0 -1
- data/spec/scenarios/html_element/abbr.md +0 -1
- data/spec/scenarios/html_element/admonition.adoc +0 -5
- data/spec/scenarios/html_element/admonition.md +0 -7
- data/spec/scenarios/html_element/div-mixed.adoc +0 -1
- data/spec/scenarios/html_element/div-mixed.md +0 -4
- data/spec/scenarios/html_element/div-text-only.adoc +0 -1
- data/spec/scenarios/html_element/div-text-only.md +0 -1
- data/spec/scenarios/html_element/empty-p.adoc +0 -5
- data/spec/scenarios/html_element/empty-p.md +0 -5
- data/spec/scenarios/html_element/heading-with-class.adoc +0 -7
- data/spec/scenarios/html_element/heading-with-class.md +0 -5
- data/spec/scenarios/html_element/heading-with-id.adoc +0 -2
- data/spec/scenarios/html_element/heading-with-id.md +0 -1
- data/spec/scenarios/html_element/image-with-id.adoc +0 -2
- data/spec/scenarios/html_element/image-with-id.md +0 -1
- data/spec/scenarios/html_element/img-with-alt-and-width.adoc +0 -1
- data/spec/scenarios/html_element/img-with-alt-and-width.md +0 -1
- data/spec/scenarios/html_element/img-with-percentage-width-css.adoc +0 -1
- data/spec/scenarios/html_element/img-with-percentage-width-css.md +0 -1
- data/spec/scenarios/html_element/img-with-percentage-width.adoc +0 -1
- data/spec/scenarios/html_element/img-with-percentage-width.md +0 -1
- data/spec/scenarios/html_element/img-with-width-css.adoc +0 -1
- data/spec/scenarios/html_element/img-with-width-css.md +0 -1
- data/spec/scenarios/html_element/img-with-width.adoc +0 -1
- data/spec/scenarios/html_element/img-with-width.md +0 -1
- data/spec/scenarios/html_element/img.adoc +0 -2
- data/spec/scenarios/html_element/img.md +0 -1
- data/spec/scenarios/html_element/mark.adoc +0 -1
- data/spec/scenarios/html_element/mark.md +0 -1
- data/spec/scenarios/html_element/native.adoc +0 -1
- data/spec/scenarios/html_element/native.md +0 -1
- data/spec/scenarios/html_element/pre-code-with-language.adoc +0 -6
- data/spec/scenarios/html_element/pre-code-with-language.md +0 -4
- data/spec/scenarios/html_element/span.adoc +0 -3
- data/spec/scenarios/html_element/span.md +0 -3
- data/spec/scenarios/html_element/strike.adoc +0 -1
- data/spec/scenarios/html_element/strike.md +0 -1
- data/spec/scenarios/html_element/sub.adoc +0 -1
- data/spec/scenarios/html_element/sub.md +0 -1
- data/spec/scenarios/html_element/sup.adoc +0 -1
- data/spec/scenarios/html_element/sup.md +0 -1
- data/spec/scenarios/html_element/unrecognized-admonition.adoc +0 -5
- data/spec/scenarios/html_element/unrecognized-admonition.md +0 -5
- data/spec/scenarios/img/block-in-list.adoc +0 -5
- data/spec/scenarios/img/block-in-list.md +0 -5
- data/spec/scenarios/img/block-with-alt.adoc +0 -1
- data/spec/scenarios/img/block-with-alt.md +0 -1
- data/spec/scenarios/img/block-with-link-and-alt.adoc +0 -1
- data/spec/scenarios/img/block-with-link-and-alt.md +0 -1
- data/spec/scenarios/img/block-with-link.adoc +0 -1
- data/spec/scenarios/img/block-with-link.md +0 -1
- data/spec/scenarios/img/block.adoc +0 -1
- data/spec/scenarios/img/block.md +0 -1
- data/spec/scenarios/img/imagesdir.adoc +0 -4
- data/spec/scenarios/img/imagesdir.md +0 -3
- data/spec/scenarios/img/imagesdir.opts +0 -2
- data/spec/scenarios/img/implicit-imagesdir.adoc +0 -3
- data/spec/scenarios/img/implicit-imagesdir.md +0 -3
- data/spec/scenarios/img/implicit-imagesdir.opts +0 -1
- data/spec/scenarios/img/inline-with-alt.adoc +0 -1
- data/spec/scenarios/img/inline-with-alt.md +0 -1
- data/spec/scenarios/img/inline-with-link-and-alt.adoc +0 -1
- data/spec/scenarios/img/inline-with-link-and-alt.md +0 -1
- data/spec/scenarios/img/inline-with-link.adoc +0 -1
- data/spec/scenarios/img/inline-with-link.md +0 -1
- data/spec/scenarios/img/inline.adoc +0 -1
- data/spec/scenarios/img/inline.md +0 -1
- data/spec/scenarios/ol/compound-separated.adoc +0 -29
- data/spec/scenarios/ol/compound-separated.md +0 -25
- data/spec/scenarios/ol/compound.adoc +0 -29
- data/spec/scenarios/ol/compound.md +0 -20
- data/spec/scenarios/ol/formatted.adoc +0 -3
- data/spec/scenarios/ol/formatted.md +0 -3
- data/spec/scenarios/ol/mixed-separated.adoc +0 -6
- data/spec/scenarios/ol/mixed-separated.md +0 -11
- data/spec/scenarios/ol/mixed.adoc +0 -6
- data/spec/scenarios/ol/mixed.md +0 -6
- data/spec/scenarios/ol/nested-mixed.adoc +0 -8
- data/spec/scenarios/ol/nested-mixed.md +0 -8
- data/spec/scenarios/ol/nested-separated.adoc +0 -7
- data/spec/scenarios/ol/nested-separated.md +0 -13
- data/spec/scenarios/ol/nested.adoc +0 -7
- data/spec/scenarios/ol/nested.md +0 -7
- data/spec/scenarios/ol/simple-separated.adoc +0 -4
- data/spec/scenarios/ol/simple-separated.md +0 -7
- data/spec/scenarios/ol/simple.adoc +0 -4
- data/spec/scenarios/ol/simple.md +0 -4
- data/spec/scenarios/p/admonition/emphasis.adoc +0 -11
- data/spec/scenarios/p/admonition/emphasis.md +0 -11
- data/spec/scenarios/p/admonition/in-blockquote.adoc +0 -1
- data/spec/scenarios/p/admonition/in-blockquote.md +0 -1
- data/spec/scenarios/p/admonition/in-compound-blockquote.adoc +0 -5
- data/spec/scenarios/p/admonition/in-compound-blockquote.md +0 -3
- data/spec/scenarios/p/admonition/in-list-item.adoc +0 -6
- data/spec/scenarios/p/admonition/in-list-item.md +0 -6
- data/spec/scenarios/p/admonition/label-only.adoc +0 -1
- data/spec/scenarios/p/admonition/label-only.md +0 -1
- data/spec/scenarios/p/admonition/plain.adoc +0 -13
- data/spec/scenarios/p/admonition/plain.md +0 -13
- data/spec/scenarios/p/admonition/strong-emphasis.adoc +0 -11
- data/spec/scenarios/p/admonition/strong-emphasis.md +0 -11
- data/spec/scenarios/p/multiple-lines.adoc +0 -2
- data/spec/scenarios/p/multiple-lines.md +0 -2
- data/spec/scenarios/p/sequential.adoc +0 -3
- data/spec/scenarios/p/sequential.md +0 -3
- data/spec/scenarios/p/single-line.adoc +0 -1
- data/spec/scenarios/p/single-line.md +0 -1
- data/spec/scenarios/root/body-only.adoc +0 -1
- data/spec/scenarios/root/body-only.md +0 -1
- data/spec/scenarios/root/book-doctype.adoc +0 -10
- data/spec/scenarios/root/book-doctype.md +0 -9
- data/spec/scenarios/root/header-and-body.adoc +0 -3
- data/spec/scenarios/root/header-and-body.md +0 -3
- data/spec/scenarios/root/header-only.adoc +0 -1
- data/spec/scenarios/root/header-only.md +0 -1
- data/spec/scenarios/smart_quote/apostrophe.adoc +0 -1
- data/spec/scenarios/smart_quote/apostrophe.md +0 -1
- data/spec/scenarios/smart_quote/double-quotes.adoc +0 -1
- data/spec/scenarios/smart_quote/double-quotes.md +0 -1
- data/spec/scenarios/smart_quote/single-quotes.adoc +0 -1
- data/spec/scenarios/smart_quote/single-quotes.md +0 -1
- data/spec/scenarios/strong/constrained.adoc +0 -1
- data/spec/scenarios/strong/constrained.md +0 -1
- data/spec/scenarios/strong/menu.adoc +0 -3
- data/spec/scenarios/strong/menu.md +0 -1
- data/spec/scenarios/strong/nested-emphasis.adoc +0 -1
- data/spec/scenarios/strong/nested-emphasis.md +0 -1
- data/spec/scenarios/strong/unconstrained.adoc +0 -8
- data/spec/scenarios/strong/unconstrained.md +0 -8
- data/spec/scenarios/table/alignment.adoc +0 -19
- data/spec/scenarios/table/alignment.md +0 -8
- data/spec/scenarios/table/cell-with-image.adoc +0 -9
- data/spec/scenarios/table/cell-with-image.md +0 -4
- data/spec/scenarios/table/cell-with-pipe.adoc +0 -5
- data/spec/scenarios/table/cell-with-pipe.md +0 -1
- data/spec/scenarios/table/header.adoc +0 -9
- data/spec/scenarios/table/header.md +0 -4
- data/spec/scenarios/table/no-header.adoc +0 -8
- data/spec/scenarios/table/no-header.md +0 -2
- data/spec/scenarios/table/single-column-with-header.adoc +0 -6
- data/spec/scenarios/table/single-column-with-header.md +0 -4
- data/spec/scenarios/table/single-column-without-header.adoc +0 -4
- data/spec/scenarios/table/single-column-without-header.md +0 -2
- data/spec/scenarios/text/attribute-reference.adoc +0 -1
- data/spec/scenarios/text/attribute-reference.md +0 -1
- data/spec/scenarios/text/caret.adoc +0 -1
- data/spec/scenarios/text/caret.md +0 -1
- data/spec/scenarios/text/lte.adoc +0 -1
- data/spec/scenarios/text/lte.md +0 -1
- data/spec/scenarios/text/nbsp.adoc +0 -1
- data/spec/scenarios/text/nbsp.md +0 -1
- data/spec/scenarios/text/plus-plus.adoc +0 -6
- data/spec/scenarios/text/plus-plus.md +0 -5
- data/spec/scenarios/text/right-arrow.adoc +0 -1
- data/spec/scenarios/text/right-arrow.md +0 -1
- data/spec/scenarios/text/typographic_sym/apostrophe.adoc +0 -3
- data/spec/scenarios/text/typographic_sym/apostrophe.md +0 -3
- data/spec/scenarios/text/typographic_sym/double-quotes.adoc +0 -1
- data/spec/scenarios/text/typographic_sym/double-quotes.md +0 -1
- data/spec/scenarios/text/typographic_sym/ellipsis.adoc +0 -1
- data/spec/scenarios/text/typographic_sym/ellipsis.md +0 -1
- data/spec/scenarios/text/typographic_sym/mdash.adoc +0 -1
- data/spec/scenarios/text/typographic_sym/mdash.md +0 -1
- data/spec/scenarios/text/typographic_sym/ndash.adoc +0 -1
- data/spec/scenarios/text/typographic_sym/ndash.md +0 -1
- data/spec/scenarios/text/typographic_sym/single-quotes.adoc +0 -1
- data/spec/scenarios/text/typographic_sym/single-quotes.md +0 -1
- data/spec/scenarios/trailing_space.adoc +0 -7
- data/spec/scenarios/trailing_space.md +0 -7
- data/spec/scenarios/typographic_sym/ellipsis.adoc +0 -1
- data/spec/scenarios/typographic_sym/ellipsis.md +0 -1
- data/spec/scenarios/typographic_sym/mdash.adoc +0 -1
- data/spec/scenarios/typographic_sym/mdash.md +0 -1
- data/spec/scenarios/typographic_sym/ndash.adoc +0 -1
- data/spec/scenarios/typographic_sym/ndash.md +0 -1
- data/spec/scenarios/ul/blockquote.adoc +0 -5
- data/spec/scenarios/ul/blockquote.md +0 -2
- data/spec/scenarios/ul/compound-nested.adoc +0 -23
- data/spec/scenarios/ul/compound-nested.md +0 -19
- data/spec/scenarios/ul/compound-only.adoc +0 -5
- data/spec/scenarios/ul/compound-only.md +0 -3
- data/spec/scenarios/ul/compound-separated.adoc +0 -41
- data/spec/scenarios/ul/compound-separated.md +0 -32
- data/spec/scenarios/ul/compound.adoc +0 -41
- data/spec/scenarios/ul/compound.md +0 -26
- data/spec/scenarios/ul/formatted.adoc +0 -3
- data/spec/scenarios/ul/formatted.md +0 -3
- data/spec/scenarios/ul/inside-delimited-block.adoc +0 -9
- data/spec/scenarios/ul/inside-delimited-block.md +0 -7
- data/spec/scenarios/ul/nested-bookended.adoc +0 -7
- data/spec/scenarios/ul/nested-bookended.md +0 -7
- data/spec/scenarios/ul/nested-separated.adoc +0 -11
- data/spec/scenarios/ul/nested-separated.md +0 -21
- data/spec/scenarios/ul/nested.adoc +0 -11
- data/spec/scenarios/ul/nested.md +0 -11
- data/spec/scenarios/ul/simple-separated.adoc +0 -3
- data/spec/scenarios/ul/simple-separated.md +0 -5
- data/spec/scenarios/ul/simple.adoc +0 -3
- data/spec/scenarios/ul/simple.md +0 -3
- data/spec/scenarios/wrap/containing-line-comment.adoc +0 -3
- data/spec/scenarios/wrap/containing-line-comment.md +0 -3
- data/spec/scenarios/wrap/containing-line-comment.opts +0 -1
- data/spec/scenarios/wrap/none.adoc +0 -1
- data/spec/scenarios/wrap/none.md +0 -4
- data/spec/scenarios/wrap/none.opts +0 -1
- data/spec/scenarios/wrap/preserve.adoc +0 -5
- data/spec/scenarios/wrap/preserve.md +0 -5
- data/spec/scenarios/wrap/preserve.opts +0 -1
- data/spec/scenarios/wrap/ventilate-exclamation.adoc +0 -3
- data/spec/scenarios/wrap/ventilate-exclamation.md +0 -1
- data/spec/scenarios/wrap/ventilate-exclamation.opts +0 -1
- data/spec/scenarios/wrap/ventilate-french.adoc +0 -3
- data/spec/scenarios/wrap/ventilate-french.md +0 -1
- data/spec/scenarios/wrap/ventilate-french.opts +0 -1
- data/spec/scenarios/wrap/ventilate-question.adoc +0 -3
- data/spec/scenarios/wrap/ventilate-question.md +0 -3
- data/spec/scenarios/wrap/ventilate-question.opts +0 -1
- data/spec/scenarios/wrap/ventilate-table-cell.adoc +0 -9
- data/spec/scenarios/wrap/ventilate-table-cell.md +0 -3
- data/spec/scenarios/wrap/ventilate-table-cell.opts +0 -1
- data/spec/scenarios/wrap/ventilate-with-comments.adoc +0 -5
- data/spec/scenarios/wrap/ventilate-with-comments.md +0 -5
- data/spec/scenarios/wrap/ventilate-with-comments.opts +0 -1
- data/spec/scenarios/wrap/ventilate.adoc +0 -2
- data/spec/scenarios/wrap/ventilate.md +0 -6
- data/spec/scenarios/wrap/ventilate.opts +0 -1
- data/spec/scenarios/xml_comment/above-block.adoc +0 -7
- data/spec/scenarios/xml_comment/above-block.md +0 -5
- data/spec/scenarios/xml_comment/above-header.adoc +0 -13
- data/spec/scenarios/xml_comment/above-header.md +0 -16
- data/spec/scenarios/xml_comment/at-start-of-line.adoc +0 -9
- data/spec/scenarios/xml_comment/at-start-of-line.md +0 -4
- data/spec/scenarios/xml_comment/block.adoc +0 -7
- data/spec/scenarios/xml_comment/block.md +0 -6
- data/spec/scenarios/xml_comment/line-adjacent-to-text.adoc +0 -2
- data/spec/scenarios/xml_comment/line-adjacent-to-text.md +0 -1
- data/spec/scenarios/xml_comment/line-empty.adoc +0 -7
- data/spec/scenarios/xml_comment/line-empty.md +0 -9
- data/spec/scenarios/xml_comment/line-offset-by-space.adoc +0 -1
- data/spec/scenarios/xml_comment/line-offset-by-space.md +0 -1
- data/spec/scenarios/xml_comment/line.adoc +0 -1
- data/spec/scenarios/xml_comment/line.md +0 -1
- data/spec/scenarios/xml_comment/list-separator.adoc +0 -7
- data/spec/scenarios/xml_comment/list-separator.md +0 -7
- data/spec/scenarios/xml_comment/mixed.adoc +0 -7
- data/spec/scenarios/xml_comment/mixed.md +0 -6
- data/spec/scenarios/xml_comment/multiline-span.adoc +0 -8
- data/spec/scenarios/xml_comment/multiline-span.md +0 -7
- data/spec/scenarios/xml_comment/p-separator.adoc +0 -5
- data/spec/scenarios/xml_comment/p-separator.md +0 -5
- data/spec/scenarios/xml_comment/styled.adoc +0 -6
- data/spec/scenarios/xml_comment/styled.md +0 -6
- data/spec/scenarios/xml_comment/surrounded-by-spaces.adoc +0 -3
- data/spec/scenarios/xml_comment/surrounded-by-spaces.md +0 -1
- data/spec/spec_helper.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbe551c7f58e65076b32bccc18a15c31d4ad2f7a6e7510ff37095e1782d0bd90
|
4
|
+
data.tar.gz: 1bbf3ccce901f2b9dd470a09a9f54fe257461922cbb1ef959cbc9071a3d72bca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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.
|
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
|
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
|
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
|
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
|
38
|
-
image:{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}
|
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.
|
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
|
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
|
223
|
+
For more information about the API, refer to the {uri-api-docs}[API documentation].
|
224
224
|
|
225
225
|
== Development
|
226
226
|
|
data/kramdown-asciidoc.gemspec
CHANGED
@@ -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
|
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'
|
data/lib/kramdown-asciidoc.rb
CHANGED
@@ -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/
|
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
|
-
|
3
|
-
|
4
|
-
|
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
|
-
|
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 =
|
47
|
+
parser_opts = DEFAULT_PARSER_OPTS.merge opts
|
13
48
|
attributes = (parser_opts[:attributes] = (parser_opts[:attributes] || {}).dup)
|
14
|
-
|
15
|
-
|
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
|
-
|
18
|
-
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
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
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:
|
104
|
+
convert markdown, (opts.merge to: to, encode: encode)
|
45
105
|
end
|
46
|
-
end; end
|
47
106
|
|
48
|
-
|
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
|
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
|
-
|
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
|
621
|
-
|
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? '//') || !(
|
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
|
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
|
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
|