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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +19 -5
  3. data/.github/workflows/ubuntu.yml +18 -5
  4. data/.github/workflows/windows.yml +20 -6
  5. data/Gemfile +2 -2
  6. data/Gemfile.lock +85 -0
  7. data/README.adoc +12 -25
  8. data/Rakefile +1 -1
  9. data/bin/reverse_adoc +20 -17
  10. data/bin/w2a +18 -31
  11. data/lib/reverse_adoc.rb +27 -0
  12. data/lib/{reverse_asciidoctor → reverse_adoc}/cleaner.rb +27 -4
  13. data/lib/{reverse_asciidoctor → reverse_adoc}/config.rb +3 -2
  14. data/lib/{reverse_asciidoctor → reverse_adoc}/converters.rb +6 -6
  15. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/a.rb +1 -1
  16. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/aside.rb +1 -1
  17. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/audio.rb +1 -1
  18. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/base.rb +2 -2
  19. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/blockquote.rb +2 -2
  20. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/br.rb +1 -1
  21. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/bypass.rb +1 -1
  22. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/code.rb +1 -1
  23. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/div.rb +1 -1
  24. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/drop.rb +1 -1
  25. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/em.rb +1 -1
  26. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/figure.rb +1 -1
  27. data/lib/reverse_adoc/converters/h.rb +34 -0
  28. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/head.rb +1 -1
  29. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/hr.rb +1 -1
  30. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/ignore.rb +1 -1
  31. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/img.rb +27 -29
  32. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/li.rb +1 -1
  33. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/mark.rb +1 -1
  34. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/math.rb +3 -3
  35. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/ol.rb +1 -1
  36. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/p.rb +1 -1
  37. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/pass_through.rb +1 -1
  38. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/pre.rb +1 -1
  39. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/q.rb +1 -1
  40. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/strong.rb +1 -1
  41. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/sub.rb +1 -1
  42. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/sup.rb +1 -1
  43. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/table.rb +1 -1
  44. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/td.rb +1 -1
  45. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/text.rb +1 -1
  46. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/th.rb +1 -1
  47. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/tr.rb +1 -1
  48. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/video.rb +1 -1
  49. data/lib/{reverse_asciidoctor → reverse_adoc}/errors.rb +1 -1
  50. data/lib/reverse_adoc/html_converter.rb +56 -0
  51. data/lib/reverse_adoc/version.rb +3 -0
  52. data/reverse_adoc.gemspec +4 -2
  53. data/spec/assets/anchors.html +2 -0
  54. data/spec/assets/external_images.docx +0 -0
  55. data/spec/assets/external_images.html +35 -0
  56. data/spec/bin/reverse_adoc_spec.rb +32 -0
  57. data/spec/bin/w2a_spec.rb +35 -0
  58. data/spec/components/anchors_spec.rb +3 -2
  59. data/spec/components/basic_spec.rb +2 -2
  60. data/spec/components/code_spec.rb +4 -4
  61. data/spec/components/escapables_spec.rb +2 -2
  62. data/spec/components/from_the_wild_spec.rb +2 -2
  63. data/spec/components/html_fragment_spec.rb +2 -2
  64. data/spec/components/lists_spec.rb +2 -2
  65. data/spec/components/paragraphs_spec.rb +2 -2
  66. data/spec/components/quotation_spec.rb +2 -2
  67. data/spec/components/tables_spec.rb +2 -2
  68. data/spec/components/unknown_tags_spec.rb +9 -9
  69. data/spec/lib/reverse_adoc.rb +90 -0
  70. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/cleaner_spec.rb +28 -4
  71. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/config_spec.rb +5 -5
  72. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/aside_spec.rb +2 -2
  73. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/audio_spec.rb +2 -2
  74. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/blockquote_spec.rb +2 -2
  75. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/br_spec.rb +2 -2
  76. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/code_spec.rb +2 -2
  77. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/div_spec.rb +2 -2
  78. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/figure_spec.rb +2 -2
  79. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/img_spec.rb +2 -2
  80. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/li_spec.rb +2 -2
  81. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/mark_spec.rb +2 -2
  82. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/p_spec.rb +2 -2
  83. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/pre_spec.rb +2 -2
  84. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/q_spec.rb +2 -2
  85. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/strong_spec.rb +2 -2
  86. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/text_spec.rb +2 -2
  87. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/video_spec.rb +2 -2
  88. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters_spec.rb +5 -5
  89. data/spec/spec_helper.rb +7 -2
  90. data/spec/support/shell_helpers.rb +15 -0
  91. metadata +126 -87
  92. data/lib/reverse_asciidoctor.rb +0 -70
  93. data/lib/reverse_asciidoctor/converters/h.rb +0 -19
  94. data/lib/reverse_asciidoctor/version.rb +0 -3
  95. data/spec/lib/reverse_asciidoctor_spec.rb +0 -37
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Strong < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Sub < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Sup < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Table < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Td < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Text < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Th < Td
4
4
  def cellstyle(node)
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Tr < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Video < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  class Error < StandardError
3
3
  end
