reverse_adoc 0.2.5 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +19 -5
- data/.github/workflows/ubuntu.yml +18 -5
- data/.github/workflows/windows.yml +20 -6
- data/Gemfile +2 -2
- data/Gemfile.lock +85 -0
- data/README.adoc +12 -25
- data/Rakefile +1 -1
- data/bin/reverse_adoc +20 -17
- data/bin/w2a +18 -31
- data/lib/reverse_adoc.rb +27 -0
- data/lib/{reverse_asciidoctor → reverse_adoc}/cleaner.rb +27 -4
- data/lib/{reverse_asciidoctor → reverse_adoc}/config.rb +3 -2
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters.rb +6 -6
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/a.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/aside.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/audio.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/base.rb +2 -2
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/blockquote.rb +2 -2
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/br.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/bypass.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/code.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/div.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/drop.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/em.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/figure.rb +1 -1
- data/lib/reverse_adoc/converters/h.rb +34 -0
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/head.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/hr.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/ignore.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/img.rb +27 -29
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/li.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/mark.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/math.rb +3 -3
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/ol.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/p.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/pass_through.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/pre.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/q.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/strong.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/sub.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/sup.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/table.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/td.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/text.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/th.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/tr.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/video.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/errors.rb +1 -1
- data/lib/reverse_adoc/html_converter.rb +56 -0
- data/lib/reverse_adoc/version.rb +3 -0
- data/reverse_adoc.gemspec +4 -2
- data/spec/assets/anchors.html +2 -0
- data/spec/assets/external_images.docx +0 -0
- data/spec/assets/external_images.html +35 -0
- data/spec/bin/reverse_adoc_spec.rb +32 -0
- data/spec/bin/w2a_spec.rb +35 -0
- data/spec/components/anchors_spec.rb +3 -2
- data/spec/components/basic_spec.rb +2 -2
- data/spec/components/code_spec.rb +4 -4
- data/spec/components/escapables_spec.rb +2 -2
- data/spec/components/from_the_wild_spec.rb +2 -2
- data/spec/components/html_fragment_spec.rb +2 -2
- data/spec/components/lists_spec.rb +2 -2
- data/spec/components/paragraphs_spec.rb +2 -2
- data/spec/components/quotation_spec.rb +2 -2
- data/spec/components/tables_spec.rb +2 -2
- data/spec/components/unknown_tags_spec.rb +9 -9
- data/spec/lib/reverse_adoc.rb +90 -0
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/cleaner_spec.rb +28 -4
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/config_spec.rb +5 -5
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/aside_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/audio_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/blockquote_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/br_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/code_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/div_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/figure_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/img_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/li_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/mark_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/p_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/pre_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/q_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/strong_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/text_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/video_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters_spec.rb +5 -5
- data/spec/spec_helper.rb +7 -2
- data/spec/support/shell_helpers.rb +15 -0
- metadata +126 -87
- data/lib/reverse_asciidoctor.rb +0 -70
- data/lib/reverse_asciidoctor/converters/h.rb +0 -19
- data/lib/reverse_asciidoctor/version.rb +0 -3
- data/spec/lib/reverse_asciidoctor_spec.rb +0 -37
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ReverseAdoc do
|
4
|
+
let(:input) { File.read('spec/assets/minimum.html') }
|
5
|
+
let(:document) { Nokogiri::HTML(input) }
|
6
|
+
|
7
|
+
it 'parses nokogiri documents' do
|
8
|
+
expect { ReverseAdoc.convert(document) }.not_to raise_error
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'parses nokogiri elements' do
|
12
|
+
expect { ReverseAdoc.convert(document.root) }.not_to raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'parses string input' do
|
16
|
+
expect { ReverseAdoc.convert(input) }.not_to raise_error
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'behaves in a sane way when root element is nil' do
|
20
|
+
expect(ReverseAdoc.convert(nil)).to eq ''
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#config' do
|
24
|
+
it 'stores a given configuration option' do
|
25
|
+
ReverseAdoc.config.tag_border = true
|
26
|
+
expect(ReverseAdoc.config.tag_border).to eq true
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'can be used as a block configurator as well' do
|
30
|
+
ReverseAdoc.config do |config|
|
31
|
+
expect(config.tag_border).to eq ' '
|
32
|
+
config.tag_border = true
|
33
|
+
end
|
34
|
+
expect(ReverseAdoc.config.tag_border).to eq true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
shared_examples 'converting source with external images included' do |result|
|
39
|
+
let(:temp_dir) do
|
40
|
+
Pathname.new(ReverseAdoc.config.destination).dirname
|
41
|
+
end
|
42
|
+
let(:images_folder) { File.join(temp_dir, 'images') }
|
43
|
+
|
44
|
+
before do
|
45
|
+
ReverseAdoc.config.destination = File.join(Dir.mktmpdir,
|
46
|
+
'output.html')
|
47
|
+
ReverseAdoc.config.sourcedir = Dir.mktmpdir
|
48
|
+
ReverseAdoc.config.external_images = true
|
49
|
+
end
|
50
|
+
|
51
|
+
after do
|
52
|
+
FileUtils.rm_rf(temp_dir)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'Creates local files from external URI' do
|
56
|
+
expect { convert }
|
57
|
+
.to(change do
|
58
|
+
Dir["#{images_folder}/*gif"]
|
59
|
+
.map { |entry| File.basename(entry) }
|
60
|
+
.sort
|
61
|
+
end.from([]).to(result))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# TODO: fix github actions integration with libreoffice, currently it hangs
|
66
|
+
# when trying to use soffice binary
|
67
|
+
unless Gem::Platform.local.os == 'darwin' && !ENV['GITHUB_ACTION'].nil?
|
68
|
+
context 'when docx file input' do
|
69
|
+
subject(:convert) do
|
70
|
+
ReverseAdoc.convert(
|
71
|
+
ReverseAdoc.cleaner.preprocess_word_html(input.document.html),
|
72
|
+
WordToMarkdown::REVERSE_MARKDOWN_OPTIONS
|
73
|
+
)
|
74
|
+
end
|
75
|
+
let(:input) do
|
76
|
+
WordToMarkdown.new('spec/assets/external_images.docx',
|
77
|
+
ReverseAdoc.config.sourcedir)
|
78
|
+
end
|
79
|
+
it_behaves_like 'converting source with external images included',
|
80
|
+
['001.gif', '002.gif']
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when html file input' do
|
85
|
+
subject(:convert) { ReverseAdoc.convert(input) }
|
86
|
+
let(:input) { File.read('spec/assets/external_images.html') }
|
87
|
+
it_behaves_like 'converting source with external images included',
|
88
|
+
['001.gif']
|
89
|
+
end
|
90
|
+
end
|
@@ -1,7 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
let(:cleaner) {
|
3
|
+
describe ReverseAdoc::Cleaner do
|
4
|
+
let(:cleaner) { ReverseAdoc::Cleaner.new }
|
5
|
+
|
6
|
+
describe '#scrub_whitespace' do
|
7
|
+
it "makes consistent nonbreaking spaces" do
|
8
|
+
result = cleaner.scrub_whitespace("   ")
|
9
|
+
expect(result).to eq "     "
|
10
|
+
end
|
11
|
+
|
12
|
+
it "makes four linebreaks into two" do
|
13
|
+
result = cleaner.scrub_whitespace("A\n\n\n\nB")
|
14
|
+
expect(result).to eq "A\n\nB"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#clean_headings' do
|
19
|
+
it "removes empty headings" do
|
20
|
+
result = cleaner.clean_headings("<h2></h2>")
|
21
|
+
expect(result).to eq " "
|
22
|
+
end
|
23
|
+
|
24
|
+
it "cleans superscripts rendered as headings" do
|
25
|
+
result = cleaner.clean_headings(%{<p class="Standard" style="font-size: 12pt; font-family: Calibri; writing-mode: lr-tb; margin: 0;" align="left ! important"><span class="T1" style="margin: 0;">H</span><h1 class="T2" style="vertical-align: super; font-size: 58%; margin: 0;">2</h1><span class="T1" style="margin: 0;">0</span></p>})
|
26
|
+
expect(result).to eq %{<p class="Standard" style="font-size: 12pt; font-family: Calibri; writing-mode: lr-tb; margin: 0;" align="left ! important"><span class="T1" style="margin: 0;">H</span><sup>2</sup><span class="T1" style="margin: 0;">0</span></p>}
|
27
|
+
end
|
28
|
+
end
|
5
29
|
|
6
30
|
describe '#remove_newlines' do
|
7
31
|
it 'removes more than 2 subsequent newlines' do
|
@@ -62,7 +86,7 @@ describe ReverseAsciidoctor::Cleaner do
|
|
62
86
|
|
63
87
|
describe '#clean_tag_borders' do
|
64
88
|
context 'with default_border is set to space' do
|
65
|
-
before {
|
89
|
+
before { ReverseAdoc.config.tag_border = ' ' }
|
66
90
|
|
67
91
|
it 'removes not needed whitespaces from strong tags' do
|
68
92
|
input = "foo ** foobar ** bar"
|
@@ -108,7 +132,7 @@ describe ReverseAsciidoctor::Cleaner do
|
|
108
132
|
end
|
109
133
|
|
110
134
|
context 'with default_border set to no space' do
|
111
|
-
before {
|
135
|
+
before { ReverseAdoc.config.tag_border = '' }
|
112
136
|
|
113
137
|
it 'removes not needed whitespaces from strong tags' do
|
114
138
|
input = "foo ** foobar ** bar"
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Config do
|
4
4
|
describe '#with' do
|
5
|
-
let(:config) {
|
5
|
+
let(:config) { ReverseAdoc.config }
|
6
6
|
|
7
7
|
it 'takes additional options into account' do
|
8
8
|
config.with(tag_border: :foobar) do
|
9
|
-
expect(
|
9
|
+
expect(ReverseAdoc.config.tag_border).to eq :foobar
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -17,9 +17,9 @@ describe ReverseAsciidoctor::Config do
|
|
17
17
|
it 'resets to original settings afterwards' do
|
18
18
|
config.tag_border = :foo
|
19
19
|
config.with(tag_border: :bar) do
|
20
|
-
expect(
|
20
|
+
expect(ReverseAdoc.config.tag_border).to eq :bar
|
21
21
|
end
|
22
|
-
expect(
|
22
|
+
expect(ReverseAdoc.config.tag_border).to eq :foo
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Converters::Aside do
|
4
4
|
|
5
|
-
let(:converter) {
|
5
|
+
let(:converter) { ReverseAdoc::Converters::Aside.new }
|
6
6
|
|
7
7
|
it 'converts aside' do
|
8
8
|
input = node_for("<aside><ul><li>foo</li></ul></aside>")
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Converters::Audio do
|
4
4
|
|
5
|
-
let(:converter) {
|
5
|
+
let(:converter) { ReverseAdoc::Converters::Audio.new }
|
6
6
|
|
7
7
|
it 'converts audio with no attributes' do
|
8
8
|
node = node_for("<audio src='example.mp3'/>")
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Converters::Blockquote do
|
4
4
|
|
5
|
-
let(:converter) {
|
5
|
+
let(:converter) { ReverseAdoc::Converters::Blockquote.new }
|
6
6
|
|
7
7
|
it 'converts nested elements as well' do
|
8
8
|
input = node_for("<blockquote><ul><li>foo</li></ul></blockquote>")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
let(:converter) {
|
3
|
+
describe ReverseAdoc::Converters::Br do
|
4
|
+
let(:converter) { ReverseAdoc::Converters::Br.new }
|
5
5
|
|
6
6
|
it 'just converts into two spaces and a newline' do
|
7
7
|
expect(converter.convert(:anything)).to eq " \+\n"
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Converters::Code do
|
4
4
|
|
5
|
-
let(:converter) {
|
5
|
+
let(:converter) { ReverseAdoc::Converters::Code.new }
|
6
6
|
|
7
7
|
it 'converts as backtick' do
|
8
8
|
node = node_for("<code>puts foo</code>")
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Converters::Code do
|
4
4
|
|
5
|
-
let(:converter) {
|
5
|
+
let(:converter) { ReverseAdoc::Converters::Div.new }
|
6
6
|
|
7
7
|
it 'converts div' do
|
8
8
|
node = node_for("<div>puts foo</div>")
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Converters::Figure do
|
4
4
|
|
5
|
-
let(:converter) {
|
5
|
+
let(:converter) { ReverseAdoc::Converters::Figure.new }
|
6
6
|
|
7
7
|
it 'converts figure' do
|
8
8
|
node = node_for("<figure id='A'><img src='example.jpg'/><figcaption>Figure <i>caption</i></figcaption></figure>")
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Converters::Img do
|
4
4
|
|
5
|
-
let(:converter) {
|
5
|
+
let(:converter) { ReverseAdoc::Converters::Img.new }
|
6
6
|
|
7
7
|
it 'converts image with no attributes' do
|
8
8
|
node = node_for("<img src='example.jpg'/>")
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Converters::Li do
|
4
4
|
|
5
|
-
let(:converter) {
|
5
|
+
let(:converter) { ReverseAdoc::Converters::Li.new }
|
6
6
|
|
7
7
|
it 'does not fail without a valid parent context' do
|
8
8
|
input = node_for("<li>foo</li>")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
let(:converter) {
|
3
|
+
describe ReverseAdoc::Converters::Mark do
|
4
|
+
let(:converter) { ReverseAdoc::Converters::Mark.new }
|
5
5
|
|
6
6
|
it 'renders mark' do
|
7
7
|
input = node_for('<mark>A</mark>')
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Converters::P do
|
4
4
|
|
5
|
-
let(:converter) {
|
5
|
+
let(:converter) { ReverseAdoc::Converters::P.new }
|
6
6
|
|
7
7
|
it 'converts p with anchor' do
|
8
8
|
node = node_for("<p id='A'>puts foo</p>")
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Converters::Pre do
|
4
4
|
|
5
|
-
let(:converter) {
|
5
|
+
let(:converter) { ReverseAdoc::Converters::Pre.new }
|
6
6
|
|
7
7
|
it 'converts as literal' do
|
8
8
|
node = node_for("<pre>puts foo</pre>")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
let(:converter) {
|
3
|
+
describe ReverseAdoc::Converters::Q do
|
4
|
+
let(:converter) { ReverseAdoc::Converters::Q.new }
|
5
5
|
|
6
6
|
it 'renders q' do
|
7
7
|
input = node_for('<q>A</q>')
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
let(:converter) {
|
3
|
+
describe ReverseAdoc::Converters::Strong do
|
4
|
+
let(:converter) { ReverseAdoc::Converters::Strong.new }
|
5
5
|
|
6
6
|
it 'returns an empty string if the node is empty' do
|
7
7
|
input = node_for('<strong></strong>')
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Converters::Text do
|
4
4
|
|
5
|
-
let(:converter) {
|
5
|
+
let(:converter) { ReverseAdoc::Converters::Text.new }
|
6
6
|
|
7
7
|
it 'treats newline within text as a single whitespace' do
|
8
8
|
input = node_for("<p>foo\nbar</p>")
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc::Converters::Video do
|
4
4
|
|
5
|
-
let(:converter) {
|
5
|
+
let(:converter) { ReverseAdoc::Converters::Video.new }
|
6
6
|
|
7
7
|
it 'converts audio with no attributes' do
|
8
8
|
node = node_for("<audio src='example.mp3'/>")
|
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
before {
|
5
|
-
let(:converters) {
|
3
|
+
describe ReverseAdoc::Converters do
|
4
|
+
before { ReverseAdoc.config.unknown_tags = :raise }
|
5
|
+
let(:converters) { ReverseAdoc::Converters }
|
6
6
|
|
7
7
|
describe '.register and .unregister' do
|
8
8
|
it 'adds a converter mapping to the list' do
|
9
|
-
expect { converters.lookup(:foo) }.to raise_error
|
9
|
+
expect { converters.lookup(:foo) }.to raise_error ReverseAdoc::UnknownTagError
|
10
10
|
|
11
11
|
converters.register :foo, :foobar
|
12
12
|
expect(converters.lookup(:foo)).to eq :foobar
|
13
13
|
|
14
14
|
converters.unregister :foo
|
15
|
-
expect { converters.lookup(:foo) }.to raise_error
|
15
|
+
expect { converters.lookup(:foo) }.to raise_error ReverseAdoc::UnknownTagError
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/spec/spec_helper.rb
CHANGED
@@ -8,11 +8,16 @@ SimpleCov.profiles.define 'gem' do
|
|
8
8
|
end
|
9
9
|
SimpleCov.start 'gem'
|
10
10
|
|
11
|
-
require '
|
11
|
+
require 'reverse_adoc'
|
12
|
+
require 'reverse_adoc/html_converter'
|
13
|
+
require 'word-to-markdown'
|
14
|
+
|
15
|
+
Dir[File.join('spec', 'support', '**', '*.rb')]
|
16
|
+
.each { |f| require File.join('.', f) }
|
12
17
|
|
13
18
|
RSpec.configure do |config|
|
14
19
|
config.after(:each) do
|
15
|
-
|
20
|
+
ReverseAdoc.instance_variable_set(:@config, nil)
|
16
21
|
end
|
17
22
|
end
|
18
23
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
|
5
|
+
module ShellUtils
|
6
|
+
class ShellExcutionError < StandardError; end
|
7
|
+
module_function
|
8
|
+
|
9
|
+
def execute!(cmd)
|
10
|
+
stdout, stderr, status = Open3.capture3(cmd)
|
11
|
+
raise(ShellExcutionError, stderr) unless status.success?
|
12
|
+
|
13
|
+
stdout
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reverse_adoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mimemagic
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +136,20 @@ dependencies:
|
|
122
136
|
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: premailer
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.11.0
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.11.0
|
125
153
|
description: Generate AsciiDoc from HTML and Microsoft Word via CLI or library.
|
126
154
|
email:
|
127
155
|
- open.source@ribose.com
|
@@ -137,56 +165,60 @@ files:
|
|
137
165
|
- ".hound.yml"
|
138
166
|
- ".rubocop.yml"
|
139
167
|
- Gemfile
|
168
|
+
- Gemfile.lock
|
140
169
|
- LICENSE.txt
|
141
170
|
- README.adoc
|
142
171
|
- Rakefile
|
143
172
|
- bin/reverse_adoc
|
144
173
|
- bin/w2a
|
145
|
-
- lib/
|
146
|
-
- lib/
|
147
|
-
- lib/
|
148
|
-
- lib/
|
149
|
-
- lib/
|
150
|
-
- lib/
|
151
|
-
- lib/
|
152
|
-
- lib/
|
153
|
-
- lib/
|
154
|
-
- lib/
|
155
|
-
- lib/
|
156
|
-
- lib/
|
157
|
-
- lib/
|
158
|
-
- lib/
|
159
|
-
- lib/
|
160
|
-
- lib/
|
161
|
-
- lib/
|
162
|
-
- lib/
|
163
|
-
- lib/
|
164
|
-
- lib/
|
165
|
-
- lib/
|
166
|
-
- lib/
|
167
|
-
- lib/
|
168
|
-
- lib/
|
169
|
-
- lib/
|
170
|
-
- lib/
|
171
|
-
- lib/
|
172
|
-
- lib/
|
173
|
-
- lib/
|
174
|
-
- lib/
|
175
|
-
- lib/
|
176
|
-
- lib/
|
177
|
-
- lib/
|
178
|
-
- lib/
|
179
|
-
- lib/
|
180
|
-
- lib/
|
181
|
-
- lib/
|
182
|
-
- lib/
|
183
|
-
- lib/
|
184
|
-
- lib/
|
174
|
+
- lib/reverse_adoc.rb
|
175
|
+
- lib/reverse_adoc/cleaner.rb
|
176
|
+
- lib/reverse_adoc/config.rb
|
177
|
+
- lib/reverse_adoc/converters.rb
|
178
|
+
- lib/reverse_adoc/converters/a.rb
|
179
|
+
- lib/reverse_adoc/converters/aside.rb
|
180
|
+
- lib/reverse_adoc/converters/audio.rb
|
181
|
+
- lib/reverse_adoc/converters/base.rb
|
182
|
+
- lib/reverse_adoc/converters/blockquote.rb
|
183
|
+
- lib/reverse_adoc/converters/br.rb
|
184
|
+
- lib/reverse_adoc/converters/bypass.rb
|
185
|
+
- lib/reverse_adoc/converters/code.rb
|
186
|
+
- lib/reverse_adoc/converters/div.rb
|
187
|
+
- lib/reverse_adoc/converters/drop.rb
|
188
|
+
- lib/reverse_adoc/converters/em.rb
|
189
|
+
- lib/reverse_adoc/converters/figure.rb
|
190
|
+
- lib/reverse_adoc/converters/h.rb
|
191
|
+
- lib/reverse_adoc/converters/head.rb
|
192
|
+
- lib/reverse_adoc/converters/hr.rb
|
193
|
+
- lib/reverse_adoc/converters/ignore.rb
|
194
|
+
- lib/reverse_adoc/converters/img.rb
|
195
|
+
- lib/reverse_adoc/converters/li.rb
|
196
|
+
- lib/reverse_adoc/converters/mark.rb
|
197
|
+
- lib/reverse_adoc/converters/math.rb
|
198
|
+
- lib/reverse_adoc/converters/ol.rb
|
199
|
+
- lib/reverse_adoc/converters/p.rb
|
200
|
+
- lib/reverse_adoc/converters/pass_through.rb
|
201
|
+
- lib/reverse_adoc/converters/pre.rb
|
202
|
+
- lib/reverse_adoc/converters/q.rb
|
203
|
+
- lib/reverse_adoc/converters/strong.rb
|
204
|
+
- lib/reverse_adoc/converters/sub.rb
|
205
|
+
- lib/reverse_adoc/converters/sup.rb
|
206
|
+
- lib/reverse_adoc/converters/table.rb
|
207
|
+
- lib/reverse_adoc/converters/td.rb
|
208
|
+
- lib/reverse_adoc/converters/text.rb
|
209
|
+
- lib/reverse_adoc/converters/th.rb
|
210
|
+
- lib/reverse_adoc/converters/tr.rb
|
211
|
+
- lib/reverse_adoc/converters/video.rb
|
212
|
+
- lib/reverse_adoc/errors.rb
|
213
|
+
- lib/reverse_adoc/html_converter.rb
|
214
|
+
- lib/reverse_adoc/version.rb
|
185
215
|
- reverse_adoc.gemspec
|
186
216
|
- spec/assets/anchors.html
|
187
217
|
- spec/assets/basic.html
|
188
218
|
- spec/assets/code.html
|
189
219
|
- spec/assets/escapables.html
|
220
|
+
- spec/assets/external_images.docx
|
221
|
+
- spec/assets/external_images.html
|
190
222
|
- spec/assets/from_the_wild.html
|
191
223
|
- spec/assets/full_example.html
|
192
224
|
- spec/assets/html_fragment.html
|
@@ -196,6 +228,8 @@ files:
|
|
196
228
|
- spec/assets/quotation.html
|
197
229
|
- spec/assets/tables.html
|
198
230
|
- spec/assets/unknown_tags.html
|
231
|
+
- spec/bin/reverse_adoc_spec.rb
|
232
|
+
- spec/bin/w2a_spec.rb
|
199
233
|
- spec/components/anchors_spec.rb
|
200
234
|
- spec/components/basic_spec.rb
|
201
235
|
- spec/components/code_spec.rb
|
@@ -207,32 +241,33 @@ files:
|
|
207
241
|
- spec/components/quotation_spec.rb
|
208
242
|
- spec/components/tables_spec.rb
|
209
243
|
- spec/components/unknown_tags_spec.rb
|
210
|
-
- spec/lib/
|
211
|
-
- spec/lib/
|
212
|
-
- spec/lib/
|
213
|
-
- spec/lib/
|
214
|
-
- spec/lib/
|
215
|
-
- spec/lib/
|
216
|
-
- spec/lib/
|
217
|
-
- spec/lib/
|
218
|
-
- spec/lib/
|
219
|
-
- spec/lib/
|
220
|
-
- spec/lib/
|
221
|
-
- spec/lib/
|
222
|
-
- spec/lib/
|
223
|
-
- spec/lib/
|
224
|
-
- spec/lib/
|
225
|
-
- spec/lib/
|
226
|
-
- spec/lib/
|
227
|
-
- spec/lib/
|
228
|
-
- spec/lib/
|
229
|
-
- spec/lib/
|
244
|
+
- spec/lib/reverse_adoc.rb
|
245
|
+
- spec/lib/reverse_adoc/cleaner_spec.rb
|
246
|
+
- spec/lib/reverse_adoc/config_spec.rb
|
247
|
+
- spec/lib/reverse_adoc/converters/aside_spec.rb
|
248
|
+
- spec/lib/reverse_adoc/converters/audio_spec.rb
|
249
|
+
- spec/lib/reverse_adoc/converters/blockquote_spec.rb
|
250
|
+
- spec/lib/reverse_adoc/converters/br_spec.rb
|
251
|
+
- spec/lib/reverse_adoc/converters/code_spec.rb
|
252
|
+
- spec/lib/reverse_adoc/converters/div_spec.rb
|
253
|
+
- spec/lib/reverse_adoc/converters/figure_spec.rb
|
254
|
+
- spec/lib/reverse_adoc/converters/img_spec.rb
|
255
|
+
- spec/lib/reverse_adoc/converters/li_spec.rb
|
256
|
+
- spec/lib/reverse_adoc/converters/mark_spec.rb
|
257
|
+
- spec/lib/reverse_adoc/converters/p_spec.rb
|
258
|
+
- spec/lib/reverse_adoc/converters/pre_spec.rb
|
259
|
+
- spec/lib/reverse_adoc/converters/q_spec.rb
|
260
|
+
- spec/lib/reverse_adoc/converters/strong_spec.rb
|
261
|
+
- spec/lib/reverse_adoc/converters/text_spec.rb
|
262
|
+
- spec/lib/reverse_adoc/converters/video_spec.rb
|
263
|
+
- spec/lib/reverse_adoc/converters_spec.rb
|
230
264
|
- spec/spec_helper.rb
|
265
|
+
- spec/support/shell_helpers.rb
|
231
266
|
homepage: http://github.com/metanorma/reverse_adoc
|
232
267
|
licenses:
|
233
268
|
- BSD-2-Clause
|
234
269
|
metadata: {}
|
235
|
-
post_install_message:
|
270
|
+
post_install_message:
|
236
271
|
rdoc_options: []
|
237
272
|
require_paths:
|
238
273
|
- lib
|
@@ -247,9 +282,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
282
|
- !ruby/object:Gem::Version
|
248
283
|
version: '0'
|
249
284
|
requirements: []
|
250
|
-
|
251
|
-
|
252
|
-
signing_key:
|
285
|
+
rubygems_version: 3.0.6
|
286
|
+
signing_key:
|
253
287
|
specification_version: 4
|
254
288
|
summary: Generate AsciiDoc from HTML and Microsoft Word via CLI or library.
|
255
289
|
test_files:
|
@@ -257,6 +291,8 @@ test_files:
|
|
257
291
|
- spec/assets/basic.html
|
258
292
|
- spec/assets/code.html
|
259
293
|
- spec/assets/escapables.html
|
294
|
+
- spec/assets/external_images.docx
|
295
|
+
- spec/assets/external_images.html
|
260
296
|
- spec/assets/from_the_wild.html
|
261
297
|
- spec/assets/full_example.html
|
262
298
|
- spec/assets/html_fragment.html
|
@@ -266,6 +302,8 @@ test_files:
|
|
266
302
|
- spec/assets/quotation.html
|
267
303
|
- spec/assets/tables.html
|
268
304
|
- spec/assets/unknown_tags.html
|
305
|
+
- spec/bin/reverse_adoc_spec.rb
|
306
|
+
- spec/bin/w2a_spec.rb
|
269
307
|
- spec/components/anchors_spec.rb
|
270
308
|
- spec/components/basic_spec.rb
|
271
309
|
- spec/components/code_spec.rb
|
@@ -277,24 +315,25 @@ test_files:
|
|
277
315
|
- spec/components/quotation_spec.rb
|
278
316
|
- spec/components/tables_spec.rb
|
279
317
|
- spec/components/unknown_tags_spec.rb
|
280
|
-
- spec/lib/
|
281
|
-
- spec/lib/
|
282
|
-
- spec/lib/
|
283
|
-
- spec/lib/
|
284
|
-
- spec/lib/
|
285
|
-
- spec/lib/
|
286
|
-
- spec/lib/
|
287
|
-
- spec/lib/
|
288
|
-
- spec/lib/
|
289
|
-
- spec/lib/
|
290
|
-
- spec/lib/
|
291
|
-
- spec/lib/
|
292
|
-
- spec/lib/
|
293
|
-
- spec/lib/
|
294
|
-
- spec/lib/
|
295
|
-
- spec/lib/
|
296
|
-
- spec/lib/
|
297
|
-
- spec/lib/
|
298
|
-
- spec/lib/
|
299
|
-
- spec/lib/
|
318
|
+
- spec/lib/reverse_adoc.rb
|
319
|
+
- spec/lib/reverse_adoc/cleaner_spec.rb
|
320
|
+
- spec/lib/reverse_adoc/config_spec.rb
|
321
|
+
- spec/lib/reverse_adoc/converters/aside_spec.rb
|
322
|
+
- spec/lib/reverse_adoc/converters/audio_spec.rb
|
323
|
+
- spec/lib/reverse_adoc/converters/blockquote_spec.rb
|
324
|
+
- spec/lib/reverse_adoc/converters/br_spec.rb
|
325
|
+
- spec/lib/reverse_adoc/converters/code_spec.rb
|
326
|
+
- spec/lib/reverse_adoc/converters/div_spec.rb
|
327
|
+
- spec/lib/reverse_adoc/converters/figure_spec.rb
|
328
|
+
- spec/lib/reverse_adoc/converters/img_spec.rb
|
329
|
+
- spec/lib/reverse_adoc/converters/li_spec.rb
|
330
|
+
- spec/lib/reverse_adoc/converters/mark_spec.rb
|
331
|
+
- spec/lib/reverse_adoc/converters/p_spec.rb
|
332
|
+
- spec/lib/reverse_adoc/converters/pre_spec.rb
|
333
|
+
- spec/lib/reverse_adoc/converters/q_spec.rb
|
334
|
+
- spec/lib/reverse_adoc/converters/strong_spec.rb
|
335
|
+
- spec/lib/reverse_adoc/converters/text_spec.rb
|
336
|
+
- spec/lib/reverse_adoc/converters/video_spec.rb
|
337
|
+
- spec/lib/reverse_adoc/converters_spec.rb
|
300
338
|
- spec/spec_helper.rb
|
339
|
+
- spec/support/shell_helpers.rb
|