reverse_adoc 0.2.4 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +16 -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 +84 -0
  7. data/README.adoc +40 -7
  8. data/Rakefile +1 -1
  9. data/bin/reverse_adoc +24 -17
  10. data/bin/w2a +19 -31
  11. data/lib/reverse_adoc.rb +30 -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 +7 -3
  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_adoc/converters/example.rb +17 -0
  27. data/lib/reverse_adoc/converters/express_ref.rb +12 -0
  28. data/lib/reverse_adoc/converters/ext_description.rb +16 -0
  29. data/lib/reverse_adoc/converters/ext_descriptions.rb +12 -0
  30. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/figure.rb +1 -1
  31. data/lib/reverse_adoc/converters/h.rb +34 -0
  32. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/head.rb +1 -1
  33. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/hr.rb +1 -1
  34. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/ignore.rb +1 -1
  35. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/img.rb +27 -25
  36. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/li.rb +1 -1
  37. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/mark.rb +1 -1
  38. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/math.rb +3 -3
  39. data/lib/reverse_adoc/converters/note.rb +17 -0
  40. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/ol.rb +1 -1
  41. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/p.rb +1 -1
  42. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/pass_through.rb +1 -1
  43. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/pre.rb +1 -1
  44. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/q.rb +1 -1
  45. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/strong.rb +1 -1
  46. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/sub.rb +1 -1
  47. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/sup.rb +1 -1
  48. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/table.rb +1 -1
  49. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/td.rb +1 -1
  50. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/text.rb +1 -1
  51. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/th.rb +1 -1
  52. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/tr.rb +1 -1
  53. data/lib/{reverse_asciidoctor → reverse_adoc}/converters/video.rb +1 -1
  54. data/lib/{reverse_asciidoctor → reverse_adoc}/errors.rb +1 -1
  55. data/lib/reverse_adoc/html_converter.rb +56 -0
  56. data/lib/reverse_adoc/smrl_description_converter.rb +45 -0
  57. data/lib/reverse_adoc/version.rb +3 -0
  58. data/reverse_adoc.gemspec +3 -2
  59. data/spec/assets/anchors.html +8 -0
  60. data/spec/assets/external_images.docx +0 -0
  61. data/spec/assets/external_images.html +35 -0
  62. data/spec/bin/reverse_adoc_spec.rb +32 -0
  63. data/spec/bin/w2a_spec.rb +35 -0
  64. data/spec/components/anchors_spec.rb +7 -2
  65. data/spec/components/basic_spec.rb +2 -2
  66. data/spec/components/code_spec.rb +4 -4
  67. data/spec/components/escapables_spec.rb +2 -2
  68. data/spec/components/from_the_wild_spec.rb +2 -2
  69. data/spec/components/html_fragment_spec.rb +2 -2
  70. data/spec/components/lists_spec.rb +2 -2
  71. data/spec/components/paragraphs_spec.rb +2 -2
  72. data/spec/components/quotation_spec.rb +2 -2
  73. data/spec/components/tables_spec.rb +2 -2
  74. data/spec/components/unknown_tags_spec.rb +9 -9
  75. data/spec/lib/reverse_adoc.rb +90 -0
  76. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/cleaner_spec.rb +28 -4
  77. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/config_spec.rb +5 -5
  78. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/aside_spec.rb +2 -2
  79. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/audio_spec.rb +2 -2
  80. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/blockquote_spec.rb +2 -2
  81. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/br_spec.rb +2 -2
  82. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/code_spec.rb +2 -2
  83. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/div_spec.rb +2 -2
  84. data/spec/lib/reverse_adoc/converters/example_spec.rb +22 -0
  85. data/spec/lib/reverse_adoc/converters/express_ref_spec.rb +14 -0
  86. data/spec/lib/reverse_adoc/converters/ext_description_spec.rb +20 -0
  87. data/spec/lib/reverse_adoc/converters/ext_descriptions_spec.rb +13 -0
  88. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/figure_spec.rb +2 -2
  89. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/img_spec.rb +2 -2
  90. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/li_spec.rb +2 -2
  91. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/mark_spec.rb +2 -2
  92. data/spec/lib/reverse_adoc/converters/note_spec.rb +22 -0
  93. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/p_spec.rb +2 -2
  94. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/pre_spec.rb +2 -2
  95. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/q_spec.rb +2 -2
  96. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/strong_spec.rb +2 -2
  97. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/text_spec.rb +2 -2
  98. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/video_spec.rb +2 -2
  99. data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters_spec.rb +5 -5
  100. data/spec/spec_helper.rb +7 -2
  101. data/spec/support/shell_helpers.rb +15 -0
  102. metadata +125 -84
  103. data/lib/reverse_asciidoctor.rb +0 -70
  104. data/lib/reverse_asciidoctor/converters/h.rb +0 -19
  105. data/lib/reverse_asciidoctor/version.rb +0 -3
  106. 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 Li < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Mark < Base
4
4
  def convert(node, state = {})
