reverse_adoc 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +42 -0
- data/Gemfile +2 -2
- data/README.adoc +6 -22
- data/Rakefile +1 -1
- data/bin/reverse_adoc +17 -17
- data/bin/w2a +17 -17
- data/lib/reverse_adoc.rb +27 -0
- data/lib/{reverse_asciidoctor → reverse_adoc}/cleaner.rb +4 -4
- data/lib/{reverse_asciidoctor → reverse_adoc}/config.rb +3 -2
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters.rb +6 -6
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/a.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/aside.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/audio.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/base.rb +2 -2
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/blockquote.rb +2 -2
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/br.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/bypass.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/code.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/div.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/drop.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/em.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/figure.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/h.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/head.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/hr.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/ignore.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/img.rb +11 -11
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/li.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/mark.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/math.rb +3 -3
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/ol.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/p.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/pass_through.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/pre.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/q.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/strong.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/sub.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/sup.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/table.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/td.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/text.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/th.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/tr.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/video.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/errors.rb +1 -1
- data/lib/reverse_adoc/html_converter.rb +56 -0
- data/lib/reverse_adoc/version.rb +3 -0
- data/reverse_adoc.gemspec +5 -4
- data/spec/assets/{test.docx → external_images.docx} +0 -0
- data/spec/assets/{test.html → external_images.html} +0 -0
- data/spec/bin/reverse_adoc_spec.rb +32 -0
- data/spec/bin/w2a_spec.rb +35 -0
- data/spec/components/anchors_spec.rb +2 -2
- data/spec/components/basic_spec.rb +2 -2
- data/spec/components/code_spec.rb +4 -4
- data/spec/components/escapables_spec.rb +2 -2
- data/spec/components/from_the_wild_spec.rb +2 -2
- data/spec/components/html_fragment_spec.rb +2 -2
- data/spec/components/lists_spec.rb +2 -2
- data/spec/components/paragraphs_spec.rb +2 -2
- data/spec/components/quotation_spec.rb +2 -2
- data/spec/components/tables_spec.rb +2 -2
- data/spec/components/unknown_tags_spec.rb +9 -9
- data/spec/lib/reverse_adoc.rb +90 -0
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/cleaner_spec.rb +4 -4
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/config_spec.rb +5 -5
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/aside_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/audio_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/blockquote_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/br_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/code_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/div_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/figure_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/img_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/li_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/mark_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/p_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/pre_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/q_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/strong_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/text_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/video_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters_spec.rb +5 -5
- data/spec/spec_helper.rb +7 -2
- data/spec/support/shell_helpers.rb +15 -0
- metadata +119 -101
- data/.github/workflows/macos.yml +0 -27
- data/.github/workflows/ubuntu.yml +0 -27
- data/.github/workflows/windows.yml +0 -30
- data/lib/reverse_asciidoctor.rb +0 -70
- data/lib/reverse_asciidoctor/version.rb +0 -3
- data/spec/lib/reverse_asciidoctor_spec.rb +0 -37
data/.github/workflows/macos.yml
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# Auto-generated !!! Do not edit it manually
|
2
|
-
# use ci-master https://github.com/metanorma/metanorma-build-scripts
|
3
|
-
name: macos
|
4
|
-
|
5
|
-
on: [push]
|
6
|
-
|
7
|
-
jobs:
|
8
|
-
test-macos:
|
9
|
-
name: Test on Ruby ${{ matrix.ruby }} macOS
|
10
|
-
runs-on: macos-latest
|
11
|
-
strategy:
|
12
|
-
matrix:
|
13
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
14
|
-
steps:
|
15
|
-
- uses: actions/checkout@master
|
16
|
-
- name: Use Ruby
|
17
|
-
uses: actions/setup-ruby@v1
|
18
|
-
with:
|
19
|
-
ruby-version: ${{ matrix.ruby }}
|
20
|
-
architecture: 'x64'
|
21
|
-
- name: Update gems
|
22
|
-
run: |
|
23
|
-
sudo gem install bundler -v "~> 2" --force
|
24
|
-
bundle install --jobs 4 --retry 3
|
25
|
-
- name: Run specs
|
26
|
-
run: |
|
27
|
-
bundle exec rake
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# Auto-generated !!! Do not edit it manually
|
2
|
-
# use ci-master https://github.com/metanorma/metanorma-build-scripts
|
3
|
-
name: ubuntu
|
4
|
-
|
5
|
-
on: [push]
|
6
|
-
|
7
|
-
jobs:
|
8
|
-
test-linux:
|
9
|
-
name: Test on Ruby ${{ matrix.ruby }} Ubuntu
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
strategy:
|
12
|
-
matrix:
|
13
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
14
|
-
steps:
|
15
|
-
- uses: actions/checkout@master
|
16
|
-
- name: Use Ruby
|
17
|
-
uses: actions/setup-ruby@v1
|
18
|
-
with:
|
19
|
-
ruby-version: ${{ matrix.ruby }}
|
20
|
-
architecture: 'x64'
|
21
|
-
- name: Update gems
|
22
|
-
run: |
|
23
|
-
gem install bundler -v "~> 2"
|
24
|
-
bundle install --jobs 4 --retry 3
|
25
|
-
- name: Run specs
|
26
|
-
run: |
|
27
|
-
bundle exec rake
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# Auto-generated !!! Do not edit it manually
|
2
|
-
# use ci-master https://github.com/metanorma/metanorma-build-scripts
|
3
|
-
name: windows
|
4
|
-
|
5
|
-
on: [push]
|
6
|
-
|
7
|
-
jobs:
|
8
|
-
test-windows:
|
9
|
-
name: Test on Ruby ${{ matrix.ruby }} Windows
|
10
|
-
runs-on: windows-latest
|
11
|
-
strategy:
|
12
|
-
matrix:
|
13
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
14
|
-
steps:
|
15
|
-
- uses: actions/checkout@master
|
16
|
-
- name: Use Ruby
|
17
|
-
uses: actions/setup-ruby@v1
|
18
|
-
with:
|
19
|
-
ruby-version: ${{ matrix.ruby }}
|
20
|
-
architecture: 'x64'
|
21
|
-
- name: Update gems
|
22
|
-
shell: pwsh
|
23
|
-
run: |
|
24
|
-
gem install bundler -v "~> 2"
|
25
|
-
bundle config --local path vendor/bundle
|
26
|
-
bundle update
|
27
|
-
bundle install --jobs 4 --retry 3
|
28
|
-
- name: Run specs
|
29
|
-
run: |
|
30
|
-
bundle exec rake
|
data/lib/reverse_asciidoctor.rb
DELETED
@@ -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,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
|