reverse_adoc 0.3.7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +4 -3
- data/Gemfile +1 -1
- data/Rakefile +7 -7
- data/exe/reverse_adoc +11 -11
- data/exe/w2a +15 -16
- data/lib/reverse_adoc/cleaner.rb +17 -18
- data/lib/reverse_adoc/config.rb +7 -7
- data/lib/reverse_adoc/converters/a.rb +24 -24
- data/lib/reverse_adoc/converters/aside.rb +6 -4
- data/lib/reverse_adoc/converters/audio.rb +16 -21
- data/lib/reverse_adoc/converters/base.rb +79 -5
- data/lib/reverse_adoc/converters/blockquote.rb +16 -7
- data/lib/reverse_adoc/converters/br.rb +5 -1
- data/lib/reverse_adoc/converters/bypass.rb +38 -34
- data/lib/reverse_adoc/converters/code.rb +42 -1
- data/lib/reverse_adoc/converters/div.rb +7 -3
- data/lib/reverse_adoc/converters/drop.rb +6 -2
- data/lib/reverse_adoc/converters/em.rb +44 -7
- data/lib/reverse_adoc/converters/figure.rb +10 -6
- data/lib/reverse_adoc/converters/h.rb +19 -11
- data/lib/reverse_adoc/converters/head.rb +7 -2
- data/lib/reverse_adoc/converters/hr.rb +5 -1
- data/lib/reverse_adoc/converters/ignore.rb +6 -2
- data/lib/reverse_adoc/converters/img.rb +29 -19
- data/lib/reverse_adoc/converters/li.rb +6 -13
- data/lib/reverse_adoc/converters/mark.rb +11 -2
- data/lib/reverse_adoc/converters/math.rb +13 -2
- data/lib/reverse_adoc/converters/ol.rb +44 -26
- data/lib/reverse_adoc/converters/p.rb +13 -7
- data/lib/reverse_adoc/converters/pass_through.rb +5 -1
- data/lib/reverse_adoc/converters/pre.rb +23 -10
- data/lib/reverse_adoc/converters/q.rb +6 -2
- data/lib/reverse_adoc/converters/strong.rb +41 -6
- data/lib/reverse_adoc/converters/sub.rb +6 -2
- data/lib/reverse_adoc/converters/sup.rb +6 -2
- data/lib/reverse_adoc/converters/table.rb +28 -23
- data/lib/reverse_adoc/converters/td.rb +32 -16
- data/lib/reverse_adoc/converters/text.rb +16 -14
- data/lib/reverse_adoc/converters/th.rb +4 -6
- data/lib/reverse_adoc/converters/tr.rb +7 -7
- data/lib/reverse_adoc/converters/video.rb +16 -23
- data/lib/reverse_adoc/converters.rb +2 -3
- data/lib/reverse_adoc/html_converter.rb +48 -43
- data/lib/reverse_adoc/version.rb +1 -1
- data/lib/reverse_adoc.rb +9 -9
- data/reverse_adoc.gemspec +4 -1
- data/spec/assets/basic.html +3 -0
- data/spec/bin/reverse_adoc_spec.rb +9 -8
- data/spec/bin/w2a_spec.rb +12 -12
- data/spec/components/anchors_spec.rb +18 -12
- data/spec/components/basic_spec.rb +28 -14
- data/spec/components/code_spec.rb +2 -4
- data/spec/components/escapables_spec.rb +4 -6
- data/spec/components/from_the_wild_spec.rb +2 -4
- data/spec/components/html_fragment_spec.rb +2 -3
- data/spec/components/lists_spec.rb +12 -8
- data/spec/components/paragraphs_spec.rb +2 -3
- data/spec/components/quotation_spec.rb +5 -5
- data/spec/components/tables_spec.rb +22 -11
- data/spec/components/unknown_tags_spec.rb +13 -10
- data/spec/lib/reverse_adoc/cleaner_spec.rb +70 -71
- data/spec/lib/reverse_adoc/config_spec.rb +5 -6
- data/spec/lib/reverse_adoc/converters/aside_spec.rb +2 -3
- data/spec/lib/reverse_adoc/converters/audio_spec.rb +3 -5
- data/spec/lib/reverse_adoc/converters/blockquote_spec.rb +5 -6
- data/spec/lib/reverse_adoc/converters/br_spec.rb +2 -2
- data/spec/lib/reverse_adoc/converters/code_spec.rb +3 -5
- data/spec/lib/reverse_adoc/converters/div_spec.rb +3 -5
- data/spec/lib/reverse_adoc/converters/figure_spec.rb +2 -4
- data/spec/lib/reverse_adoc/converters/img_spec.rb +5 -7
- data/spec/lib/reverse_adoc/converters/li_spec.rb +2 -4
- data/spec/lib/reverse_adoc/converters/mark_spec.rb +4 -4
- data/spec/lib/reverse_adoc/converters/p_spec.rb +2 -3
- data/spec/lib/reverse_adoc/converters/pre_spec.rb +8 -9
- data/spec/lib/reverse_adoc/converters/q_spec.rb +3 -3
- data/spec/lib/reverse_adoc/converters/strong_spec.rb +9 -8
- data/spec/lib/reverse_adoc/converters/text_spec.rb +13 -14
- data/spec/lib/reverse_adoc/converters/video_spec.rb +7 -9
- data/spec/lib/reverse_adoc/converters_spec.rb +9 -6
- data/spec/lib/reverse_adoc.rb +25 -25
- data/spec/spec_helper.rb +11 -11
- data/spec/support/shell_helpers.rb +1 -1
- metadata +17 -3
data/reverse_adoc.gemspec
CHANGED
@@ -16,12 +16,15 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
-
s.executables = `git ls-files -- exe/*`.split("\n").map
|
19
|
+
s.executables = `git ls-files -- exe/*`.split("\n").map do |f|
|
20
|
+
File.basename(f)
|
21
|
+
end
|
20
22
|
s.bindir = "exe"
|
21
23
|
s.require_paths = ["lib"]
|
22
24
|
s.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
23
25
|
|
24
26
|
# specify any dependencies here; for example:
|
27
|
+
s.add_dependency "coradoc", "~> 0.2"
|
25
28
|
s.add_dependency "marcel", "~> 1.0.0"
|
26
29
|
s.add_dependency "mathml2asciimath"
|
27
30
|
s.add_dependency "nokogiri", "~> 1.13"
|
data/spec/assets/basic.html
CHANGED
@@ -1,31 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe "exe/reverse_adoc" do
|
6
6
|
subject(:convert) do
|
7
7
|
ShellUtils.execute!("./exe/reverse_adoc -e -o test1 #{input_file_path}")
|
8
8
|
end
|
9
|
+
|
9
10
|
unless Gem.win_platform?
|
10
|
-
context
|
11
|
-
let(:input_file_path) {
|
12
|
-
let(:images_folder) {
|
11
|
+
context "when external images present" do
|
12
|
+
let(:input_file_path) { "spec/assets/external_images.html" }
|
13
|
+
let(:images_folder) { "images" }
|
13
14
|
|
14
15
|
after do
|
15
16
|
FileUtils.rm_rf(images_folder) if File.directory?(images_folder)
|
16
17
|
end
|
17
18
|
|
18
|
-
it
|
19
|
+
it "Does not raise error" do
|
19
20
|
expect { convert }.to_not raise_error
|
20
21
|
end
|
21
22
|
|
22
|
-
it
|
23
|
+
it "exatracts images from source html" do
|
23
24
|
expect { convert }
|
24
25
|
.to(change do
|
25
26
|
Dir["#{images_folder}/*gif"]
|
26
27
|
.map { |entry| File.basename(entry) }
|
27
28
|
.sort
|
28
|
-
end.from([]).to([
|
29
|
+
end.from([]).to(["001.gif"]))
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
data/spec/bin/w2a_spec.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe "exe/w2a" do
|
6
6
|
subject(:convert) do
|
7
7
|
ShellUtils.execute!("./exe/w2a -e -o test1 #{input_file_path}")
|
8
8
|
end
|
9
|
+
|
9
10
|
# TODO: fix github actions integration with libreoffice, currently it hangs
|
10
11
|
# when trying to use soffice binary
|
11
12
|
unless Gem.win_platform? ||
|
12
|
-
|
13
|
-
context
|
14
|
-
let(:input_file_path) {
|
15
|
-
let(:images_folder) {
|
13
|
+
(Gem::Platform.local.os == "darwin" && !ENV["GITHUB_ACTION"].nil?)
|
14
|
+
context "when external images present" do
|
15
|
+
let(:input_file_path) { "spec/assets/external_images.docx" }
|
16
|
+
let(:images_folder) { "images" }
|
16
17
|
|
17
18
|
after do
|
18
19
|
FileUtils.rm_rf(images_folder) if File.directory?(images_folder)
|
19
20
|
end
|
20
21
|
|
21
|
-
it
|
22
|
+
it "Does not raise error" do
|
22
23
|
expect { convert }.to_not raise_error
|
23
24
|
end
|
24
25
|
|
25
|
-
it
|
26
|
+
it "extracts images from source html" do
|
26
27
|
expect { convert }
|
27
28
|
.to(change do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end.from(false).to(true))
|
29
|
+
!Dir["#{images_folder}/*gif"]
|
30
|
+
.map { |entry| File.basename(entry) }.empty?
|
31
|
+
end.from(false).to(true))
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -1,26 +1,32 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ReverseAdoc do
|
4
|
-
|
5
|
-
let(:input) { File.read('spec/assets/anchors.html') }
|
4
|
+
let(:input) { File.read("spec/assets/anchors.html") }
|
6
5
|
let(:document) { Nokogiri::HTML(input) }
|
7
6
|
subject { ReverseAdoc.convert(input) }
|
8
7
|
|
9
|
-
it { is_expected.to include
|
10
|
-
it { is_expected.to include
|
8
|
+
it { is_expected.to include "http://foobar.com[Foobar]" }
|
9
|
+
it { is_expected.to include "http://foobar.com[Fubar]" }
|
11
10
|
it { is_expected.to include 'http://foobar.com[f\*\*\*\*\* up beyond all redemption]' }
|
12
|
-
it { is_expected.to include
|
11
|
+
it { is_expected.to include "http://strong.foobar.com[*Strong foobar*]" }
|
13
12
|
|
14
|
-
it {
|
13
|
+
it {
|
14
|
+
is_expected.to include "There should be space before but not after the anchor ( http://foobar.com[stripped])."
|
15
|
+
}
|
15
16
|
|
16
|
-
it {
|
17
|
-
|
18
|
-
|
19
|
-
it {
|
17
|
+
it {
|
18
|
+
is_expected.to include " do not ignore link:foo.html[] anchor tags with no link text "
|
19
|
+
}
|
20
|
+
it {
|
21
|
+
is_expected.to include " link <<content,internal jumplinks>> with anchors "
|
22
|
+
}
|
23
|
+
it {
|
24
|
+
is_expected.to include " link <<content2>>internal jumplinks without anchors "
|
25
|
+
}
|
26
|
+
it { is_expected.to include " treat [[content]] as bookmarks " }
|
20
27
|
|
21
28
|
it { is_expected.to include "<<a_bspaced,Double \\_\\_ anchor with space>>" }
|
22
29
|
it { is_expected.to include "[[a_bspaced]]" }
|
23
30
|
it { is_expected.to include "[[a_Foreword]]\n== Text" }
|
24
31
|
it { is_expected.not_to include "[[_Toc12345]]" }
|
25
|
-
|
26
32
|
end
|
@@ -1,9 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ReverseAdoc do
|
4
|
-
|
5
|
-
let(:
|
6
|
-
let(:document) { Nokogiri::HTML(input) }
|
4
|
+
let(:input) { File.read("spec/assets/basic.html") }
|
5
|
+
# let(:document) { Nokogiri::HTML(input) }
|
7
6
|
subject { ReverseAdoc.convert(input) }
|
8
7
|
|
9
8
|
it { is_expected.to match /plain text ?\n/ }
|
@@ -21,25 +20,40 @@ describe ReverseAdoc do
|
|
21
20
|
it { is_expected.to match /_double em tags_/ }
|
22
21
|
it { is_expected.to match /_double em tags in p tag_/ }
|
23
22
|
it { is_expected.to match /a _em with leading and trailing_ whitespace/ }
|
24
|
-
it {
|
23
|
+
it {
|
24
|
+
is_expected.to match /a _em with extra leading and trailing_ whitespace/
|
25
|
+
}
|
25
26
|
|
26
27
|
it { is_expected.to match /\*strong tag content\*/ }
|
27
28
|
it { is_expected.to match /before and after empty strong tags/ }
|
28
|
-
it {
|
29
|
+
it {
|
30
|
+
is_expected.to match /before and after strong tags containing whitespace/
|
31
|
+
}
|
29
32
|
it { is_expected.to match /\*double strong tags\*/ }
|
30
33
|
it { is_expected.to match /\*double strong tags in p tag\*/ }
|
31
|
-
it {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
it {
|
35
|
+
is_expected.to match /before \*double strong tags containing whitespace\* after/
|
36
|
+
}
|
37
|
+
it {
|
38
|
+
is_expected.to match /a \*strong with leading and trailing\* whitespace/
|
39
|
+
}
|
40
|
+
it {
|
41
|
+
is_expected.to match /a \*strong with extra leading and trailing\* whitespace/
|
42
|
+
}
|
43
|
+
|
44
|
+
it { is_expected.to match /constrai\*\*ned\*\* strong/ }
|
45
|
+
it { is_expected.to match /constrai__ned__ italic/ }
|
37
46
|
|
38
47
|
it { is_expected.to match /_i tag content_/ }
|
39
48
|
it { is_expected.to match /\*b tag content\*/ }
|
40
49
|
|
41
|
-
it { is_expected.to match /
|
42
|
-
|
50
|
+
it { is_expected.to match /H~2~O/ }
|
51
|
+
it { is_expected.to match /A\^2\^B/ }
|
52
|
+
|
53
|
+
it {
|
54
|
+
is_expected.to match /br tags become double space followed by newline \+\n/
|
55
|
+
}
|
56
|
+
# it { should match /br tags XXX \n/ }
|
43
57
|
|
44
58
|
it { is_expected.to match /before hr \n\* \* \*\n after hr/ }
|
45
59
|
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ReverseAdoc do
|
4
|
-
|
5
|
-
let(:input) { File.read('spec/assets/code.html') }
|
4
|
+
let(:input) { File.read("spec/assets/code.html") }
|
6
5
|
let(:document) { Nokogiri::HTML(input) }
|
7
6
|
subject { ReverseAdoc.convert(input) }
|
8
7
|
|
@@ -23,5 +22,4 @@ describe ReverseAdoc do
|
|
23
22
|
it { is_expected.to match(/^ beep\n/) }
|
24
23
|
it { is_expected.to match(/^end tell\n/) }
|
25
24
|
end
|
26
|
-
|
27
25
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ReverseAdoc do
|
4
|
-
|
5
|
-
let(:input) { File.read('spec/assets/escapables.html') }
|
4
|
+
let(:input) { File.read("spec/assets/escapables.html") }
|
6
5
|
let(:document) { Nokogiri::HTML(input) }
|
7
6
|
subject { ReverseAdoc.convert(input) }
|
8
7
|
|
@@ -10,7 +9,7 @@ describe ReverseAdoc do
|
|
10
9
|
it { is_expected.to include ' \*\*two asterisks\*\* ' }
|
11
10
|
it { is_expected.to include ' \*\*\*three asterisks\*\*\* ' }
|
12
11
|
it { is_expected.to include ' \*and*the\* ' }
|
13
|
-
it { is_expected.to include
|
12
|
+
it { is_expected.to include " asterisc*word " }
|
14
13
|
it { is_expected.to include ' asterisc**multword asterisks\*\*\* ' }
|
15
14
|
end
|
16
15
|
|
@@ -20,7 +19,7 @@ describe ReverseAdoc do
|
|
20
19
|
end
|
21
20
|
|
22
21
|
context "multiple underscores with undersocre inside words and new lines" do
|
23
|
-
it { is_expected.to include
|
22
|
+
it { is_expected.to include "another_undersocre" }
|
24
23
|
it { is_expected.to include ' \_\_\_three__underscores\_\_\_ ' }
|
25
24
|
end
|
26
25
|
|
@@ -28,5 +27,4 @@ describe ReverseAdoc do
|
|
28
27
|
let(:expected_output) { "....\nvar theoretical_max_infin = 1.0;\n....\n" }
|
29
28
|
it { is_expected.to include expected_output }
|
30
29
|
end
|
31
|
-
|
32
30
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ReverseAdoc do
|
4
|
-
|
5
|
-
let(:input) { File.read('spec/assets/from_the_wild.html') }
|
4
|
+
let(:input) { File.read("spec/assets/from_the_wild.html") }
|
6
5
|
let(:document) { Nokogiri::HTML(input) }
|
7
6
|
subject { ReverseAdoc.convert(input) }
|
8
7
|
|
@@ -13,5 +12,4 @@ describe ReverseAdoc do
|
|
13
12
|
it "should not over escape * or _" do
|
14
13
|
expect(subject).to include 'link:example.com/foo_bar[image::example.com/foo_bar.png[] I\_AM\_HELPFUL]'
|
15
14
|
end
|
16
|
-
|
17
15
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ReverseAdoc do
|
4
|
-
|
5
|
-
let(:input) { File.read('spec/assets/html_fragment.html') }
|
4
|
+
let(:input) { File.read("spec/assets/html_fragment.html") }
|
6
5
|
let(:document) { Nokogiri::HTML(input) }
|
7
6
|
subject { ReverseAdoc.convert(input) }
|
8
7
|
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ReverseAdoc do
|
4
|
-
|
5
|
-
let(:input) { File.read('spec/assets/lists.html') }
|
4
|
+
let(:input) { File.read("spec/assets/lists.html") }
|
6
5
|
let(:document) { Nokogiri::HTML(input) }
|
7
6
|
subject { ReverseAdoc.convert(input) }
|
8
7
|
|
@@ -30,7 +29,9 @@ describe ReverseAdoc do
|
|
30
29
|
|
31
30
|
context "list start, reversed" do
|
32
31
|
it { is_expected.to match /\n\[start=3\]\n\. another ordered list entry\n/ }
|
33
|
-
it {
|
32
|
+
it {
|
33
|
+
is_expected.to match /\n\[%reversed\]\n\. a reversed ordered list entry\n/
|
34
|
+
}
|
34
35
|
end
|
35
36
|
|
36
37
|
context "nested list with no whitespace" do
|
@@ -49,8 +50,12 @@ describe ReverseAdoc do
|
|
49
50
|
|
50
51
|
context "lists containing links" do
|
51
52
|
it { is_expected.to match /\n\* link:Basic_concepts\[1 Basic concepts\]\n/ }
|
52
|
-
it {
|
53
|
-
|
53
|
+
it {
|
54
|
+
is_expected.to match /\n\* link:History_of_the_idea\[2 History of the idea\]\n/
|
55
|
+
}
|
56
|
+
it {
|
57
|
+
is_expected.to match /\n\* link:Intelligence_explosion\[3 Intelligence explosion\]\n/
|
58
|
+
}
|
54
59
|
end
|
55
60
|
|
56
61
|
context "lists containing embedded <p> tags" do
|
@@ -61,7 +66,7 @@ describe ReverseAdoc do
|
|
61
66
|
xit { is_expected.to match /\n\* li 1, p 1\n\n\* li 1, p 2\n/ }
|
62
67
|
end
|
63
68
|
|
64
|
-
context
|
69
|
+
context "it produces correct numbering" do
|
65
70
|
it { is_expected.to include "\. one" }
|
66
71
|
it { is_expected.to include "\.\. one one" }
|
67
72
|
it { is_expected.to include "\.\. one two" }
|
@@ -82,5 +87,4 @@ describe ReverseAdoc do
|
|
82
87
|
it { is_expected.to match /\n\* charlie\n/ }
|
83
88
|
it { is_expected.to match /\n\* delta\n/ }
|
84
89
|
end
|
85
|
-
|
86
90
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ReverseAdoc do
|
4
|
-
|
5
|
-
let(:input) { File.read('spec/assets/paragraphs.html') }
|
4
|
+
let(:input) { File.read("spec/assets/paragraphs.html") }
|
6
5
|
let(:document) { Nokogiri::HTML(input) }
|
7
6
|
subject { ReverseAdoc.convert(input) }
|
8
7
|
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ReverseAdoc do
|
4
|
-
|
5
|
-
let(:input) { File.read('spec/assets/quotation.html') }
|
4
|
+
let(:input) { File.read("spec/assets/quotation.html") }
|
6
5
|
let(:document) { Nokogiri::HTML(input) }
|
7
6
|
subject { ReverseAdoc.convert(input) }
|
8
7
|
|
9
8
|
it { is_expected.to match /\n Block of code$/ }
|
10
|
-
it {
|
11
|
-
|
9
|
+
it {
|
10
|
+
is_expected.to include "\n____\nFirst quoted paragraph\n\nSecond quoted paragraph\n____\n"
|
11
|
+
}
|
12
12
|
end
|
@@ -1,17 +1,24 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ReverseAdoc do
|
4
|
-
|
5
|
-
let(:input) { File.read('spec/assets/tables.html') }
|
4
|
+
let(:input) { File.read("spec/assets/tables.html") }
|
6
5
|
let(:document) { Nokogiri::HTML(input) }
|
7
6
|
subject { ReverseAdoc.convert(input) }
|
8
7
|
|
9
|
-
it {
|
10
|
-
|
8
|
+
it {
|
9
|
+
is_expected.to match /\[\[A\]\]\n\|===\n\| \[\[C\]\]header 1 \| header 2 \| header 3\n\n/
|
10
|
+
}
|
11
|
+
it {
|
12
|
+
is_expected.to match /\nh\| \[\[D\]\]data 1-1 \| data 2-1 \| data 3-1\n/
|
13
|
+
}
|
11
14
|
it { is_expected.to match /\nh\| data 1-2 \| data 2-2 \| data 3-2\n/ }
|
12
15
|
|
13
|
-
it {
|
14
|
-
|
16
|
+
it {
|
17
|
+
is_expected.to match /\n\| _header oblique_ \| \*header bold\* \| `header code`\n\n/
|
18
|
+
}
|
19
|
+
it {
|
20
|
+
is_expected.to match /\n\| _data oblique_ \| \*data bold\* \| `data code`\n/
|
21
|
+
}
|
15
22
|
|
16
23
|
it { is_expected.to match /\n\.2\+\| rowspan 2\n/ }
|
17
24
|
it { is_expected.to match /\n2\+| colspan 2\n/ }
|
@@ -23,9 +30,13 @@ describe ReverseAdoc do
|
|
23
30
|
it { is_expected.to match /\^\.\^\| center middle\n/ }
|
24
31
|
|
25
32
|
it { is_expected.to match /\n\.Table _caption_\n\|===\n/ }
|
26
|
-
it { is_expected.to match /\n\[width=75%\]\n\|===\n\| 75% width table\n/ }
|
27
|
-
it {
|
28
|
-
|
29
|
-
|
33
|
+
# it { is_expected.to match /\n\[width=75%\]\n\|===\n\| 75% width table\n/ }
|
34
|
+
it {
|
35
|
+
is_expected.to match /\n\[frame=topbot,rules=cols\]\n\|===\n\| topbot\n/
|
36
|
+
}
|
37
|
+
|
38
|
+
it {
|
39
|
+
is_expected.to match /\na|\nHello\n\nThis cell has multiple paragraphs\n\n/
|
40
|
+
}
|
30
41
|
it { is_expected.to match /\n\| This cell has a single paragraph\n/ }
|
31
42
|
end
|
@@ -1,38 +1,41 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ReverseAdoc do
|
4
|
-
|
5
|
-
let(:input) { File.read('spec/assets/unknown_tags.html') }
|
4
|
+
let(:input) { File.read("spec/assets/unknown_tags.html") }
|
6
5
|
let(:document) { Nokogiri::HTML(input) }
|
7
6
|
let(:result) { ReverseAdoc.convert(input) }
|
8
7
|
|
9
|
-
context
|
8
|
+
context "with unknown_tags = :pass_through" do
|
10
9
|
before { ReverseAdoc.config.unknown_tags = :pass_through }
|
11
10
|
|
12
11
|
it { expect(result).to include "<bar>Foo with bar</bar>" }
|
13
12
|
end
|
14
13
|
|
15
|
-
context
|
14
|
+
context "with unknown_tags = :raise" do
|
16
15
|
before { ReverseAdoc.config.unknown_tags = :raise }
|
17
16
|
|
18
17
|
it { expect { result }.to raise_error(ReverseAdoc::UnknownTagError) }
|
19
18
|
end
|
20
19
|
|
21
|
-
context
|
20
|
+
context "with unknown_tags = :drop" do
|
22
21
|
before { ReverseAdoc.config.unknown_tags = :drop }
|
23
22
|
|
24
|
-
it { expect(result).to eq
|
23
|
+
it { expect(result).to eq "" }
|
25
24
|
end
|
26
25
|
|
27
|
-
context
|
26
|
+
context "with unknown_tags = :bypass" do
|
28
27
|
before { ReverseAdoc.config.unknown_tags = :bypass }
|
29
28
|
|
30
29
|
it { expect(result).to eq "Foo with bar\n\n" }
|
31
30
|
end
|
32
31
|
|
33
|
-
context
|
32
|
+
context "with unknown_tags = :something_wrong" do
|
34
33
|
before { ReverseAdoc.config.unknown_tags = :something_wrong }
|
35
34
|
|
36
|
-
it {
|
35
|
+
it {
|
36
|
+
expect do
|
37
|
+
result
|
38
|
+
end.to raise_error(ReverseAdoc::InvalidConfigurationError)
|
39
|
+
}
|
37
40
|
end
|
38
41
|
end
|