reverse_asciidoctor 0.1.0

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.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +32 -0
  4. data/README.adoc +186 -0
  5. data/Rakefile +14 -0
  6. data/bin/reverse_asciidoctor +14 -0
  7. data/bin/w2m +31 -0
  8. data/lib/reverse_asciidoctor.rb +70 -0
  9. data/lib/reverse_asciidoctor/cleaner.rb +85 -0
  10. data/lib/reverse_asciidoctor/config.rb +28 -0
  11. data/lib/reverse_asciidoctor/converters.rb +33 -0
  12. data/lib/reverse_asciidoctor/converters/a.rb +38 -0
  13. data/lib/reverse_asciidoctor/converters/aside.rb +14 -0
  14. data/lib/reverse_asciidoctor/converters/audio.rb +34 -0
  15. data/lib/reverse_asciidoctor/converters/base.rb +24 -0
  16. data/lib/reverse_asciidoctor/converters/blockquote.rb +18 -0
  17. data/lib/reverse_asciidoctor/converters/br.rb +11 -0
  18. data/lib/reverse_asciidoctor/converters/bypass.rb +77 -0
  19. data/lib/reverse_asciidoctor/converters/code.rb +15 -0
  20. data/lib/reverse_asciidoctor/converters/div.rb +14 -0
  21. data/lib/reverse_asciidoctor/converters/drop.rb +18 -0
  22. data/lib/reverse_asciidoctor/converters/em.rb +18 -0
  23. data/lib/reverse_asciidoctor/converters/figure.rb +21 -0
  24. data/lib/reverse_asciidoctor/converters/h.rb +19 -0
  25. data/lib/reverse_asciidoctor/converters/head.rb +18 -0
  26. data/lib/reverse_asciidoctor/converters/hr.rb +11 -0
  27. data/lib/reverse_asciidoctor/converters/ignore.rb +12 -0
  28. data/lib/reverse_asciidoctor/converters/img.rb +23 -0
  29. data/lib/reverse_asciidoctor/converters/li.rb +24 -0
  30. data/lib/reverse_asciidoctor/converters/mark.rb +12 -0
  31. data/lib/reverse_asciidoctor/converters/math.rb +14 -0
  32. data/lib/reverse_asciidoctor/converters/ol.rb +46 -0
  33. data/lib/reverse_asciidoctor/converters/p.rb +17 -0
  34. data/lib/reverse_asciidoctor/converters/pass_through.rb +9 -0
  35. data/lib/reverse_asciidoctor/converters/pre.rb +38 -0
  36. data/lib/reverse_asciidoctor/converters/q.rb +12 -0
  37. data/lib/reverse_asciidoctor/converters/strong.rb +17 -0
  38. data/lib/reverse_asciidoctor/converters/sub.rb +12 -0
  39. data/lib/reverse_asciidoctor/converters/sup.rb +12 -0
  40. data/lib/reverse_asciidoctor/converters/table.rb +64 -0
  41. data/lib/reverse_asciidoctor/converters/td.rb +67 -0
  42. data/lib/reverse_asciidoctor/converters/text.rb +65 -0
  43. data/lib/reverse_asciidoctor/converters/th.rb +16 -0
  44. data/lib/reverse_asciidoctor/converters/tr.rb +22 -0
  45. data/lib/reverse_asciidoctor/converters/video.rb +36 -0
  46. data/lib/reverse_asciidoctor/errors.rb +10 -0
  47. data/lib/reverse_asciidoctor/version.rb +3 -0
  48. data/reverse_asciidoctor.gemspec +30 -0
  49. data/spec/assets/anchors.html +22 -0
  50. data/spec/assets/basic.html +58 -0
  51. data/spec/assets/code.html +22 -0
  52. data/spec/assets/escapables.html +15 -0
  53. data/spec/assets/from_the_wild.html +23 -0
  54. data/spec/assets/full_example.html +49 -0
  55. data/spec/assets/html_fragment.html +3 -0
  56. data/spec/assets/lists.html +137 -0
  57. data/spec/assets/minimum.html +4 -0
  58. data/spec/assets/paragraphs.html +24 -0
  59. data/spec/assets/quotation.html +12 -0
  60. data/spec/assets/tables.html +99 -0
  61. data/spec/assets/unknown_tags.html +9 -0
  62. data/spec/components/anchors_spec.rb +21 -0
  63. data/spec/components/basic_spec.rb +49 -0
  64. data/spec/components/code_spec.rb +28 -0
  65. data/spec/components/escapables_spec.rb +23 -0
  66. data/spec/components/from_the_wild_spec.rb +17 -0
  67. data/spec/components/html_fragment_spec.rb +11 -0
  68. data/spec/components/lists_spec.rb +86 -0
  69. data/spec/components/paragraphs_spec.rb +15 -0
  70. data/spec/components/quotation_spec.rb +12 -0
  71. data/spec/components/tables_spec.rb +31 -0
  72. data/spec/components/unknown_tags_spec.rb +39 -0
  73. data/spec/lib/reverse_asciidoctor/cleaner_spec.rb +157 -0
  74. data/spec/lib/reverse_asciidoctor/config_spec.rb +26 -0
  75. data/spec/lib/reverse_asciidoctor/converters/aside_spec.rb +12 -0
  76. data/spec/lib/reverse_asciidoctor/converters/audio_spec.rb +18 -0
  77. data/spec/lib/reverse_asciidoctor/converters/blockquote_spec.rb +24 -0
  78. data/spec/lib/reverse_asciidoctor/converters/br_spec.rb +9 -0
  79. data/spec/lib/reverse_asciidoctor/converters/code_spec.rb +18 -0
  80. data/spec/lib/reverse_asciidoctor/converters/div_spec.rb +18 -0
  81. data/spec/lib/reverse_asciidoctor/converters/figure_spec.rb +13 -0
  82. data/spec/lib/reverse_asciidoctor/converters/img_spec.rb +28 -0
  83. data/spec/lib/reverse_asciidoctor/converters/li_spec.rb +13 -0
  84. data/spec/lib/reverse_asciidoctor/converters/mark_spec.rb +10 -0
  85. data/spec/lib/reverse_asciidoctor/converters/p_spec.rb +12 -0
  86. data/spec/lib/reverse_asciidoctor/converters/pre_spec.rb +45 -0
  87. data/spec/lib/reverse_asciidoctor/converters/q_spec.rb +10 -0
  88. data/spec/lib/reverse_asciidoctor/converters/strong_spec.rb +20 -0
  89. data/spec/lib/reverse_asciidoctor/converters/text_spec.rb +62 -0
  90. data/spec/lib/reverse_asciidoctor/converters/video_spec.rb +18 -0
  91. data/spec/lib/reverse_asciidoctor/converters_spec.rb +19 -0
  92. data/spec/lib/reverse_asciidoctor_spec.rb +37 -0
  93. data/spec/spec_helper.rb +21 -0
  94. metadata +281 -0
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor do
4
+
5
+ let(:input) { File.read('spec/assets/unknown_tags.html') }
6
+ let(:document) { Nokogiri::HTML(input) }
7
+ let(:result) { ReverseAsciidoctor.convert(input) }
8
+
9
+ context 'with unknown_tags = :pass_through' do
10
+ before { ReverseAsciidoctor.config.unknown_tags = :pass_through }
11
+
12
+ it { expect(result).to include "<bar>Foo with bar</bar>" }
13
+ end
14
+
15
+ context 'with unknown_tags = :raise' do
16
+ before { ReverseAsciidoctor.config.unknown_tags = :raise }
17
+
18
+ it { expect { result }.to raise_error(ReverseAsciidoctor::UnknownTagError) }
19
+ end
20
+
21
+ context 'with unknown_tags = :drop' do
22
+ before { ReverseAsciidoctor.config.unknown_tags = :drop }
23
+
24
+ it { expect(result).to eq '' }
25
+ end
26
+
27
+ context 'with unknown_tags = :bypass' do
28
+ before { ReverseAsciidoctor.config.unknown_tags = :bypass }
29
+
30
+ it { expect(result).to eq "Foo with bar\n\n" }
31
+ end
32
+
33
+ context 'with unknown_tags = :something_wrong' do
34
+ before { ReverseAsciidoctor.config.unknown_tags = :something_wrong }
35
+
36
+ it { expect { result }.to raise_error(ReverseAsciidoctor::InvalidConfigurationError) }
37
+ end
38
+ end
39
+
@@ -0,0 +1,157 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Cleaner do
4
+ let(:cleaner) { ReverseAsciidoctor::Cleaner.new }
5
+
6
+ describe '#remove_newlines' do
7
+ it 'removes more than 2 subsequent newlines' do
8
+ result = cleaner.remove_newlines("foo\n\n\nbar")
9
+ expect(result).to eq "foo\n\nbar"
10
+ end
11
+
12
+ it 'skips single and double newlines' do
13
+ result = cleaner.remove_newlines("foo\nbar\n\nbaz")
14
+ expect(result).to eq "foo\nbar\n\nbaz"
15
+ end
16
+ end
17
+
18
+ describe '#remove_inner_whitespaces' do
19
+ it 'removes duplicate whitespaces from the string' do
20
+ result = cleaner.remove_inner_whitespaces('foo bar')
21
+ expect(result).to eq "foo bar"
22
+ end
23
+
24
+ it 'performs changes for multiple lines' do
25
+ result = cleaner.remove_inner_whitespaces("foo bar\nbar foo")
26
+ expect(result).to eq "foo bar\nbar foo"
27
+ end
28
+
29
+ it 'keeps leading whitespaces' do
30
+ result = cleaner.remove_inner_whitespaces(" foo bar\n bar foo")
31
+ expect(result).to eq " foo bar\n bar foo"
32
+ end
33
+
34
+ it 'keeps trailing whitespaces' do
35
+ result = cleaner.remove_inner_whitespaces("foo \n")
36
+ expect(result).to eq "foo \n"
37
+ end
38
+
39
+ it 'keeps trailing newlines' do
40
+ result = cleaner.remove_inner_whitespaces("foo\n")
41
+ expect(result).to eq "foo\n"
42
+ end
43
+
44
+ it 'removes tabs as well' do
45
+ result = cleaner.remove_inner_whitespaces("foo\t \tbar")
46
+ expect(result).to eq "foo bar"
47
+ end
48
+
49
+ it 'keeps lines that only contain whitespace' do
50
+ result = cleaner.remove_inner_whitespaces("foo \nbar \n \n \nfoo")
51
+ expect(result).to eq "foo \nbar \n \n \nfoo"
52
+ end
53
+ end
54
+
55
+ describe '#clean_punctuation_characters' do
56
+ it 'removes whitespace between tag end and punctuation characters' do
57
+ input = "**fat** . ~~strike~~ ? __italic__ ! "
58
+ result = cleaner.clean_punctuation_characters(input)
59
+ expect(result).to eq "**fat**. ~~strike~~? __italic__! "
60
+ end
61
+ end
62
+
63
+ describe '#clean_tag_borders' do
64
+ context 'with default_border is set to space' do
65
+ before { ReverseAsciidoctor.config.tag_border = ' ' }
66
+
67
+ it 'removes not needed whitespaces from strong tags' do
68
+ input = "foo ** foobar ** bar"
69
+ result = cleaner.clean_tag_borders(input)
70
+ expect(result).to eq "foo **foobar** bar"
71
+ end
72
+
73
+ it 'remotes leading or trailing whitespaces independently' do
74
+ input = "1 **fat ** 2 ** fat** 3"
75
+ result = cleaner.clean_tag_borders(input)
76
+ expect(result).to eq "1 **fat** 2 **fat** 3"
77
+ end
78
+
79
+ it 'adds whitespaces if there are none' do
80
+ input = "1**fat**2"
81
+ result = cleaner.clean_tag_borders(input)
82
+ expect(result).to eq "1 **fat** 2"
83
+ end
84
+
85
+ it "doesn't add whitespaces to underscore'ed elements if they are part of links" do
86
+ input = "![im__age](sou__rce)"
87
+ result = cleaner.clean_tag_borders(input)
88
+ expect(result).to eq "![im__age](sou__rce)"
89
+ end
90
+
91
+ it "still cleans up whitespaces that aren't inside a link" do
92
+ input = "now __italic __with following [under__scored](link)"
93
+ result = cleaner.clean_tag_borders(input)
94
+ expect(result).to eq "now __italic__ with following [under__scored](link)"
95
+ end
96
+
97
+ it 'cleans italic stuff as well' do
98
+ input = "1 __italic __ 2 __ italic__ 3__italic __4"
99
+ result = cleaner.clean_tag_borders(input)
100
+ expect(result).to eq "1 __italic__ 2 __italic__ 3 __italic__ 4"
101
+ end
102
+
103
+ it 'cleans strikethrough stuff as well' do
104
+ input = "1 ~~italic ~~ 2 ~~ italic~~ 3~~italic ~~4"
105
+ result = cleaner.clean_tag_borders(input)
106
+ expect(result).to eq "1 ~~italic~~ 2 ~~italic~~ 3 ~~italic~~ 4"
107
+ end
108
+ end
109
+
110
+ context 'with default_border set to no space' do
111
+ before { ReverseAsciidoctor.config.tag_border = '' }
112
+
113
+ it 'removes not needed whitespaces from strong tags' do
114
+ input = "foo ** foobar ** bar"
115
+ result = cleaner.clean_tag_borders(input)
116
+ expect(result).to eq "foo **foobar** bar"
117
+ end
118
+
119
+ it 'remotes leading or trailing whitespaces independently' do
120
+ input = "1 **fat ** 2 ** fat** 3"
121
+ result = cleaner.clean_tag_borders(input)
122
+ expect(result).to eq "1 **fat** 2 **fat** 3"
123
+ end
124
+
125
+ it 'adds whitespaces if there are none' do
126
+ input = "1**fat**2"
127
+ result = cleaner.clean_tag_borders(input)
128
+ expect(result).to eq "1**fat**2"
129
+ end
130
+
131
+ it "doesn't add whitespaces to underscore'ed elements if they are part of links" do
132
+ input = "![im__age](sou__rce)"
133
+ result = cleaner.clean_tag_borders(input)
134
+ expect(result).to eq "![im__age](sou__rce)"
135
+ end
136
+
137
+ it "still cleans up whitespaces that aren't inside a link" do
138
+ input = "now __italic __with following [under__scored](link)"
139
+ result = cleaner.clean_tag_borders(input)
140
+ expect(result).to eq "now __italic__with following [under__scored](link)"
141
+ end
142
+
143
+ it 'cleans italic stuff as well' do
144
+ input = "1 __italic __ 2 __ italic__ 3__italic __4"
145
+ result = cleaner.clean_tag_borders(input)
146
+ expect(result).to eq "1 __italic__ 2 __italic__ 3__italic__4"
147
+ end
148
+
149
+ it 'cleans strikethrough stuff as well' do
150
+ input = "1 ~~italic ~~ 2 ~~ italic~~ 3~~italic ~~4"
151
+ result = cleaner.clean_tag_borders(input)
152
+ expect(result).to eq "1 ~~italic~~ 2 ~~italic~~ 3~~italic~~4"
153
+ end
154
+ end
155
+ end
156
+
157
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Config do
4
+ describe '#with' do
5
+ let(:config) { ReverseAsciidoctor.config }
6
+
7
+ it 'takes additional options into account' do
8
+ config.with(tag_border: :foobar) do
9
+ expect(ReverseAsciidoctor.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(ReverseAsciidoctor.config.tag_border).to eq :bar
21
+ end
22
+ expect(ReverseAsciidoctor.config.tag_border).to eq :foo
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Converters::Aside do
4
+
5
+ let(:converter) { ReverseAsciidoctor::Converters::Aside.new }
6
+
7
+ it 'converts aside' do
8
+ input = node_for("<aside><ul><li>foo</li></ul></aside>")
9
+ result = converter.convert(input)
10
+ expect(result).to eq "\n\n\*\*\*\*\n\n* foo\n\n\*\*\*\*\n\n"
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Converters::Audio do
4
+
5
+ let(:converter) { ReverseAsciidoctor::Converters::Audio.new }
6
+
7
+ it 'converts audio with no attributes' do
8
+ node = node_for("<audio src='example.mp3'/>")
9
+ expect(converter.convert(node)).to include "audio::example.mp3[]"
10
+ end
11
+
12
+ it 'converts audio with full set of attributes' do
13
+ node = node_for("<audio id='A' src='example.mp3' loop='loop'/>")
14
+ expect(converter.convert(node)).to include "[[A]]\naudio::example.mp3[options=\"loop\"]"
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Converters::Blockquote do
4
+
5
+ let(:converter) { ReverseAsciidoctor::Converters::Blockquote.new }
6
+
7
+ it 'converts nested elements as well' do
8
+ input = node_for("<blockquote><ul><li>foo</li></ul></blockquote>")
9
+ result = converter.convert(input)
10
+ expect(result).to eq "\n\n____\n* foo\n____\n\n"
11
+ end
12
+
13
+ it 'can deal with paragraphs inside' do
14
+ input = node_for("<blockquote><p>Some text.</p><p>Some more text.</p></blockquote>")
15
+ result = converter.convert(input)
16
+ expect(result).to eq "\n\n____\nSome text.\n\nSome more text.\n____\n\n"
17
+ end
18
+
19
+ it 'can deal with cite attribute' do
20
+ input = node_for("<blockquote cite='http://www.example.com'><p>Some text.</p><p>Some more text.</p></blockquote>")
21
+ result = converter.convert(input)
22
+ expect(result).to eq "\n\n[quote, http://www.example.com]\n____\nSome text.\n\nSome more text.\n____\n\n"
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Converters::Br do
4
+ let(:converter) { ReverseAsciidoctor::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
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Converters::Code do
4
+
5
+ let(:converter) { ReverseAsciidoctor::Converters::Code.new }
6
+
7
+ it 'converts as backtick' do
8
+ node = node_for("<code>puts foo</code>")
9
+ expect(converter.convert(node)).to include "`puts foo`"
10
+ end
11
+
12
+ it 'converts as backtick' do
13
+ node = node_for("<tt>puts foo</tt>")
14
+ expect(converter.convert(node)).to include "`puts foo`"
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Converters::Code do
4
+
5
+ let(:converter) { ReverseAsciidoctor::Converters::Div.new }
6
+
7
+ it 'converts div' do
8
+ node = node_for("<div>puts foo</div>")
9
+ expect(converter.convert(node)).to include "\nputs foo"
10
+ end
11
+
12
+ it 'converts div with anchor' do
13
+ node = node_for("<div id='A'>puts foo</div>")
14
+ expect(converter.convert(node)).to include "\n[[A]]\nputs foo"
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Converters::Figure do
4
+
5
+ let(:converter) { ReverseAsciidoctor::Converters::Figure.new }
6
+
7
+ it 'converts figure' do
8
+ node = node_for("<figure id='A'><img src='example.jpg'/><figcaption>Figure <i>caption</i></figcaption></figure>")
9
+ expect(converter.convert(node)).to include "[[A]]\n.Figure _caption_\n====\nimage::example.jpg[]\n====\n"
10
+
11
+ end
12
+ end
13
+
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Converters::Img do
4
+
5
+ let(:converter) { ReverseAsciidoctor::Converters::Img.new }
6
+
7
+ it 'converts image with no attributes' do
8
+ node = node_for("<img src='example.jpg'/>")
9
+ expect(converter.convert(node)).to include "image::example.jpg[]"
10
+ end
11
+
12
+ it 'converts image with full set of attributes' do
13
+ node = node_for("<img id='A' alt='Alt Text' src='example.jpg' width='30' height='40'/>")
14
+ expect(converter.convert(node)).to include "[[A]]\nimage::example.jpg[Alt Text,30,40]"
15
+ end
16
+
17
+ it 'converts image with alt text, no width and height' do
18
+ node = node_for("<img id='A' alt='Alt Text' src='example.jpg'/>")
19
+ expect(converter.convert(node)).to include "[[A]]\nimage::example.jpg[Alt Text]"
20
+ end
21
+
22
+ it 'converts image with width and height, no alt text' do
23
+ node = node_for("<img id='A' src='example.jpg' width='30' height='40'/>")
24
+ expect(converter.convert(node)).to include "[[A]]\nimage::example.jpg[\"\",30,40]"
25
+ end
26
+
27
+ end
28
+
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Converters::Li do
4
+
5
+ let(:converter) { ReverseAsciidoctor::Converters::Li.new }
6
+
7
+ it 'does not fail without a valid parent context' do
8
+ input = node_for("<li>foo</li>")
9
+ result = converter.convert(input)
10
+ expect(result).to eq " foo\n"
11
+ end
12
+
13
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Converters::Mark do
4
+ let(:converter) { ReverseAsciidoctor::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
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Converters::P do
4
+
5
+ let(:converter) { ReverseAsciidoctor::Converters::P.new }
6
+
7
+ it 'converts p with anchor' do
8
+ node = node_for("<p id='A'>puts foo</p>")
9
+ expect(converter.convert(node)).to include "\n[[A]]\nputs foo"
10
+ end
11
+ end
12
+
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseAsciidoctor::Converters::Pre do
4
+
5
+ let(:converter) { ReverseAsciidoctor::Converters::Pre.new }
6
+
7
+ it 'converts as literal' do
8
+ node = node_for("<pre>puts foo</pre>")
9
+ expect(converter.convert(node)).to include "....\nputs foo\n....\n"
10
+ end
11
+
12
+ it 'converts as literal with anchor' do
13
+ node = node_for("<pre id='A'>puts foo</pre>")
14
+ expect(converter.convert(node)).to include "[[A]]\n....\nputs foo\n....\n"
15
+ end
16
+
17
+ it 'preserves new lines' do
18
+ node = node_for("<pre>foo\nbar</pre>")
19
+ expect(converter.convert(node)).to include "....\nfoo\nbar\n....\n"
20
+ end
21
+
22
+ it 'preserves xml' do
23
+ node = node_for("<pre><code>x</code><br/><p>hello</p></pre>")
24
+ expect(converter.convert(node)).to include "....\n<code>x</code><br><p>hello</p>\n....\n"
25
+ end
26
+
27
+ context 'syntax highlighting' do
28
+ it 'works for "highlight-lang" mechanism' do
29
+ div = node_for("<div class='highlight highlight-ruby'><pre>puts foo</pre></div>")
30
+ pre = div.children.first
31
+ expect(converter.convert(pre)).to include "[source,ruby]\n----\nputs foo\n----\n"
32
+ end
33
+
34
+ it 'works for the confluence mechanism' do
35
+ pre = node_for("<pre class='theme: Confluence; brush: html/xml; gutter: false'>puts foo</pre>")
36
+ expect(converter.convert(pre)).to include "[source,html/xml]\n----\nputs foo\n----\n"
37
+ end
38
+
39
+ it 'works for the confluence mechanism, with anchor' do
40
+ pre = node_for("<pre id = 'A' class='theme: Confluence; brush: html/xml; gutter: false'>puts foo</pre>")
41
+ expect(converter.convert(pre)).to include "[[A]]\n[source,html/xml]\n----\nputs foo\n----\n"
42
+ end
43
+ end
44
+ end
45
+