4
4
 
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'reverse_adoc/converters/a'
4
+ require 'reverse_adoc/converters/aside'
5
+ require 'reverse_adoc/converters/audio'
6
+ require 'reverse_adoc/converters/blockquote'
7
+ require 'reverse_adoc/converters/br'
8
+ require 'reverse_adoc/converters/bypass'
9
+ require 'reverse_adoc/converters/code'
10
+ require 'reverse_adoc/converters/div'
11
+ require 'reverse_adoc/converters/drop'
12
+ require 'reverse_adoc/converters/em'
13
+ require 'reverse_adoc/converters/figure'
14
+ require 'reverse_adoc/converters/h'
15
+ require 'reverse_adoc/converters/head'
16
+ require 'reverse_adoc/converters/hr'
17
+ require 'reverse_adoc/converters/ignore'
18
+ require 'reverse_adoc/converters/img'
19
+ require 'reverse_adoc/converters/mark'
20
+ require 'reverse_adoc/converters/li'
21
+ require 'reverse_adoc/converters/ol'
22
+ require 'reverse_adoc/converters/p'
23
+ require 'reverse_adoc/converters/pass_through'
24
+ require 'reverse_adoc/converters/pre'
25
+ require 'reverse_adoc/converters/q'
26
+ require 'reverse_adoc/converters/strong'
27
+ require 'reverse_adoc/converters/sup'
28
+ require 'reverse_adoc/converters/sub'
29
+ require 'reverse_adoc/converters/table'
30
+ require 'reverse_adoc/converters/td'
31
+ require 'reverse_adoc/converters/th'
32
+ require 'reverse_adoc/converters/text'
33
+ require 'reverse_adoc/converters/tr'
34
+ require 'reverse_adoc/converters/video'
35
+ require 'reverse_adoc/converters/math'
36
+
37
+ module ReverseAdoc
38
+ class HtmlConverter
39
+ def self.convert(input, options = {})
40
+ root = if input.is_a?(String)
41
+ then Nokogiri::HTML(input).root
42
+ elsif input.is_a?(Nokogiri::XML::Document)
43
+ then input.root
44
+ elsif input.is_a?(Nokogiri::XML::Node)
45
+ then input
46
+ end
47
+
48
+ root || (return '')
49
+
50
+ ReverseAdoc.config.with(options) do
51
+ result = ReverseAdoc::Converters.lookup(root.name).convert(root)
52
+ ReverseAdoc.cleaner.tidy(result)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,3 @@
1
+ module ReverseAdoc
2
+ VERSION = '0.2.10'
3
+ end
@@ -1,10 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "reverse_asciidoctor/version"
3
+ require "reverse_adoc/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "reverse_adoc"
7
- s.version = ReverseAsciidoctor::VERSION
7
+ s.version = ReverseAdoc::VERSION
8
8
  s.authors = ["Ribose Inc."]
9
9
  s.email = ["open.source@ribose.com"]
10
10
 
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  # specify any dependencies here; for example:
23
23
  s.add_dependency 'nokogiri', ">= 1.10.4"
24
24
  s.add_dependency 'mathml2asciimath'
25
+ s.add_dependency 'mimemagic'
25
26
  s.add_development_dependency 'rspec'
26
27
  s.add_development_dependency 'simplecov'
27
28
  s.add_development_dependency 'rake'
@@ -32,4 +33,5 @@ Gem::Specification.new do |s|
32
33
 
33
34
  # All the following are for bin/w2m
34
35
  s.add_dependency 'word-to-markdown'
36
+ s.add_dependency 'premailer', '~> 1.11.0'
35
37
  end
@@ -24,5 +24,7 @@
24
24
  <img alt="foobar image" src="http://foobar.com/foobar.png">
25
25
  <img alt="foobar image 2" title="this is the foobar image 2" src="http://foobar.com/foobar2.png">
