kramdown-asciidoc 1.0.0.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.adoc +10 -0
- data/Gemfile +3 -0
- data/LICENSE.adoc +22 -0
- data/README.adoc +147 -0
- data/Rakefile +3 -0
- data/bin/kramdoc +24 -0
- data/kramdown-asciidoc.gemspec +41 -0
- data/lib/kramdown-asciidoc.rb +2 -0
- data/lib/kramdown-asciidoc/converter.rb +413 -0
- data/lib/kramdown-asciidoc/version.rb +3 -0
- data/spec/converter_spec.rb +114 -0
- data/spec/fixtures/a/bare-url.adoc +1 -0
- data/spec/fixtures/a/bare-url.md +1 -0
- data/spec/fixtures/a/interdoc-xref.adoc +1 -0
- data/spec/fixtures/a/interdoc-xref.md +1 -0
- data/spec/fixtures/a/internal.adoc +5 -0
- data/spec/fixtures/a/internal.md +5 -0
- data/spec/fixtures/a/local.adoc +1 -0
- data/spec/fixtures/a/local.md +1 -0
- data/spec/fixtures/a/url-matches-text.adoc +1 -0
- data/spec/fixtures/a/url-matches-text.md +1 -0
- data/spec/fixtures/a/url-with-text.adoc +1 -0
- data/spec/fixtures/a/url-with-text.md +1 -0
- data/spec/fixtures/blockquote/basic.adoc +3 -0
- data/spec/fixtures/blockquote/basic.md +1 -0
- data/spec/fixtures/blockquote/list.adoc +5 -0
- data/spec/fixtures/blockquote/list.md +3 -0
- data/spec/fixtures/blockquote/multiple-lines.adoc +5 -0
- data/spec/fixtures/blockquote/multiple-lines.md +3 -0
- data/spec/fixtures/blockquote/nested.adoc +7 -0
- data/spec/fixtures/blockquote/nested.md +3 -0
- data/spec/fixtures/blockquote/with-attribution.adoc +5 -0
- data/spec/fixtures/blockquote/with-attribution.md +3 -0
- data/spec/fixtures/br/tag-followed-by-newline.adoc +3 -0
- data/spec/fixtures/br/tag-followed-by-newline.md +3 -0
- data/spec/fixtures/br/tag-preceded-by-space.adoc +3 -0
- data/spec/fixtures/br/tag-preceded-by-space.md +1 -0
- data/spec/fixtures/br/tag.adoc +3 -0
- data/spec/fixtures/br/tag.md +1 -0
- data/spec/fixtures/br/trailing-double-space.adoc +3 -0
- data/spec/fixtures/br/trailing-double-space.md +3 -0
- data/spec/fixtures/codeblock/contiguous-lines.adoc +5 -0
- data/spec/fixtures/codeblock/contiguous-lines.md +3 -0
- data/spec/fixtures/codeblock/fenced/bash-to-console.adoc +4 -0
- data/spec/fixtures/codeblock/fenced/bash-to-console.md +3 -0
- data/spec/fixtures/codeblock/fenced/with-command-prompt.adoc +1 -0
- data/spec/fixtures/codeblock/fenced/with-command-prompt.md +3 -0
- data/spec/fixtures/codeblock/fenced/with-language.adoc +8 -0
- data/spec/fixtures/codeblock/fenced/with-language.md +7 -0
- data/spec/fixtures/codeblock/fenced/with-non-contiguous-command-prompts.adoc +5 -0
- data/spec/fixtures/codeblock/fenced/with-non-contiguous-command-prompts.md +5 -0
- data/spec/fixtures/codeblock/fenced/without-language.adoc +5 -0
- data/spec/fixtures/codeblock/fenced/without-language.md +5 -0
- data/spec/fixtures/codeblock/non-contiguous-lines.adoc +7 -0
- data/spec/fixtures/codeblock/non-contiguous-lines.md +5 -0
- data/spec/fixtures/codeblock/with-command-prompt.adoc +1 -0
- data/spec/fixtures/codeblock/with-command-prompt.md +1 -0
- data/spec/fixtures/codeblock/with-non-contiguous-command-prompts.adoc +5 -0
- data/spec/fixtures/codeblock/with-non-contiguous-command-prompts.md +3 -0
- data/spec/fixtures/codespan/constrained.adoc +1 -0
- data/spec/fixtures/codespan/constrained.md +1 -0
- data/spec/fixtures/codespan/literal.adoc +3 -0
- data/spec/fixtures/codespan/literal.md +3 -0
- data/spec/fixtures/em/asterisks.adoc +1 -0
- data/spec/fixtures/em/asterisks.md +1 -0
- data/spec/fixtures/em/constrained.adoc +1 -0
- data/spec/fixtures/em/constrained.md +1 -0
- data/spec/fixtures/entity/numeric.adoc +1 -0
- data/spec/fixtures/entity/numeric.md +1 -0
- data/spec/fixtures/entity/reverse.adoc +1 -0
- data/spec/fixtures/entity/reverse.md +1 -0
- data/spec/fixtures/heading/out-of-sequence.adoc +23 -0
- data/spec/fixtures/heading/out-of-sequence.md +21 -0
- data/spec/fixtures/heading/outline.adoc +13 -0
- data/spec/fixtures/heading/outline.md +13 -0
- data/spec/fixtures/heading/with-anchor.adoc +2 -0
- data/spec/fixtures/heading/with-anchor.md +1 -0
- data/spec/fixtures/heading/with-formatting.adoc +1 -0
- data/spec/fixtures/heading/with-formatting.md +1 -0
- data/spec/fixtures/hr/between-blocks.adoc +5 -0
- data/spec/fixtures/hr/between-blocks.md +5 -0
- data/spec/fixtures/hr/dashes.adoc +1 -0
- data/spec/fixtures/hr/dashes.md +1 -0
- data/spec/fixtures/html_element/abbr.adoc +1 -0
- data/spec/fixtures/html_element/abbr.md +1 -0
- data/spec/fixtures/html_element/heading-with-class.adoc +7 -0
- data/spec/fixtures/html_element/heading-with-class.md +5 -0
- data/spec/fixtures/html_element/heading-with-id.adoc +2 -0
- data/spec/fixtures/html_element/heading-with-id.md +1 -0
- data/spec/fixtures/html_element/native.adoc +1 -0
- data/spec/fixtures/html_element/native.md +1 -0
- data/spec/fixtures/html_element/sub.adoc +1 -0
- data/spec/fixtures/html_element/sub.md +1 -0
- data/spec/fixtures/html_element/sup.adoc +1 -0
- data/spec/fixtures/html_element/sup.md +1 -0
- data/spec/fixtures/img/block-with-alt.adoc +1 -0
- data/spec/fixtures/img/block-with-alt.md +1 -0
- data/spec/fixtures/img/block-with-link-and-alt.adoc +1 -0
- data/spec/fixtures/img/block-with-link-and-alt.md +1 -0
- data/spec/fixtures/img/block-with-link.adoc +1 -0
- data/spec/fixtures/img/block-with-link.md +1 -0
- data/spec/fixtures/img/block.adoc +1 -0
- data/spec/fixtures/img/block.md +1 -0
- data/spec/fixtures/img/imagesdir.adoc +4 -0
- data/spec/fixtures/img/imagesdir.md +3 -0
- data/spec/fixtures/img/imagesdir.opts +2 -0
- data/spec/fixtures/img/implicit-imagesdir.adoc +3 -0
- data/spec/fixtures/img/implicit-imagesdir.md +3 -0
- data/spec/fixtures/img/implicit-imagesdir.opts +2 -0
- data/spec/fixtures/img/inline-with-alt.adoc +1 -0
- data/spec/fixtures/img/inline-with-alt.md +1 -0
- data/spec/fixtures/img/inline-with-link-and-alt.adoc +1 -0
- data/spec/fixtures/img/inline-with-link-and-alt.md +1 -0
- data/spec/fixtures/img/inline-with-link.adoc +1 -0
- data/spec/fixtures/img/inline-with-link.md +1 -0
- data/spec/fixtures/img/inline.adoc +1 -0
- data/spec/fixtures/img/inline.md +1 -0
- data/spec/fixtures/ol/compound-separated.adoc +25 -0
- data/spec/fixtures/ol/compound-separated.md +23 -0
- data/spec/fixtures/ol/compound.adoc +25 -0
- data/spec/fixtures/ol/compound.md +18 -0
- data/spec/fixtures/ol/mixed-separated.adoc +6 -0
- data/spec/fixtures/ol/mixed-separated.md +11 -0
- data/spec/fixtures/ol/mixed.adoc +6 -0
- data/spec/fixtures/ol/mixed.md +6 -0
- data/spec/fixtures/ol/nested-separated.adoc +7 -0
- data/spec/fixtures/ol/nested-separated.md +13 -0
- data/spec/fixtures/ol/nested.adoc +7 -0
- data/spec/fixtures/ol/nested.md +7 -0
- data/spec/fixtures/ol/simple-separated.adoc +4 -0
- data/spec/fixtures/ol/simple-separated.md +7 -0
- data/spec/fixtures/ol/simple.adoc +4 -0
- data/spec/fixtures/ol/simple.md +4 -0
- data/spec/fixtures/p/admonition/emphasis.adoc +11 -0
- data/spec/fixtures/p/admonition/emphasis.md +11 -0
- data/spec/fixtures/p/admonition/in-list-item.adoc +6 -0
- data/spec/fixtures/p/admonition/in-list-item.md +6 -0
- data/spec/fixtures/p/admonition/plain.adoc +11 -0
- data/spec/fixtures/p/admonition/plain.md +11 -0
- data/spec/fixtures/p/admonition/strong-emphasis.adoc +11 -0
- data/spec/fixtures/p/admonition/strong-emphasis.md +11 -0
- data/spec/fixtures/p/multiple-lines.adoc +2 -0
- data/spec/fixtures/p/multiple-lines.md +2 -0
- data/spec/fixtures/p/multiple.adoc +3 -0
- data/spec/fixtures/p/multiple.md +3 -0
- data/spec/fixtures/p/single-line.adoc +1 -0
- data/spec/fixtures/p/single-line.md +1 -0
- data/spec/fixtures/root/body-only.adoc +1 -0
- data/spec/fixtures/root/body-only.md +1 -0
- data/spec/fixtures/root/book-doctype.adoc +10 -0
- data/spec/fixtures/root/book-doctype.md +9 -0
- data/spec/fixtures/root/header-and-body.adoc +3 -0
- data/spec/fixtures/root/header-and-body.md +3 -0
- data/spec/fixtures/root/header-only.adoc +1 -0
- data/spec/fixtures/root/header-only.md +1 -0
- data/spec/fixtures/smart_quote/apostrophe.adoc +1 -0
- data/spec/fixtures/smart_quote/apostrophe.md +1 -0
- data/spec/fixtures/smart_quote/double-quotes.adoc +1 -0
- data/spec/fixtures/smart_quote/double-quotes.md +1 -0
- data/spec/fixtures/smart_quote/single-quotes.adoc +1 -0
- data/spec/fixtures/smart_quote/single-quotes.md +1 -0
- data/spec/fixtures/strong/constrained.adoc +1 -0
- data/spec/fixtures/strong/constrained.md +1 -0
- data/spec/fixtures/strong/nested-emphasis.adoc +1 -0
- data/spec/fixtures/strong/nested-emphasis.md +1 -0
- data/spec/fixtures/table/with-header.adoc +9 -0
- data/spec/fixtures/table/with-header.md +4 -0
- data/spec/fixtures/table/without-header.adoc +8 -0
- data/spec/fixtures/table/without-header.md +2 -0
- data/spec/fixtures/text/lte.adoc +1 -0
- data/spec/fixtures/text/lte.md +1 -0
- data/spec/fixtures/text/plus-plus.adoc +6 -0
- data/spec/fixtures/text/plus-plus.md +5 -0
- data/spec/fixtures/text/typographic_sym/apostrophe.adoc +1 -0
- data/spec/fixtures/text/typographic_sym/apostrophe.md +1 -0
- data/spec/fixtures/text/typographic_sym/double-quotes.adoc +1 -0
- data/spec/fixtures/text/typographic_sym/double-quotes.md +1 -0
- data/spec/fixtures/text/typographic_sym/ellipsis.adoc +1 -0
- data/spec/fixtures/text/typographic_sym/ellipsis.md +1 -0
- data/spec/fixtures/text/typographic_sym/mdash.adoc +1 -0
- data/spec/fixtures/text/typographic_sym/mdash.md +1 -0
- data/spec/fixtures/text/typographic_sym/ndash.adoc +1 -0
- data/spec/fixtures/text/typographic_sym/ndash.md +1 -0
- data/spec/fixtures/text/typographic_sym/single-quotes.adoc +1 -0
- data/spec/fixtures/text/typographic_sym/single-quotes.md +1 -0
- data/spec/fixtures/typographic_sym/ellipsis.adoc +1 -0
- data/spec/fixtures/typographic_sym/ellipsis.md +1 -0
- data/spec/fixtures/typographic_sym/mdash.adoc +1 -0
- data/spec/fixtures/typographic_sym/mdash.md +1 -0
- data/spec/fixtures/typographic_sym/ndash.adoc +1 -0
- data/spec/fixtures/typographic_sym/ndash.md +1 -0
- data/spec/fixtures/ul/compound-separated.adoc +25 -0
- data/spec/fixtures/ul/compound-separated.md +23 -0
- data/spec/fixtures/ul/compound.adoc +25 -0
- data/spec/fixtures/ul/compound.md +18 -0
- data/spec/fixtures/ul/nested-separated.adoc +11 -0
- data/spec/fixtures/ul/nested-separated.md +21 -0
- data/spec/fixtures/ul/nested.adoc +11 -0
- data/spec/fixtures/ul/nested.md +11 -0
- data/spec/fixtures/ul/simple-separated.adoc +3 -0
- data/spec/fixtures/ul/simple-separated.md +5 -0
- data/spec/fixtures/ul/simple.adoc +3 -0
- data/spec/fixtures/ul/simple.md +3 -0
- data/spec/fixtures/xml_comment/block.adoc +7 -0
- data/spec/fixtures/xml_comment/block.md +6 -0
- data/spec/fixtures/xml_comment/line-offset-by-space.adoc +1 -0
- data/spec/fixtures/xml_comment/line-offset-by-space.md +1 -0
- data/spec/fixtures/xml_comment/line.adoc +1 -0
- data/spec/fixtures/xml_comment/line.md +1 -0
- data/spec/fixtures/xml_comment/list-separator.adoc +7 -0
- data/spec/fixtures/xml_comment/list-separator.md +7 -0
- data/spec/fixtures/xml_comment/mixed.adoc +7 -0
- data/spec/fixtures/xml_comment/mixed.md +6 -0
- data/spec/fixtures/xml_comment/multiline-span.adoc +4 -0
- data/spec/fixtures/xml_comment/multiline-span.md +3 -0
- data/spec/fixtures/xml_comment/styled.adoc +6 -0
- data/spec/fixtures/xml_comment/styled.md +6 -0
- data/spec/integration_spec.rb +27 -0
- data/spec/spec_helper.rb +9 -0
- metadata +533 -0
@@ -0,0 +1,114 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Kramdown::AsciiDoc::Converter do
|
4
|
+
let(:opts) { Kramdown::AsciiDoc::DEFAULT_PARSER_OPTS }
|
5
|
+
let(:doc) { Kramdown::Document.new input, opts }
|
6
|
+
let(:root) { doc.root }
|
7
|
+
|
8
|
+
context '#convert' do
|
9
|
+
let (:input) { %(# Document Title\n\nBody text.) }
|
10
|
+
it 'adds line feed (EOL) to end of output document' do
|
11
|
+
converter = described_class.send :new, root, {}
|
12
|
+
(expect converter.convert root).to end_with %(\n)
|
13
|
+
(expect doc.to_asciidoc).to end_with %(\n)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context '.replace_toc' do
|
18
|
+
it 'does not modify source if TOC directive not detected' do
|
19
|
+
input = <<~EOS
|
20
|
+
# Database Guide
|
21
|
+
|
22
|
+
...
|
23
|
+
EOS
|
24
|
+
|
25
|
+
attributes = {}
|
26
|
+
(expect Kramdown::AsciiDoc.replace_toc input, attributes).to be input
|
27
|
+
(expect attributes).to be_empty
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'replaces TOC directive with a toc block macro' do
|
31
|
+
input = <<~EOS
|
32
|
+
# Database Guide
|
33
|
+
|
34
|
+
This tutorial walks you through the steps to set up a database instance.
|
35
|
+
|
36
|
+
<!-- TOC depthFrom:2 depthTo:6 withLinks:1 updateOnSave:1 -->
|
37
|
+
|
38
|
+
- [Prerequisites](#prerequisites)
|
39
|
+
- [Create an Instance](#1-create-instance)
|
40
|
+
- [Create a User](#2-create-user)
|
41
|
+
- [Create a user using the CLI](#create-user-using-cli)
|
42
|
+
- [Create a user using the UI](#create-user-using-ui)
|
43
|
+
- [Insert Data](#3-insert-data)
|
44
|
+
- [Start Instance](#4-start-instance)
|
45
|
+
|
46
|
+
<!-- /TOC -->
|
47
|
+
|
48
|
+
...
|
49
|
+
EOS
|
50
|
+
|
51
|
+
expected = <<~EOS
|
52
|
+
# Database Guide
|
53
|
+
|
54
|
+
This tutorial walks you through the steps to set up a database instance.
|
55
|
+
|
56
|
+
toc::[]
|
57
|
+
|
58
|
+
...
|
59
|
+
EOS
|
60
|
+
|
61
|
+
attributes = {}
|
62
|
+
(expect Kramdown::AsciiDoc.replace_toc input, attributes).to eql expected
|
63
|
+
(expect attributes['toc']).to eql 'macro'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context '.extract_front_matter' do
|
68
|
+
it 'does not modify source if front matter not detected' do
|
69
|
+
input = <<~EOS
|
70
|
+
# Introduction
|
71
|
+
|
72
|
+
content
|
73
|
+
|
74
|
+
---
|
75
|
+
|
76
|
+
more content
|
77
|
+
EOS
|
78
|
+
|
79
|
+
attributes = {}
|
80
|
+
(expect Kramdown::AsciiDoc.extract_front_matter input, attributes).to be input
|
81
|
+
(expect attributes).to be_empty
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'extracts front matter and assigns entries to attributes' do
|
85
|
+
input = <<~EOS
|
86
|
+
---
|
87
|
+
title: Introduction
|
88
|
+
description: An introduction to this amazing technology.
|
89
|
+
keywords: buzz, transformative
|
90
|
+
layout: default
|
91
|
+
---
|
92
|
+
|
93
|
+
# Introduction
|
94
|
+
|
95
|
+
When using this technology, anything is possible.
|
96
|
+
EOS
|
97
|
+
|
98
|
+
expected = <<~EOS
|
99
|
+
# Introduction
|
100
|
+
|
101
|
+
When using this technology, anything is possible.
|
102
|
+
EOS
|
103
|
+
|
104
|
+
expected_attributes = {
|
105
|
+
'description' => 'An introduction to this amazing technology.',
|
106
|
+
'keywords' => 'buzz, transformative',
|
107
|
+
}
|
108
|
+
|
109
|
+
attributes = {}
|
110
|
+
(expect Kramdown::AsciiDoc.extract_front_matter input, attributes).to eql expected
|
111
|
+
(expect attributes).to eql expected_attributes
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Use https://ecosia.org to plant trees while you search the web.
|
@@ -0,0 +1 @@
|
|
1
|
+
Use https://ecosia.org to plant trees while you search the web.
|
@@ -0,0 +1 @@
|
|
1
|
+
See xref:prerequisites.adoc[prerequisites] for details.
|
@@ -0,0 +1 @@
|
|
1
|
+
See [prerequisites](prerequisites.md) for details.
|
@@ -0,0 +1 @@
|
|
1
|
+
Take a look at the link:release-notes.html[release notes] to find a list of what changed.
|
@@ -0,0 +1 @@
|
|
1
|
+
Take a look at the [release notes](release-notes.html) to find a list of what changed.
|
@@ -0,0 +1 @@
|
|
1
|
+
Visit https://info.ecosia.org/what/ to learn about Ecosia's mission.
|
@@ -0,0 +1 @@
|
|
1
|
+
Visit [https://info.ecosia.org/what](https://info.ecosia.org/what/) to learn about Ecosia's mission.
|
@@ -0,0 +1 @@
|
|
1
|
+
Use https://ecosia.org[Ecosia] to plant trees while you search the web.
|
@@ -0,0 +1 @@
|
|
1
|
+
Use [Ecosia](https://ecosia.org) to plant trees while you search the web.
|
@@ -0,0 +1 @@
|
|
1
|
+
> Something someone said.
|
@@ -0,0 +1 @@
|
|
1
|
+
break <br/>your <br/>*lines*
|
@@ -0,0 +1 @@
|
|
1
|
+
break<br>your<br>*lines*
|
@@ -0,0 +1 @@
|
|
1
|
+
$ docker -it --run node:8-alpine
|
@@ -0,0 +1 @@
|
|
1
|
+
$ docker -it --run node:8-alpine
|
@@ -0,0 +1 @@
|
|
1
|
+
$ docker -it --run node:8-alpine
|
@@ -0,0 +1 @@
|
|
1
|
+
A boolean value can be `true` or `false`.
|
@@ -0,0 +1 @@
|
|
1
|
+
A boolean value can be `true` or `false`.
|
@@ -0,0 +1 @@
|
|
1
|
+
This is known as a _*composite type*_.
|
@@ -0,0 +1 @@
|
|
1
|
+
This is known as a _*composite type*_.
|
@@ -0,0 +1 @@
|
|
1
|
+
This is so _easy_.
|
@@ -0,0 +1 @@
|
|
1
|
+
This is so *easy*.
|
@@ -0,0 +1 @@
|
|
1
|
+
1 + 1 = 2
|
@@ -0,0 +1 @@
|
|
1
|
+
1 + 1 = 2
|
@@ -0,0 +1 @@
|
|
1
|
+
<undefined>
|
@@ -0,0 +1 @@
|
|
1
|
+
<undefined>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
= User Guide
|
2
|
+
|
3
|
+
[discrete]
|
4
|
+
=== DISCLAIMER
|
5
|
+
|
6
|
+
This is not a section.
|
7
|
+
|
8
|
+
[discrete]
|
9
|
+
=== Before we get started
|
10
|
+
|
11
|
+
Also not a section.
|
12
|
+
|
13
|
+
== Let's get going
|
14
|
+
|
15
|
+
Now we're talking.
|
16
|
+
|
17
|
+
=== Installation
|
18
|
+
|
19
|
+
Do this stuff.
|
20
|
+
|
21
|
+
== Next steps
|
22
|
+
|
23
|
+
Now we're getting to the good stuff.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# User Guide
|
2
|
+
|
3
|
+
### DISCLAIMER
|
4
|
+
|
5
|
+
This is not a section.
|
6
|
+
|
7
|
+
### Before we get started
|
8
|
+
|
9
|
+
Also not a section.
|
10
|
+
|
11
|
+
## Let's get going
|
12
|
+
|
13
|
+
Now we're talking.
|
14
|
+
|
15
|
+
### Installation
|
16
|
+
|
17
|
+
Do this stuff.
|
18
|
+
|
19
|
+
## Next steps
|
20
|
+
|
21
|
+
Now we're getting to the good stuff.
|