reverse_adoc 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/README.adoc +4 -294
  4. data/Rakefile +2 -13
  5. data/reverse_adoc.gemspec +2 -20
  6. metadata +5 -246
  7. data/.editorconfig +0 -15
  8. data/.github/workflows/rake.yml +0 -15
  9. data/.gitignore +0 -10
  10. data/.hound.yml +0 -5
  11. data/.rubocop.yml +0 -10
  12. data/LICENSE.txt +0 -25
  13. data/exe/reverse_adoc +0 -70
  14. data/exe/w2a +0 -72
  15. data/lib/reverse_adoc/cleaner.rb +0 -113
  16. data/lib/reverse_adoc/config.rb +0 -54
  17. data/lib/reverse_adoc/converters/a.rb +0 -42
  18. data/lib/reverse_adoc/converters/aside.rb +0 -16
  19. data/lib/reverse_adoc/converters/audio.rb +0 -29
  20. data/lib/reverse_adoc/converters/base.rb +0 -100
  21. data/lib/reverse_adoc/converters/blockquote.rb +0 -27
  22. data/lib/reverse_adoc/converters/br.rb +0 -15
  23. data/lib/reverse_adoc/converters/bypass.rb +0 -81
  24. data/lib/reverse_adoc/converters/code.rb +0 -56
  25. data/lib/reverse_adoc/converters/div.rb +0 -18
  26. data/lib/reverse_adoc/converters/drop.rb +0 -22
  27. data/lib/reverse_adoc/converters/em.rb +0 -55
  28. data/lib/reverse_adoc/converters/figure.rb +0 -25
  29. data/lib/reverse_adoc/converters/h.rb +0 -42
  30. data/lib/reverse_adoc/converters/head.rb +0 -23
  31. data/lib/reverse_adoc/converters/hr.rb +0 -15
  32. data/lib/reverse_adoc/converters/ignore.rb +0 -16
  33. data/lib/reverse_adoc/converters/img.rb +0 -93
  34. data/lib/reverse_adoc/converters/li.rb +0 -17
  35. data/lib/reverse_adoc/converters/mark.rb +0 -21
  36. data/lib/reverse_adoc/converters/math.rb +0 -31
  37. data/lib/reverse_adoc/converters/ol.rb +0 -64
  38. data/lib/reverse_adoc/converters/p.rb +0 -23
  39. data/lib/reverse_adoc/converters/pass_through.rb +0 -13
  40. data/lib/reverse_adoc/converters/pre.rb +0 -55
  41. data/lib/reverse_adoc/converters/q.rb +0 -16
  42. data/lib/reverse_adoc/converters/strong.rb +0 -52
  43. data/lib/reverse_adoc/converters/sub.rb +0 -16
  44. data/lib/reverse_adoc/converters/sup.rb +0 -16
  45. data/lib/reverse_adoc/converters/table.rb +0 -69
  46. data/lib/reverse_adoc/converters/td.rb +0 -83
  47. data/lib/reverse_adoc/converters/text.rb +0 -65
  48. data/lib/reverse_adoc/converters/th.rb +0 -14
  49. data/lib/reverse_adoc/converters/tr.rb +0 -22
  50. data/lib/reverse_adoc/converters/video.rb +0 -29
  51. data/lib/reverse_adoc/converters.rb +0 -32
  52. data/lib/reverse_adoc/errors.rb +0 -10
  53. data/lib/reverse_adoc/html_converter.rb +0 -61
  54. data/lib/reverse_adoc/version.rb +0 -3
  55. data/lib/reverse_adoc.rb +0 -27
  56. data/spec/assets/anchors.html +0 -30
  57. data/spec/assets/basic.html +0 -61
  58. data/spec/assets/code.html +0 -22
  59. data/spec/assets/escapables.html +0 -17
  60. data/spec/assets/external_images.docx +0 -0
  61. data/spec/assets/external_images.html +0 -35
  62. data/spec/assets/from_the_wild.html +0 -23
  63. data/spec/assets/full_example.html +0 -49
  64. data/spec/assets/html_fragment.html +0 -3
  65. data/spec/assets/lists.html +0 -137
  66. data/spec/assets/minimum.html +0 -4
  67. data/spec/assets/paragraphs.html +0 -24
  68. data/spec/assets/quotation.html +0 -12
  69. data/spec/assets/tables.html +0 -99
  70. data/spec/assets/unknown_tags.html +0 -9
  71. data/spec/bin/reverse_adoc_spec.rb +0 -33
  72. data/spec/bin/w2a_spec.rb +0 -35
  73. data/spec/components/anchors_spec.rb +0 -32
  74. data/spec/components/basic_spec.rb +0 -63
  75. data/spec/components/code_spec.rb +0 -25
  76. data/spec/components/escapables_spec.rb +0 -30
  77. data/spec/components/from_the_wild_spec.rb +0 -15
  78. data/spec/components/html_fragment_spec.rb +0 -9
  79. data/spec/components/lists_spec.rb +0 -90
  80. data/spec/components/paragraphs_spec.rb +0 -14
  81. data/spec/components/quotation_spec.rb +0 -12
  82. data/spec/components/tables_spec.rb +0 -42
  83. data/spec/components/unknown_tags_spec.rb +0 -41
  84. data/spec/lib/reverse_adoc/cleaner_spec.rb +0 -180
  85. data/spec/lib/reverse_adoc/config_spec.rb +0 -25
  86. data/spec/lib/reverse_adoc/converters/aside_spec.rb +0 -11
  87. data/spec/lib/reverse_adoc/converters/audio_spec.rb +0 -15
  88. data/spec/lib/reverse_adoc/converters/blockquote_spec.rb +0 -23
  89. data/spec/lib/reverse_adoc/converters/br_spec.rb +0 -9
  90. data/spec/lib/reverse_adoc/converters/code_spec.rb +0 -15
  91. data/spec/lib/reverse_adoc/converters/div_spec.rb +0 -15
  92. data/spec/lib/reverse_adoc/converters/figure_spec.rb +0 -10
  93. data/spec/lib/reverse_adoc/converters/img_spec.rb +0 -25
  94. data/spec/lib/reverse_adoc/converters/li_spec.rb +0 -11
  95. data/spec/lib/reverse_adoc/converters/mark_spec.rb +0 -10
  96. data/spec/lib/reverse_adoc/converters/p_spec.rb +0 -10
  97. data/spec/lib/reverse_adoc/converters/pre_spec.rb +0 -43
  98. data/spec/lib/reverse_adoc/converters/q_spec.rb +0 -10
  99. data/spec/lib/reverse_adoc/converters/strong_spec.rb +0 -21
  100. data/spec/lib/reverse_adoc/converters/text_spec.rb +0 -67
  101. data/spec/lib/reverse_adoc/converters/video_spec.rb +0 -15
  102. data/spec/lib/reverse_adoc/converters_spec.rb +0 -22
  103. data/spec/lib/reverse_adoc.rb +0 -90
  104. data/spec/spec_helper.rb +0 -25
  105. data/spec/support/shell_helpers.rb +0 -15