26
26
  some text...
27
+
28
+ <h1><a id="a__Foreword"></a>Text</h1>
27
29
  </body>
28
30
  </html>
@@ -0,0 +1,35 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">
2
+ <?xml version="1.0" encoding="UTF-8"??><html xmlns="http://www.w3.org/1999/xhtml" style="margin: 0;">
3
+ <!--This file was converted to xhtml by LibreOffice - see http://cgit.freedesktop.org/libreoffice/core/tree/filter/source/xslt for the code.--><head profile="http://dublincore.org/documents/dcmi-terms/">
4
+ <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8">
5
+ <meta name="DCTERMS.title" content="" xml:lang="en-US">
6
+ <meta name="DCTERMS.language" content="en-US" scheme="DCTERMS.RFC4646">
7
+ <meta name="DCTERMS.source" content="http://xml.openoffice.org/odf2xhtml">
8
+ <meta name="DCTERMS.creator" content="Nick Nicholas">
9
+ <meta name="DCTERMS.issued" content="2019-11-21T08:48:00" scheme="DCTERMS.W3CDTF">
10
+ <meta name="DCTERMS.contributor" content="Nick Nicholas">
11
+ <meta name="DCTERMS.modified" content="2019-11-21T10:01:00" scheme="DCTERMS.W3CDTF">
12
+ <meta name="DCTERMS.provenance" content="" xml:lang="en-US">
13
+ <meta name="DCTERMS.subject" content="," xml:lang="en-US">
14
+ <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" hreflang="en">
15
+ <link rel="schema.DCTERMS" href="http://purl.org/dc/terms/" hreflang="en">
16
+ <link rel="schema.DCTYPE" href="http://purl.org/dc/dcmitype/" hreflang="en">
17
+ <link rel="schema.DCAM" href="http://purl.org/dc/dcam/" hreflang="en">
18
+ </head>
19
+ <body dir="ltr" style="max-width: 21.001cm; margin: 2.54cm 3.175cm;">
20
+ <h1 class="P3" style="clear: both; color: #2f5496; font-size: 16pt; font-family: Calibri Light; writing-mode: lr-tb; margin: 0.423cm 0 0cm;" align="left ! important">
21
+ <a id="a__Hello" style="margin: 0;"><span style="margin: 0;"></span></a><span class="T1" style="margin: 0;">Hello</span>
22
+ </h1>
23
+ <p class="P1" style="font-size: 12pt; font-family: Calibri; writing-mode: lr-tb; margin: 0;" align="left ! important"> </p>
24
+ <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="T3" style="vertical-align: super; font-size: 58%; margin: 0;">2</h1><span class="T1" style="margin: 0;">0</span></p>
25
+ <p class="P1" style="font-size: 12pt; font-family: Calibri; writing-mode: lr-tb; margin: 0;" align="left ! important"> </p>
26
+ <!--Next 'div' was a 'text:p'.--><div class="Standard" style="font-size: 12pt; font-family: Calibri; writing-mode: lr-tb; margin: 0;" align="left ! important">
27
+ <!--Next ' span' is a draw:frame. --><span style="margin: 0;"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block" style="margin: 0;"><mrow style="margin: 0;"><mrow style="margin: 0;"><mrow style="margin: 0;"></mrow><mrow style="margin: 0;"><mi style="margin: 0;">i</mi><mo stretchy="false" style="margin: 0;">=</mo><mn style="margin: 0;">1</mn></mrow></mrow><mrow style="margin: 0;"><mrow style="margin: 0;"></mrow><mi style="margin: 0;">n</mi><msubsup style="margin: 0;"><mi style="margin: 0;">β</mi><mn style="margin: 0;">2</mn><mi style="margin: 0;">i</mi></msubsup></mrow></mrow></math></span>
28
+ </div>
29
+ <div style="clear: both; line-height: 0; width: 0; height: 0; margin: 0; padding: 0;"> </div>
30
+ <!--Next 'div' was a 'text:p'.--><div class="Standard" style="font-size: 12pt; font-family: Calibri; writing-mode: lr-tb; margin: 0;" align="left ! important">
31
+ <a id="_GoBack" style="margin: 0;"></a><!--Next ' span' is a draw:frame. --><span style="height: 1.764cm; margin: 0cm; padding: 0; border: none; width: 1.764cm; font-size: 12pt; font-family: Calibri; text-align: center; vertical-align: top; background-color: transparent;" class="fr1" id="Εικόνα_2"><img style="height: 1.764cm; width: 1.764cm; margin: 0;" alt="" src="data:image/gif;base64,R0lGODlhZABkAIAAAAAAAP///ywAAAAAZABkAEAC+4yPqcvtD6OctNqLs968XwCGokd24kidYckuKri9cFvKQCzTdG7x+u+y+YDECqqIzByTzKbzCY1Kp9Sq9eoQKrTY1Ev57TJsuLA4Meylz8HTxMz2LOPFOR1ov+v3/L7/DxgoOEj4IcRVeLA2Bue3CEHGF2nYyDaJcWn5+LZ5lamm0tf5MHpWilYJ6INymmiQ52q0EqsBSythews5qwt60wscLDxMXGx8jJysvMzc7PwM7XmYWzh9SPuJmuq43Raq2ooQbpUdMT5Vbn4ela7+fdfu/h4Xv9stfS/vBr+uPa+Zz94/gPvADCRY0FdCfgdxBezSr1+Vh+Iaclu4KoSiKGsSL9YTRu1YSGMji5UkdnJYSpC8nq0M9hJYzF4zo9m8iTOnzigFAAAh/tNUaGlzIGZpbGUgd2FzIGNyZWF0ZWQgYnkNDUdyYXBoaWMgV29ya3Nob3CZIFByb2Zlc3Npb25hbCAyLjBhDQ1mcm9tIEFsY2hlbXkgTWluZHdvcmtzIEluYy4NaHR0cDovL3d3dy5taW5kd29ya3Nob3AuY29tDQ1UaGlzIGltYWdlIG1heSBoYXZlIGJlZW4gY3JlYXRlZCBieQ1hIHBhcnR5IG90aGVyIHRoYW4gQWxjaGVteSBNaW5kd29ya3MgSW5jLg0NVXNlIG5vIGhvb2tzADs="></span>
32
+ </div>
33
+ <div style="clear: both; line-height: 0; width: 0; height: 0; margin: 0; padding: 0;"> </div>
34
+ </body>
35
+ </html>
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'bin/revrse_adoc' do
6
+ subject(:convert) do
7
+ ShellUtils.execute!("./bin/reverse_adoc -e -o test1 #{input_file_path}")
8
+ end
9
+ unless Gem.win_platform?
10
+ context 'when external images present' do
11
+ let(:input_file_path) { 'spec/assets/external_images.html' }
12
+ let(:images_folder) { 'images' }
13
+
14
+ after do
15
+ FileUtils.rm_rf(images_folder) if File.directory?(images_folder)
16
+ end
17
+
18
+ it 'Does not raise error' do
19
+ expect { convert }.to_not raise_error
20
+ end
21
+
22
+ it 'exatracts images from source html' do
23
+ expect { convert }
24
+ .to(change do
25
+ Dir["#{images_folder}/*gif"]
26
+ .map { |entry| File.basename(entry) }
27
+ .sort
28
+ end.from([]).to(['001.gif']))
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'bin/w2a' do
6
+ subject(:convert) do
7
+ ShellUtils.execute!("./bin/w2a -e -o test1 #{input_file_path}")
8
+ end
9
+ # TODO: fix github actions integration with libreoffice, currently it hangs
10
+ # when trying to use soffice binary
11
+ unless Gem.win_platform? ||
12
+ (Gem::Platform.local.os == 'darwin' && !ENV['GITHUB_ACTION'].nil?)
13
+ context 'when external images present' do
14
+ let(:input_file_path) { 'spec/assets/external_images.docx' }
15
+ let(:images_folder) { 'images' }
16
+
17
+ after do
18
+ FileUtils.rm_rf(images_folder) if File.directory?(images_folder)
19
+ end
20
+
21
+ it 'Does not raise error' do
22
+ expect { convert }.to_not raise_error
23
+ end
24
+
25
+ it 'exatracts images from source html' do
26
+ expect { convert }
27
+ .to(change do
28
+ Dir["#{images_folder}/*gif"]
29
+ .map { |entry| File.basename(entry) }
30
+ .sort
31
+ end.from([]).to(['001.gif', '002.gif']))
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ReverseAsciidoctor do
3
+ describe ReverseAdoc do
4
4
 
