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,70 +0,0 @@
1
- require 'digest'
2
- require 'nokogiri'
3
- require 'reverse_asciidoctor/version'
4
- require 'reverse_asciidoctor/errors'
5
- require 'reverse_asciidoctor/cleaner'
6
- require 'reverse_asciidoctor/config'
7
- require 'reverse_asciidoctor/converters'
8
- require 'reverse_asciidoctor/converters/base'
9
- require 'reverse_asciidoctor/converters/a'
10
- require 'reverse_asciidoctor/converters/aside'
11
- require 'reverse_asciidoctor/converters/audio'
12
- require 'reverse_asciidoctor/converters/blockquote'
13
- require 'reverse_asciidoctor/converters/br'
14
- require 'reverse_asciidoctor/converters/bypass'
15
- require 'reverse_asciidoctor/converters/code'
16
- require 'reverse_asciidoctor/converters/div'
17
- require 'reverse_asciidoctor/converters/drop'
18
- require 'reverse_asciidoctor/converters/em'
19
- require 'reverse_asciidoctor/converters/figure'
20
- require 'reverse_asciidoctor/converters/h'
21
- require 'reverse_asciidoctor/converters/head'
22
- require 'reverse_asciidoctor/converters/hr'
23
- require 'reverse_asciidoctor/converters/ignore'
24
- require 'reverse_asciidoctor/converters/img'
25
- require 'reverse_asciidoctor/converters/mark'
26
- require 'reverse_asciidoctor/converters/li'
27
- require 'reverse_asciidoctor/converters/ol'
28
- require 'reverse_asciidoctor/converters/p'
29
- require 'reverse_asciidoctor/converters/pass_through'
30
- require 'reverse_asciidoctor/converters/pre'
31
- require 'reverse_asciidoctor/converters/q'
32
- require 'reverse_asciidoctor/converters/strong'
33
- require 'reverse_asciidoctor/converters/sup'
34
- require 'reverse_asciidoctor/converters/sub'
35
- require 'reverse_asciidoctor/converters/table'
36
- require 'reverse_asciidoctor/converters/td'
37
- require 'reverse_asciidoctor/converters/th'
38
- require 'reverse_asciidoctor/converters/text'
39
- require 'reverse_asciidoctor/converters/tr'
40
- require 'reverse_asciidoctor/converters/video'
41
- require 'reverse_asciidoctor/converters/math'
42
-
43
- module ReverseAsciidoctor
44
-
45
- def self.convert(input, options = {})
46
- root = case input
47
- when String then Nokogiri::HTML(input).root
48
- when Nokogiri::XML::Document then input.root
49
- when Nokogiri::XML::Node then input
50
- end
51
-
52
- root or return ''
53
-
54
- config.with(options) do
55
- result = ReverseAsciidoctor::Converters.lookup(root.name).convert(root)
56
- cleaner.tidy(result)
57
- end
58
- end
59
-
60
- def self.config
61
- @config ||= Config.new
62
- yield @config if block_given?
63
- @config
64
- end
65
-
66
- def self.cleaner
67
- @cleaner ||= Cleaner.new
68
- end
69
-
70
- end
@@ -1,19 +0,0 @@
1
- module ReverseAsciidoctor
2
- module Converters
3
- class H < Base
4
- def convert(node, state = {})
5
- id = node['id']
6
- anchor = id ? "[[#{id}]]\n" : ""
7
- prefix = '=' * (node.name[/\d/].to_i + 1)
8
- ["\n", anchor, prefix, ' ', treat_children(node, state), "\n"].join
9
- end
10
- end
11
-
12
- register :h1, H.new
13
- register :h2, H.new
14
- register :h3, H.new
15
- register :h4, H.new
16
- register :h5, H.new
17
- register :h6, H.new
18
- end
19
- end
@@ -1,3 +0,0 @@
1
- module ReverseAsciidoctor
2
- VERSION = '0.2.4'
3
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ReverseAsciidoctor do
4
- let(:input) { File.read('spec/assets/minimum.html') }
5
- let(:document) { Nokogiri::HTML(input) }
6
-
7
- it "parses nokogiri documents" do
8
- expect { ReverseAsciidoctor.convert(document) }.not_to raise_error
9
- end
10
-
11
- it "parses nokogiri elements" do
12
- expect { ReverseAsciidoctor.convert(document.root) }.not_to raise_error
13
- end
14
-
15
- it "parses string input" do
16
- expect { ReverseAsciidoctor.convert(input) }.not_to raise_error
17
- end
18
-
19
- it "behaves in a sane way when root element is nil" do
20
- expect(ReverseAsciidoctor.convert(nil)).to eq ''
21
- end
22
-
23
- describe '#config' do
24
- it 'stores a given configuration option' do
25
- ReverseAsciidoctor.config.tag_border = true
26
- expect(ReverseAsciidoctor.config.tag_border).to eq true
27
- end
28
-
29
- it 'can be used as a block configurator as well' do
30
- ReverseAsciidoctor.config do |config|
31
- expect(config.tag_border).to eq " "
32
- config.tag_border = true
33
- end
34
- expect(ReverseAsciidoctor.config.tag_border).to eq true
35
- end
36
- end
37
- end