@@ -1,90 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc do
4
- let(:input) { File.read("spec/assets/lists.html") }
5
- let(:document) { Nokogiri::HTML(input) }
6
- subject { ReverseAdoc.convert(input) }
7
-
8
- it { is_expected.to match /\n\* unordered list entry\n/ }
9
- it { is_expected.to match /\n\* unordered list entry 2\n/ }
10
- it { is_expected.to match /\n. ordered list entry\n/ }
11
- it { is_expected.to match /\n. ordered list entry 2\n/ }
12
- it { is_expected.to match /\n. list entry 1st hierarchy\n/ }
13
- it { is_expected.to match /\n\*\* nested unsorted list entry\n/ }
14
- it { is_expected.to match /\n\.\.\. deep nested list entry\n/ }
15
-
16
- context "list anchors" do
17
- it { is_expected.to match /\n\[\[1\]\]\n\. arabic1\n/ }
18
- it { is_expected.to match /\n\[\[A\]\]\n\* upperalpha1\n/ }
19
- end
20
-
21
- context "list styles" do
22
- it { is_expected.to match /\n\[arabic\]\n\. arabic\n/ }
23
- it { is_expected.to match /\n\[loweralpha\]\n\. loweralpha\n/ }
24
- it { is_expected.to match /\n\[upperalpha\]\n\. upperalpha\n/ }
25
- it { is_expected.to match /\n\[lowerroman\]\n\. lowerroman\n/ }
26
- it { is_expected.to match /\n\[upperroman\]\n\. upperroman\n/ }
27
- it { is_expected.to match /\n\[type=disc\]\n\* disc\n/ }
28
- end
29
-
30
- context "list start, reversed" do
31
- it { is_expected.to match /\n\[start=3\]\n\. another ordered list entry\n/ }
32
- it {
33
- is_expected.to match /\n\[%reversed\]\n\. a reversed ordered list entry\n/
34
- }
35
- end
36
-
37
- context "nested list with no whitespace" do
38
- it { is_expected.to match /\n\* item a\n/ }
39
- it { is_expected.to match /\n\* item b\n/ }
40
- it { is_expected.to match /\n\*\* item bb\n/ }
41
- it { is_expected.to match /\n\*\* item bc\n/ }
42
- end
43
-
44
- context "nested list with lots of whitespace" do
45
- it { is_expected.to match /\n\* item wa \n/ }
46
- it { is_expected.to match /\n\* item wb \n/ }
47
- it { is_expected.to match /\n\*\* item wbb \n/ }
48
- it { is_expected.to match /\n\*\* item wbc \n/ }
49
- end
50
-
51
- context "lists containing links" do
52
- it { is_expected.to match /\n\* link:Basic_concepts\[1 Basic concepts\]\n/ }
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
- }
59
- end
60
-
61
- context "lists containing embedded <p> tags" do
62
- xit { is_expected.to match /\n\* I want to have a party at my house!\n/ }
63
- end
64
-
65
- context "list item containing multiple <p> tags" do
66
- xit { is_expected.to match /\n\* li 1, p 1\n\n\* li 1, p 2\n/ }
67
- end
68
-
69
- context "it produces correct numbering" do
70
- it { is_expected.to include "\. one" }
71
- it { is_expected.to include "\.\. one one" }
72
- it { is_expected.to include "\.\. one two" }
73
- it { is_expected.to include "\. two" }
74
- it { is_expected.to include "\.\. two one" }
75
- it { is_expected.to include "\.\.\. two one one" }
76
- it { is_expected.to include "\.\.\. two one two" }
77
- it { is_expected.to include "\.\. two two" }
78
- it { is_expected.to include "\. three" }
79
- end
80
-
81
- context "properly embeds a nested list between adjacent list items" do
82
- it { is_expected.to match /\n\* alpha\n/ }
83
- it { is_expected.to match /\n\* bravo/ }
84
- it { is_expected.to match /\n\*\* bravo alpha\n/ }
85
- it { is_expected.to match /\n\*\* bravo bravo/ }
86
- it { is_expected.to match /\n\*\*\* bravo bravo alpha/ }
87
- it { is_expected.to match /\n\* charlie\n/ }
88
- it { is_expected.to match /\n\* delta\n/ }
89
- end
90
- end
@@ -1,14 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc do
4
- let(:input) { File.read("spec/assets/paragraphs.html") }
5
- let(:document) { Nokogiri::HTML(input) }
6
- subject { ReverseAdoc.convert(input) }
7
-
8
- it { is_expected.not_to start_with "\n\n" }
9
- it { is_expected.to start_with "First content\n\nSecond content\n\n" }
10
- it { is_expected.to include "\n\n_Complex_\n\n\.\.\.\.\n\n Content\n" }
11
- it { is_expected.to include "*Trailing whitespace:*" }
12
- it { is_expected.to include "*Trailing non-breaking space:&nbsp;*" }
13
- it { is_expected.to include "*_Combination:&nbsp;_*" }
14
- end
@@ -1,12 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc do
4
- let(:input) { File.read("spec/assets/quotation.html") }
5
- let(:document) { Nokogiri::HTML(input) }
6
- subject { ReverseAdoc.convert(input) }
7
-
8
- it { is_expected.to match /\n Block of code$/ }
9
- it {
10
- is_expected.to include "\n____\nFirst quoted paragraph\n\nSecond quoted paragraph\n____\n"
11
- }
12
- end
@@ -1,42 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc do
4
- let(:input) { File.read("spec/assets/tables.html") }
5
- let(:document) { Nokogiri::HTML(input) }
6
- subject { ReverseAdoc.convert(input) }
7
-
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
- }
14
- it { is_expected.to match /\nh\| data 1-2 \| data 2-2 \| data 3-2\n/ }
15
-
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
- }
22
-
23
- it { is_expected.to match /\n\.2\+\| rowspan 2\n/ }
24
- it { is_expected.to match /\n2\+| colspan 2\n/ }
25
- it { is_expected.to match /\n2\.2\+| colrowspan 2\n/ }
26
-
27
- it { is_expected.to match /<\| horizontal left / }
28
- it { is_expected.to match /\^\| horizontal center / }
29
- it { is_expected.to match />\| horizontal right\n/ }
30
- it { is_expected.to match /\^\.\^\| center middle\n/ }
31
-
32
- it { is_expected.to match /\n\.Table _caption_\n\|===\n/ }
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
- }
41
- it { is_expected.to match /\n\| This cell has a single paragraph\n/ }
42
- end
@@ -1,41 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc do
4
- let(:input) { File.read("spec/assets/unknown_tags.html") }
5
- let(:document) { Nokogiri::HTML(input) }
6
- let(:result) { ReverseAdoc.convert(input) }
7
-
8
- context "with unknown_tags = :pass_through" do
9
- before { ReverseAdoc.config.unknown_tags = :pass_through }
10
-
11
- it { expect(result).to include "<bar>Foo with bar</bar>" }
12
- end
13
-
14
- context "with unknown_tags = :raise" do
15
- before { ReverseAdoc.config.unknown_tags = :raise }
16
-
17
- it { expect { result }.to raise_error(ReverseAdoc::UnknownTagError) }
18
- end
19
-
20
- context "with unknown_tags = :drop" do
21
- before { ReverseAdoc.config.unknown_tags = :drop }
22
-
23
- it { expect(result).to eq "" }
24
- end
25
-
26
- context "with unknown_tags = :bypass" do
27
- before { ReverseAdoc.config.unknown_tags = :bypass }
28
-
29
- it { expect(result).to eq "Foo with bar\n\n" }
30
- end
31
-
32
- context "with unknown_tags = :something_wrong" do
33
- before { ReverseAdoc.config.unknown_tags = :something_wrong }
34
-
35
- it {
36
- expect do
37
- result
38
- end.to raise_error(ReverseAdoc::InvalidConfigurationError)
39
- }
40
- end
41
- end
@@ -1,180 +0,0 @@
1
- require "spec_helper"
2
-
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("&nbsp; &#xA0;  ")
9
- expect(result).to eq "&#xA0; &#xA0; &#xA0;"
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
29
-
30
- describe "#remove_newlines" do
31
- it "removes more than 2 subsequent newlines" do
32
- result = cleaner.remove_newlines("foo\n\n\nbar")
33
- expect(result).to eq "foo\n\nbar"
34
- end
35
-
36
- it "skips single and double newlines" do
37
- result = cleaner.remove_newlines("foo\nbar\n\nbaz")
38
- expect(result).to eq "foo\nbar\n\nbaz"
39
- end
40
- end
41
-
42
- describe "#remove_inner_whitespaces" do
43
- it "removes duplicate whitespaces from the string" do
44
- result = cleaner.remove_inner_whitespaces("foo bar")
45
- expect(result).to eq "foo bar"
46
- end
47
-
48
- it "performs changes for multiple lines" do
49
- result = cleaner.remove_inner_whitespaces("foo bar\nbar foo")
50
- expect(result).to eq "foo bar\nbar foo"
51
- end
52
-
53
- it "keeps leading whitespaces" do
54
- result = cleaner.remove_inner_whitespaces(" foo bar\n bar foo")
55
- expect(result).to eq " foo bar\n bar foo"
56
- end
57
-
58
- it "keeps trailing whitespaces" do
59
- result = cleaner.remove_inner_whitespaces("foo \n")
60
- expect(result).to eq "foo \n"
61
- end
62
-
63
- it "keeps trailing newlines" do
64
- result = cleaner.remove_inner_whitespaces("foo\n")
65
- expect(result).to eq "foo\n"
66
- end
67
-
68
- it "removes tabs as well" do
69
- result = cleaner.remove_inner_whitespaces("foo\t \tbar")
70
- expect(result).to eq "foo bar"
71
- end
72
-
73
- it "keeps lines that only contain whitespace" do
74
- result = cleaner.remove_inner_whitespaces("foo \nbar \n \n \nfoo")
75
- expect(result).to eq "foo \nbar \n \n \nfoo"
76
- end
77
- end
78
-
79
- describe "#clean_punctuation_characters" do
80
- it "removes whitespace between tag end and punctuation characters" do
81
- input = "**fat** . ~~strike~~ ? __italic__ ! "
82
- result = cleaner.clean_punctuation_characters(input)
83
- expect(result).to eq "**fat**. ~~strike~~? __italic__! "
84
- end
85
- end
86
-
87
- describe "#clean_tag_borders" do
88
- context "with default_border is set to space" do
89
- before { ReverseAdoc.config.tag_border = " " }
90
-
91
- # it 'removes not needed whitespaces from strong tags' do
92
- # input = "foo ** foobar ** bar"
93
- # result = cleaner.clean_tag_borders(input)
94
- # expect(result).to eq "foo **foobar** bar"
95
- # end
96
-
97
- # it 'remotes leading or trailing whitespaces independently' do
98
- # input = "1 **fat ** 2 ** fat** 3"
99
- # result = cleaner.clean_tag_borders(input)
100
- # expect(result).to eq "1 **fat** 2 **fat** 3"
101
- # end
102
-
103
- # it 'adds whitespaces if there are none' do
104
- # input = "1**fat**2"
105
- # result = cleaner.clean_tag_borders(input)
106
- # expect(result).to eq "1 **fat** 2"
107
- # end
108
-
109
- it "doesn't add whitespaces to underscore'ed elements if they are part of links" do
110
- input = "![im__age](sou__rce)"
111
- result = cleaner.clean_tag_borders(input)
112
- expect(result).to eq "![im__age](sou__rce)"
113
- end
114
-
115
- # it "still cleans up whitespaces that aren't inside a link" do
116
- # input = "now __italic __with following [under__scored](link)"
117
- # result = cleaner.clean_tag_borders(input)
118
- # expect(result).to eq "now __italic__ with following [under__scored](link)"
119
- # end
120
-
121
- # it 'cleans italic stuff as well' do
122
- # input = "1 __italic __ 2 __ italic__ 3__italic __4"
123
- # result = cleaner.clean_tag_borders(input)
124
- # expect(result).to eq "1 __italic__ 2 __italic__ 3 __italic__ 4"
125
- # end
126
-
127
- it "cleans strikethrough stuff as well" do
128
- input = "1 ~~italic ~~ 2 ~~ italic~~ 3~~italic ~~4"
129
- result = cleaner.clean_tag_borders(input)
130
- expect(result).to eq "1 ~~italic~~ 2 ~~italic~~ 3 ~~italic~~ 4"
131
- end
132
- end
133
-
134
- context "with default_border set to no space" do
135
- before { ReverseAdoc.config.tag_border = "" }
136
-
137
- # it 'removes not needed whitespaces from strong tags' do
138
- # input = "foo ** foobar ** bar"
139
- # result = cleaner.clean_tag_borders(input)
140
- # expect(result).to eq "foo **foobar** bar"
141
- # end
142
-
143
- # it 'remotes leading or trailing whitespaces independently' do
144
- # input = "1 **fat ** 2 ** fat** 3"
145
- # result = cleaner.clean_tag_borders(input)
146
- # expect(result).to eq "1 **fat** 2 **fat** 3"
147
- # end
148
-
149
- it "adds whitespaces if there are none" do
150
- input = "1**fat**2"
151
- result = cleaner.clean_tag_borders(input)
152
- expect(result).to eq "1**fat**2"
153
- end
154
-
155
- it "doesn't add whitespaces to underscore'ed elements if they are part of links" do
156
- input = "![im__age](sou__rce)"
157
- result = cleaner.clean_tag_borders(input)
158
- expect(result).to eq "![im__age](sou__rce)"
159
- end
160
-
161
- # it "still cleans up whitespaces that aren't inside a link" do
162
- # input = "now __italic __with following [under__scored](link)"
163
- # result = cleaner.clean_tag_borders(input)
164
- # expect(result).to eq "now __italic__with following [under__scored](link)"
165
- # end
166
-
167
- # it 'cleans italic stuff as well' do
168
- # input = "1 __italic __ 2 __ italic__ 3__italic __4"
169
- # result = cleaner.clean_tag_borders(input)
170
- # expect(result).to eq "1 __italic__ 2 __italic__ 3__italic__4"
171
- # end
172
-
173
- it "cleans strikethrough stuff as well" do
174
- input = "1 ~~italic ~~ 2 ~~ italic~~ 3~~italic ~~4"
175
- result = cleaner.clean_tag_borders(input)
176
- expect(result).to eq "1 ~~italic~~ 2 ~~italic~~ 3~~italic~~4"
177
- end
178
- end
179
- end
180
- end
@@ -1,25 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Config do
4
- describe "#with" do
5
- let(:config) { ReverseAdoc.config }
6
-
7
- it "takes additional options into account" do
8
- config.with(tag_border: :foobar) do
9
- expect(ReverseAdoc.config.tag_border).to eq :foobar
10
- end
11
- end
12
-
13
- it "returns the result of a given block" do
14
- expect(config.with { :something }).to eq :something
15
- end
16
-
17
- it "resets to original settings afterwards" do
18
- config.tag_border = :foo
19
- config.with(tag_border: :bar) do
20
- expect(ReverseAdoc.config.tag_border).to eq :bar
21
- end
22
- expect(ReverseAdoc.config.tag_border).to eq :foo
23
- end
24
- end
25
- end
@@ -1,11 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Aside do
4
- let(:converter) { ReverseAdoc::Converters::Aside.new }
5
-
6
- it "converts aside" do
7
- input = node_for("<aside><ul><li>foo</li></ul></aside>")
8
- result = converter.convert(input)
9
- expect(result).to eq "\n\n\*\*\*\*\n\n* foo\n\n\*\*\*\*\n\n"
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Audio do
4
- let(:converter) { ReverseAdoc::Converters::Audio.new }
5
-
6
- it "converts audio with no attributes" do
7
- node = node_for("<audio src='example.mp3'/>")
8
- expect(converter.convert(node)).to include "audio::example.mp3[]"
9
- end
10
-
11
- it "converts audio with full set of attributes" do
12
- node = node_for("<audio id='A' src='example.mp3' loop='loop'/>")
13
- expect(converter.convert(node)).to include "[[A]]\naudio::example.mp3[options=\"loop\"]"
14
- end
15
- end
@@ -1,23 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Blockquote do
4
- let(:converter) { ReverseAdoc::Converters::Blockquote.new }
5
-
6
- it "converts nested elements as well" do
7
- input = node_for("<blockquote><ul><li>foo</li></ul></blockquote>")
8
- result = converter.convert(input)
9
- expect(result).to eq "\n\n____\n* foo\n____\n\n"
10
- end
11
-
12
- it "can deal with paragraphs inside" do
13
- input = node_for("<blockquote><p>Some text.</p><p>Some more text.</p></blockquote>")
14
- result = converter.convert(input)
15
- expect(result).to eq "\n\n____\nSome text.\n\nSome more text.\n____\n\n"
16
- end
17
-
18
- it "can deal with cite attribute" do
19
- input = node_for("<blockquote cite='http://www.example.com'><p>Some text.</p><p>Some more text.</p></blockquote>")
20
- result = converter.convert(input)
21
- expect(result).to eq "\n\n[quote,http://www.example.com]\n____\nSome text.\n\nSome more text.\n____\n\n"
22
- end
23
- end
@@ -1,9 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Br do
4
- let(:converter) { ReverseAdoc::Converters::Br.new }
5
-
6
- it "just converts into two spaces and a newline" do
7
- expect(converter.convert(:anything)).to eq " \+\n"
8
- end
9
- end
@@ -1,15 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Code do
4
- let(:converter) { ReverseAdoc::Converters::Code.new }
5
-
6
- it "converts as backtick" do
7
- node = node_for("<code>puts foo</code>")
8
- expect(converter.convert(node)).to include "`puts foo`"
9
- end
10
-
11
- it "converts as backtick" do
12
- node = node_for("<tt>puts foo</tt>")
13
- expect(converter.convert(node)).to include "`puts foo`"
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Code do
4
- let(:converter) { ReverseAdoc::Converters::Div.new }
5
-
6
- it "converts div" do
7
- node = node_for("<div>puts foo</div>")
8
- expect(converter.convert(node)).to include "\nputs foo"
9
- end
10
-
11
- it "converts div with anchor" do
12
- node = node_for("<div id='A'>puts foo</div>")
13
- expect(converter.convert(node)).to include "\n[[A]]\nputs foo"
14
- end
15
- end
@@ -1,10 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Figure do
4
- let(:converter) { ReverseAdoc::Converters::Figure.new }
5
-
6
- it "converts figure" do
7
- node = node_for("<figure id='A'><img src='example.jpg'/><figcaption>Figure <i>caption</i></figcaption></figure>")
8
- expect(converter.convert(node)).to include "[[A]]\n.Figure _caption_\n====\nimage::example.jpg[]\n====\n"
9
- end
10
- end
@@ -1,25 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Img do
4
- let(:converter) { ReverseAdoc::Converters::Img.new }
5
-
6
- it "converts image with no attributes" do
7
- node = node_for("<img src='example.jpg'/>")
8
- expect(converter.convert(node)).to include "image::example.jpg[]"
9
- end
10
-
11
- it "converts image with full set of attributes" do
12
- node = node_for("<img id='A' alt='Alt Text' src='example.jpg' width='30' height='40'/>")
13
- expect(converter.convert(node)).to include "[[A]]\nimage::example.jpg[Alt Text,30,40]"
14
- end
15
-
16
- it "converts image with alt text, no width and height" do
17
- node = node_for("<img id='A' alt='Alt Text' src='example.jpg'/>")
18
- expect(converter.convert(node)).to include "[[A]]\nimage::example.jpg[Alt Text]"
19
- end
20
-
21
- it "converts image with width and height, no alt text" do
22
- node = node_for("<img id='A' src='example.jpg' width='30' height='40'/>")
23
- expect(converter.convert(node)).to include "[[A]]\nimage::example.jpg[\"\",30,40]"
24
- end
25
- end
@@ -1,11 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Li do
4
- let(:converter) { ReverseAdoc::Converters::Li.new }
5
-
6
- it "does not fail without a valid parent context" do
7
- input = node_for("<li>foo</li>")
8
- result = converter.convert(input)
9
- expect(result).to eq " foo\n"
10
- end
11
- end
@@ -1,10 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Mark do
4
- let(:converter) { ReverseAdoc::Converters::Mark.new }
5
-
6
- it "renders mark" do
7
- input = node_for("<mark>A</mark>")
8
- expect(converter.convert(input)).to eq "#A#"
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::P do
4
- let(:converter) { ReverseAdoc::Converters::P.new }
5
-
6
- it "converts p with anchor" do
7
- node = node_for("<p id='A'>puts foo</p>")
8
- expect(converter.convert(node)).to include "\n[[A]]\nputs foo"
9
- end
10
- end
@@ -1,43 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Pre do
4
- let(:converter) { ReverseAdoc::Converters::Pre.new }
5
-
6
- it "converts as literal" do
7
- node = node_for("<pre>puts foo</pre>")
8
- expect(converter.convert(node)).to include "....\nputs foo\n....\n"
9
- end
10
-
11
- it "converts as literal with anchor" do
12
- node = node_for("<pre id='A'>puts foo</pre>")
13
- expect(converter.convert(node)).to include "[[A]]\n....\nputs foo\n....\n"
14
- end
15
-
16
- it "preserves new lines" do
17
- node = node_for("<pre>foo\nbar</pre>")
18
- expect(converter.convert(node)).to include "....\nfoo\nbar\n....\n"
19
- end
20
-
21
- it "preserves xml" do
22
- node = node_for("<pre><code>x</code><br/><p>hello</p></pre>")
23
- expect(converter.convert(node)).to include "....\nx\n\n\nhello\n\n\n....\n"
24
- end
25
-
26
- context "syntax highlighting" do
27
- it 'works for "highlight-lang" mechanism' do
28
- div = node_for("<div class='highlight highlight-ruby'><pre>puts foo</pre></div>")
29
- pre = div.children.first
30
- expect(converter.convert(pre)).to include "[source,ruby]\n----\nputs foo\n----\n"
31
- end
32
-
33
- it "works for the confluence mechanism" do
34
- pre = node_for("<pre class='theme: Confluence; brush: html/xml; gutter: false'>puts foo</pre>")
35
- expect(converter.convert(pre)).to include "[source,html/xml]\n----\nputs foo\n----\n"
36
- end
37
-
38
- it "works for the confluence mechanism, with anchor" do
39
- pre = node_for("<pre id = 'A' class='theme: Confluence; brush: html/xml; gutter: false'>puts foo</pre>")
40
- expect(converter.convert(pre)).to include "[[A]]\n[source,html/xml]\n----\nputs foo\n----\n"
41
- end
42
- end
43
- end
@@ -1,10 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Q do
4
- let(:converter) { ReverseAdoc::Converters::Q.new }
5
-
6
- it "renders q" do
7
- input = node_for("<q>A</q>")
8
- expect(converter.convert(input)).to eq '"A"'
9
- end
10
- end
@@ -1,21 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ReverseAdoc::Converters::Strong do
4
- let(:converter) { ReverseAdoc::Converters::Strong.new }
5
-
6
- it "returns an empty string if the node is empty" do
7
- input = node_for("<strong></strong>")
8
- expect(converter.convert(input)).to eq ""
9
- end
10
-
11
- it "returns just the content if the strong tag is nested in another strong" do
12
- input = node_for("<strong><strong>foo</strong></strong>")
13
- expect(converter.convert(input.children.first,
14
- already_strong: true)).to eq "foo"
15
- end
16
-
17
- it "moves border whitespaces outside of the delimiters tag" do
18
- input = node_for("<strong> \n foo </strong>")
19
- expect(converter.convert(input)).to eq " *foo* "
20
- end
21
- end