5
5
  let(:input) { File.read('spec/assets/anchors.html') }
6
6
  let(:document) { Nokogiri::HTML(input) }
7
- subject { ReverseAsciidoctor.convert(input) }
7
+ subject { ReverseAdoc.convert(input) }
8
8
 
9
9
  it { is_expected.to include 'http://foobar.com[Foobar]' }
10
10
  it { is_expected.to include 'http://foobar.com[Fubar]' }
@@ -20,6 +20,7 @@ describe ReverseAsciidoctor do
20
20
 
21
21
  it { is_expected.to include "<<a_bspaced,Double \\_\\_ anchor with space>>" }
22
22
  it { is_expected.to include "[[a_bspaced]]" }
23
+ it { is_expected.to include "[[a_Foreword]]\n== Text" }
23
24
  it { is_expected.not_to include "[[_Toc12345]]" }
24
25
 
25
26
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ReverseAsciidoctor do
3
+ describe ReverseAdoc do
4
4
 
5
5
  let(:input) { File.read('spec/assets/basic.html') }
6
6
  let(:document) { Nokogiri::HTML(input) }
7
- subject { ReverseAsciidoctor.convert(input) }
7
+ subject { ReverseAdoc.convert(input) }
8
8
 
9
9
  it { is_expected.to match /plain text ?\n/ }