@@ -1,15 +1,15 @@
1
- # Unless run with ReverseAsciidoctor.config.mathml2asciimath,
1
+ # Unless run with ReverseAdoc.config.mathml2asciimath,
2
2
  # this is cheating: we're injecting MathML into Asciidoctor, but
3
3
  # Asciidoctor only understands AsciiMath or LaTeX
4
4
 
5
5
  require "mathml2asciimath"
6
6
 
7
- module ReverseAsciidoctor
7
+ module ReverseAdoc
8
8
  module Converters
9
9
  class Math < Base
10
10
  def convert(node, state = {})
11
11
  stem = node.to_s.gsub(/\n/, " ")
12
- stem = MathML2AsciiMath.m2a(stem) if ReverseAsciidoctor.config.mathml2asciimath
12
+ stem = MathML2AsciiMath.m2a(stem) if ReverseAdoc.config.mathml2asciimath
13
13
  stem = stem.gsub(/\[/, "\\[").gsub(/\]/, "\\]").gsub(/\(\(([^\)]+)\)\)/, "(\\1)") unless stem.nil?
14
14
  " stem:[" << stem << "] "
15
15
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ReverseAdoc
4
+ module Converters
5
+ class Note < Base
6
+ def convert(node, state = {})
7
+ <<~TEMPLATE
8
+ [NOTE]
9
+ --
10
+ #{treat_children(node, state)}
11
+ --
12
+ TEMPLATE
13
+ end
14
+ end
15
+ register :note, Note.new
16
+ end
17
+ end
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Ol < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class P < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class PassThrough < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Pre < Base
4
4
  def convert(node, state = {})
@@ -1,4 +1,4 @@
1
- module ReverseAsciidoctor
1
+ module ReverseAdoc
2
2
  module Converters
3
3
  class Q < Base
4
4
  def convert(node, state = {})
@@ -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,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'reverse_adoc/converters/a'
4
+ require 'reverse_adoc/converters/blockquote'
5
+ require 'reverse_adoc/converters/bypass'
6
+ require 'reverse_adoc/converters/br'
7
+ require 'reverse_adoc/converters/code'
8
+ require 'reverse_adoc/converters/drop'
9
+ require 'reverse_adoc/converters/em'
10
+ require 'reverse_adoc/converters/example'
11
+ require 'reverse_adoc/converters/ext_descriptions'
12
+ require 'reverse_adoc/converters/ext_description'
13
+ require 'reverse_adoc/converters/express_ref'
14
+ require 'reverse_adoc/converters/head'
15
+ require 'reverse_adoc/converters/hr'
16
+ require 'reverse_adoc/converters/ignore'
17
+ require 'reverse_adoc/converters/note'
18
+ require 'reverse_adoc/converters/p'
19
+ require 'reverse_adoc/converters/pass_through'
20
+ require 'reverse_adoc/converters/q'
21
+ require 'reverse_adoc/converters/strong'
22
+ require 'reverse_adoc/converters/sup'
23
+ require 'reverse_adoc/converters/sub'
24
+ require 'reverse_adoc/converters/text'
25
+
26
+ module ReverseAdoc
27
+ class SmrlDescriptionConverter
28
+ def self.convert(input, options = {})
29
+ root = if input.is_a?(String)
30
+ then Nokogiri::XML(input).root
31
+ elsif input.is_a?(Nokogiri::XML::Document)
32
+ then input.root
33
+ elsif input.is_a?(Nokogiri::XML::Node)
34
+ then input
35
+ end
36
+
37
+ root || (return '')
38
+
39
+ ReverseAdoc.config.with(options) do
40
+ result = ReverseAdoc::Converters.lookup(root.name).convert(root)
41
+ ReverseAdoc.cleaner.tidy(result)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,3 @@
1
+ module ReverseAdoc
2
+ VERSION = '0.2.9'
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'
@@ -14,9 +14,17 @@
14
14
 
15
15
  some text...
16
16
 
17
+ <a href="#a__b spaced">Double __ anchor with space</a>
18
+
19
+ Double __ anchor with space <a id="a__b spaced"/>
20
+
21
+ <a id="_Toc12345"/>
22
+
17
23
  <img src="http://foobar.com/logo.png">
18
24
  <img alt="foobar image" src="http://foobar.com/foobar.png">
19
25
  <img alt="foobar image 2" title="this is the foobar image 2" src="http://foobar.com/foobar2.png">
20
26
  some text...
27
+
28
+ <h1><a id="a__Foreword"></a>Text</h1>
21
29
  </body>
22
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]' }
@@ -18,4 +18,9 @@ describe ReverseAsciidoctor do
18
18
  it { is_expected.to include ' link <<content2>>internal jumplinks without anchors ' }
19
19
  it { is_expected.to include ' treat [[content]] as bookmarks ' }
20
20
 
21
+ it { is_expected.to include "<<a_bspaced,Double \\_\\_ anchor with space>>" }
22
+ it { is_expected.to include "[[a_bspaced]]" }
23
+ it { is_expected.to include "[[a_Foreword]]\n== Text" }
24
+ it { is_expected.not_to include "[[_Toc12345]]" }
25
+
21
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/ }