10
10
  it { is_expected.to match /\n== h1\n/ }
@@ -1,24 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ReverseAsciidoctor do
3
+ describe ReverseAdoc do
4
4
 
5
5
  let(:input) { File.read('spec/assets/code.html') }
6
6
  let(:document) { Nokogiri::HTML(input) }
7
- subject { ReverseAsciidoctor.convert(input) }
7
+ subject { ReverseAdoc.convert(input) }
8
8
 
9
9
  it { is_expected.to match /inline `code` block/ }
10
10
  it { is_expected.to match /\n<code>var this\;\nthis\.is/ }
11
11
  it { is_expected.to match /block"\)\nconsole/ }
12
12
 
13
13
  context "with github style code blocks" do
14
- subject { ReverseAsciidoctor.convert(input) }
14
+ subject { ReverseAdoc.convert(input) }
15
15
  it { is_expected.to match /inline `code` block/ }
16
16
  it { is_expected.to match /\n\.\.\.\.\n<code>var this\;\nthis/ }
17
17
  it { is_expected.to match /it is"\) ?\n <\/code>\n\.\.\.\./ }
18
18
  end
19
19
 
20
20
  context "code with indentation" do
21
- subject { ReverseAsciidoctor.convert(input) }
21
+ subject { ReverseAdoc.convert(input) }
22
22
  it { is_expected.to match(/^<code>tell application "Foo"\n/) }
23
23
  it { is_expected.to match(/^ beep\n/) }
24
24
  it { is_expected.to match(/^end tell\n/) }
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ReverseAsciidoctor do
3
+ describe ReverseAdoc do
4
4
 
5
5
  let(:input) { File.read('spec/assets/escapables.html') }
6
6
  let(:document) { Nokogiri::HTML(input) }
7
- subject { ReverseAsciidoctor.convert(input) }
7
+ subject { ReverseAdoc.convert(input) }
8
8
 
9
9
  context "multiple asterisks" do
10
10
  it { is_expected.to include ' \*\*two asterisks\*\* ' }
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ReverseAsciidoctor do
3
+ describe ReverseAdoc do
4
4
 
5
5
  let(:input) { File.read('spec/assets/from_the_wild.html') }
6
6
  let(:document) { Nokogiri::HTML(input) }
7
- subject { ReverseAsciidoctor.convert(input) }
7
+ subject { ReverseAdoc.convert(input) }
8
8
 
9
9
  it "should make sense of strong-crazy markup (as seen in the wild)" do
10
10
  expect(subject).to include "*. +\n \\*\\*\\* intentcast* : logo design *+*\n"
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ReverseAsciidoctor do
3
+ describe ReverseAdoc do
4
4
 
5
5
  let(:input) { File.read('spec/assets/html_fragment.html') }
6
6
  let(:document) { Nokogiri::HTML(input) }
7
- subject { ReverseAsciidoctor.convert(input) }
7
+ subject { ReverseAdoc.convert(input) }
8
8
 
9
9
  it { is_expected.to eq("naked text 1\n\nparagraph text\n\nnaked text 2") }
10
10
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ReverseAsciidoctor do
3
+ describe ReverseAdoc do
4
4
 
5
5
  let(:input) { File.read('spec/assets/lists.html') }
6
6
  let(:document) { Nokogiri::HTML(input) }
7
- subject { ReverseAsciidoctor.convert(input) }
7
+ subject { ReverseAdoc.convert(input) }
8
8
 
9
9
  it { is_expected.to match /\n\* unordered list entry\n/ }
10
10
  it { is_expected.to match /\n\* unordered list entry 2\n/ }
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ReverseAsciidoctor do
3
+ describe ReverseAdoc do
4
4
 
5
5
  let(:input) { File.read('spec/assets/paragraphs.html') }
6
6
  let(:document) { Nokogiri::HTML(input) }
7
- subject { ReverseAsciidoctor.convert(input) }
7
+ subject { ReverseAdoc.convert(input) }
8
8
 
9
9
  it { is_expected.not_to start_with "\n\n" }
10
10
  it { is_expected.to start_with "First content\n\nSecond content\n\n" }
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ReverseAsciidoctor do
3
+ describe ReverseAdoc do
4
4
 
5
5
  let(:input) { File.read('spec/assets/quotation.html') }
6
6
  let(:document) { Nokogiri::HTML(input) }
7
- subject { ReverseAsciidoctor.convert(input) }
7
+ subject { ReverseAdoc.convert(input) }
8
8
 
9
9
  it { is_expected.to match /\n <code>Block of code<\/code>$/ }
10
10
  it { is_expected.to include "\n____\nFirst quoted paragraph\n\nSecond quoted paragraph\n____\n" }
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ReverseAsciidoctor do
3
+ describe ReverseAdoc do
4
4
 
5
5
  let(:input) { File.read('spec/assets/tables.html') }
6
6
  let(:document) { Nokogiri::HTML(input) }
7
- subject { ReverseAsciidoctor.convert(input) }
7
+ subject { ReverseAdoc.convert(input) }
8
8
 
9
9
  it { is_expected.to match /\[\[A\]\]\n\|===\n\| \[\[C\]\]header 1 \| header 2 \| header 3\n\n/ }
10
10
  it { is_expected.to match /\nh\| \[\[D\]\]data 1-1 \| data 2-1 \| data 3-1\n/ }
@@ -1,39 +1,39 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ReverseAsciidoctor do
3
+ describe ReverseAdoc do
4
4
 
5
5
  let(:input) { File.read('spec/assets/unknown_tags.html') }
6
6
  let(:document) { Nokogiri::HTML(input) }
7
- let(:result) { ReverseAsciidoctor.convert(input) }
7
+ let(:result) { ReverseAdoc.convert(input) }
8
8
 
9
9
  context 'with unknown_tags = :pass_through' do
10
- before { ReverseAsciidoctor.config.unknown_tags = :pass_through }
10
+ before { ReverseAdoc.config.unknown_tags = :pass_through }
11
11
 
12
12
  it { expect(result).to include "<bar>Foo with bar</bar>" }
13
13
  end
14
14
 
15
15
  context 'with unknown_tags = :raise' do
16
- before { ReverseAsciidoctor.config.unknown_tags = :raise }
16
+ before { ReverseAdoc.config.unknown_tags = :raise }
17
17
 
18
- it { expect { result }.to raise_error(ReverseAsciidoctor::UnknownTagError) }
18
+ it { expect { result }.to raise_error(ReverseAdoc::UnknownTagError) }
19
19
  end
20
20
 
21
21
  context 'with unknown_tags = :drop' do
22
- before { ReverseAsciidoctor.config.unknown_tags = :drop }
22
+ before { ReverseAdoc.config.unknown_tags = :drop }
23
23
 
24
24
  it { expect(result).to eq '' }
25
25
  end
26
26
 
27
27
  context 'with unknown_tags = :bypass' do
28
- before { ReverseAsciidoctor.config.unknown_tags = :bypass }
28
+ before { ReverseAdoc.config.unknown_tags = :bypass }
29
29
 
30
30
  it { expect(result).to eq "Foo with bar\n\n" }
31
31
  end
32
32
 
33
33
  context 'with unknown_tags = :something_wrong' do
34
- before { ReverseAsciidoctor.config.unknown_tags = :something_wrong }
34
+ before { ReverseAdoc.config.unknown_tags = :something_wrong }
35
35
 
36
- it { expect { result }.to raise_error(ReverseAsciidoctor::InvalidConfigurationError) }
36
+ it { expect { result }.to raise_error(ReverseAdoc::InvalidConfigurationError) }
37
37
  end
38
38
  end
39
39