reverse_adoc 0.2.8 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +15 -0
- data/.github/workflows/rake.yml +32 -0
- data/.github/workflows/release.yml +45 -0
- data/.gitignore +10 -0
- data/.hound.yml +3 -1
- data/.rubocop.yml +7 -7
- data/Gemfile +1 -1
- data/README.adoc +6 -33
- data/Rakefile +1 -1
- data/exe/reverse_adoc +70 -0
- data/{bin → exe}/w2a +15 -15
- data/lib/reverse_adoc.rb +27 -0
- data/lib/{reverse_asciidoctor → reverse_adoc}/cleaner.rb +28 -27
- data/lib/{reverse_asciidoctor → reverse_adoc}/config.rb +1 -1
- 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 +5 -3
- 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 +9 -9
- 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 +18 -15
- data/spec/assets/escapables.html +2 -0
- data/spec/bin/reverse_adoc_spec.rb +2 -2
- data/spec/bin/w2a_spec.rb +7 -7
- data/spec/components/anchors_spec.rb +2 -2
- data/spec/components/basic_spec.rb +3 -3
- data/spec/components/code_spec.rb +4 -5
- data/spec/components/escapables_spec.rb +10 -2
- data/spec/components/from_the_wild_spec.rb +2 -2
- data/spec/components/html_fragment_spec.rb +2 -3
- 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 -10
- data/spec/lib/{reverse_asciidoctor_spec.rb → reverse_adoc.rb} +17 -17
- 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 -3
- 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 -3
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/div_spec.rb +2 -3
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/figure_spec.rb +2 -3
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/img_spec.rb +2 -3
- 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 -3
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/pre_spec.rb +2 -3
- 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 -3
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters_spec.rb +5 -5
- data/spec/spec_helper.rb +3 -3
- metadata +123 -125
- data/.github/workflows/macos.yml +0 -31
- data/.github/workflows/ubuntu.yml +0 -33
- data/.github/workflows/windows.yml +0 -37
- data/Gemfile.lock +0 -84
- data/bin/reverse_adoc +0 -74
- data/lib/reverse_asciidoctor.rb +0 -30
- data/lib/reverse_asciidoctor/converters/example.rb +0 -17
- data/lib/reverse_asciidoctor/converters/express_ref.rb +0 -12
- data/lib/reverse_asciidoctor/converters/ext_description.rb +0 -16
- data/lib/reverse_asciidoctor/converters/ext_descriptions.rb +0 -12
- data/lib/reverse_asciidoctor/converters/note.rb +0 -17
- data/lib/reverse_asciidoctor/html_converter.rb +0 -56
- data/lib/reverse_asciidoctor/smrl_description_converter.rb +0 -45
- data/lib/reverse_asciidoctor/version.rb +0 -3
- data/spec/lib/reverse_asciidoctor/converters/example_spec.rb +0 -22
- data/spec/lib/reverse_asciidoctor/converters/express_ref_spec.rb +0 -14
- data/spec/lib/reverse_asciidoctor/converters/ext_description_spec.rb +0 -20
- data/spec/lib/reverse_asciidoctor/converters/ext_descriptions_spec.rb +0 -13
- data/spec/lib/reverse_asciidoctor/converters/note_spec.rb +0 -22
data/reverse_adoc.gemspec
CHANGED
@@ -1,36 +1,39 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
$:.push File.expand_path("lib", __dir__)
|
4
|
+
require "reverse_adoc/version"
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
6
7
|
s.name = "reverse_adoc"
|
7
|
-
s.version =
|
8
|
+
s.version = ReverseAdoc::VERSION
|
8
9
|
s.authors = ["Ribose Inc."]
|
9
10
|
s.email = ["open.source@ribose.com"]
|
10
11
|
|
11
12
|
s.homepage = "http://github.com/metanorma/reverse_adoc"
|
12
|
-
s.summary =
|
13
|
-
s.description =
|
13
|
+
s.summary = "Generate AsciiDoc from HTML and Microsoft Word via CLI or library."
|
14
|
+
s.description = "Generate AsciiDoc from HTML and Microsoft Word via CLI or library."
|
14
15
|
s.license = "BSD-2-Clause"
|
15
16
|
|
16
17
|
s.files = `git ls-files`.split("\n")
|
17
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files --
|
19
|
+
s.executables = `git ls-files -- exe/*`.split("\n").map { |f| File.basename(f) }
|
20
|
+
s.bindir = "exe"
|
19
21
|
s.require_paths = ["lib"]
|
20
22
|
s.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
21
23
|
|
22
24
|
# specify any dependencies here; for example:
|
23
|
-
s.add_dependency
|
24
|
-
s.add_dependency
|
25
|
-
s.add_dependency
|
26
|
-
s.add_development_dependency
|
27
|
-
s.add_development_dependency
|
28
|
-
s.add_development_dependency
|
29
|
-
s.add_development_dependency
|
30
|
-
s.add_development_dependency
|
25
|
+
s.add_dependency "marcel", "~> 1.0.0"
|
26
|
+
s.add_dependency "mathml2asciimath"
|
27
|
+
s.add_dependency "nokogiri", "~> 1.11"
|
28
|
+
s.add_development_dependency "codeclimate-test-reporter"
|
29
|
+
s.add_development_dependency "rake"
|
30
|
+
s.add_development_dependency "redcarpet"
|
31
|
+
s.add_development_dependency "rspec"
|
32
|
+
s.add_development_dependency "simplecov"
|
31
33
|
|
32
34
|
# spec.add_runtime_dependency "thor"
|
33
35
|
|
34
36
|
# All the following are for bin/w2m
|
35
|
-
s.add_dependency
|
37
|
+
s.add_dependency "premailer", "~> 1.11.0"
|
38
|
+
s.add_dependency "word-to-markdown"
|
36
39
|
end
|
data/spec/assets/escapables.html
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe '
|
5
|
+
describe 'exe/revrse_adoc' do
|
6
6
|
subject(:convert) do
|
7
|
-
ShellUtils.execute!("./
|
7
|
+
ShellUtils.execute!("./exe/reverse_adoc -e -o test1 #{input_file_path}")
|
8
8
|
end
|
9
9
|
unless Gem.win_platform?
|
10
10
|
context 'when external images present' do
|
data/spec/bin/w2a_spec.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe '
|
5
|
+
describe 'exe/w2a' do
|
6
6
|
subject(:convert) do
|
7
|
-
ShellUtils.execute!("./
|
7
|
+
ShellUtils.execute!("./exe/w2a -e -o test1 #{input_file_path}")
|
8
8
|
end
|
9
9
|
# TODO: fix github actions integration with libreoffice, currently it hangs
|
10
10
|
# when trying to use soffice binary
|
@@ -22,13 +22,13 @@ describe 'bin/w2a' do
|
|
22
22
|
expect { convert }.to_not raise_error
|
23
23
|
end
|
24
24
|
|
25
|
-
it '
|
25
|
+
it 'extracts images from source html' do
|
26
26
|
expect { convert }
|
27
27
|
.to(change do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
Dir["#{images_folder}/*gif"]
|
29
|
+
.map { |entry| File.basename(entry) }
|
30
|
+
.size > 0
|
31
|
+
end.from(false).to(true))
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
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 {
|
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]' }
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
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 {
|
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/ }
|
11
|
-
it { is_expected.to match /\n\[\[A]\]\n== h1 with anchor\n/ }
|
11
|
+
it { is_expected.to match /\n\[\[A\]\]\n== h1 with anchor\n/ }
|
12
12
|
it { is_expected.to match /\n=== h2\n/ }
|
13
13
|
it { is_expected.to match /\n==== h3\n/ }
|
14
14
|
it { is_expected.to match /\n===== h4\n/ }
|
@@ -1,28 +1,27 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
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 {
|
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 {
|
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 {
|
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/) }
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
28
|
-
|
@@ -1,14 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
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 {
|
7
|
+
subject { ReverseAdoc.convert(input) }
|
8
8
|
|
9
9
|
context "multiple asterisks" do
|
10
10
|
it { is_expected.to include ' \*\*two asterisks\*\* ' }
|
11
11
|
it { is_expected.to include ' \*\*\*three asterisks\*\*\* ' }
|
12
|
+
it { is_expected.to include ' \*and*the\* ' }
|
13
|
+
it { is_expected.to include ' asterisc*word ' }
|
14
|
+
it { is_expected.to include ' asterisc**multword asterisks\*\*\* ' }
|
12
15
|
end
|
13
16
|
|
14
17
|
context "multiple underscores" do
|
@@ -16,6 +19,11 @@ describe ReverseAsciidoctor do
|
|
16
19
|
it { is_expected.to include ' \_\_\_three underscores\_\_\_ ' }
|
17
20
|
end
|
18
21
|
|
22
|
+
context "multiple underscores with undersocre inside words and new lines" do
|
23
|
+
it { is_expected.to include 'another_undersocre' }
|
24
|
+
it { is_expected.to include ' \_\_\_three__underscores\_\_\_ ' }
|
25
|
+
end
|
26
|
+
|
19
27
|
context "underscores within words in code blocks" do
|
20
28
|
it { is_expected.to include "....\n<code>var theoretical_max_infin = 1.0;</code>\n....\n" }
|
21
29
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
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 {
|
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,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
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 {
|
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
|
11
|
-
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
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 {
|
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
|
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 {
|
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
|
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 {
|
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
|
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 {
|
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,38 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
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) {
|
7
|
+
let(:result) { ReverseAdoc.convert(input) }
|
8
8
|
|
9
9
|
context 'with unknown_tags = :pass_through' do
|
10
|
-
before {
|
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 {
|
16
|
+
before { ReverseAdoc.config.unknown_tags = :raise }
|
17
17
|
|
18
|
-
it { expect { result }.to raise_error(
|
18
|
+
it { expect { result }.to raise_error(ReverseAdoc::UnknownTagError) }
|
19
19
|
end
|
20
20
|
|
21
21
|
context 'with unknown_tags = :drop' do
|
22
|
-
before {
|
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 {
|
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 {
|
34
|
+
before { ReverseAdoc.config.unknown_tags = :something_wrong }
|
35
35
|
|
36
|
-
it { expect { result }.to raise_error(
|
36
|
+
it { expect { result }.to raise_error(ReverseAdoc::InvalidConfigurationError) }
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
@@ -1,51 +1,51 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ReverseAdoc do
|
4
4
|
let(:input) { File.read('spec/assets/minimum.html') }
|
5
5
|
let(:document) { Nokogiri::HTML(input) }
|
6
6
|
|
7
7
|
it 'parses nokogiri documents' do
|
8
|
-
expect {
|
8
|
+
expect { ReverseAdoc.convert(document) }.not_to raise_error
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'parses nokogiri elements' do
|
12
|
-
expect {
|
12
|
+
expect { ReverseAdoc.convert(document.root) }.not_to raise_error
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'parses string input' do
|
16
|
-
expect {
|
16
|
+
expect { ReverseAdoc.convert(input) }.not_to raise_error
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'behaves in a sane way when root element is nil' do
|
20
|
-
expect(
|
20
|
+
expect(ReverseAdoc.convert(nil)).to eq ''
|
21
21
|
end
|
22
22
|
|
23
23
|
describe '#config' do
|
24
24
|
it 'stores a given configuration option' do
|
25
|
-
|
26
|
-
expect(
|
25
|
+
ReverseAdoc.config.tag_border = true
|
26
|
+
expect(ReverseAdoc.config.tag_border).to eq true
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'can be used as a block configurator as well' do
|
30
|
-
|
30
|
+
ReverseAdoc.config do |config|
|
31
31
|
expect(config.tag_border).to eq ' '
|
32
32
|
config.tag_border = true
|
33
33
|
end
|
34
|
-
expect(
|
34
|
+
expect(ReverseAdoc.config.tag_border).to eq true
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
shared_examples 'converting source with external images included' do |result|
|
39
39
|
let(:temp_dir) do
|
40
|
-
Pathname.new(
|
40
|
+
Pathname.new(ReverseAdoc.config.destination).dirname
|
41
41
|
end
|
42
42
|
let(:images_folder) { File.join(temp_dir, 'images') }
|
43
43
|
|
44
44
|
before do
|
45
|
-
|
45
|
+
ReverseAdoc.config.destination = File.join(Dir.mktmpdir,
|
46
46
|
'output.html')
|
47
|
-
|
48
|
-
|
47
|
+
ReverseAdoc.config.sourcedir = Dir.mktmpdir
|
48
|
+
ReverseAdoc.config.external_images = true
|
49
49
|
end
|
50
50
|
|
51
51
|
after do
|
@@ -67,14 +67,14 @@ describe ReverseAsciidoctor do
|
|
67
67
|
unless Gem::Platform.local.os == 'darwin' && !ENV['GITHUB_ACTION'].nil?
|
68
68
|
context 'when docx file input' do
|
69
69
|
subject(:convert) do
|
70
|
-
|
71
|
-
|
70
|
+
ReverseAdoc.convert(
|
71
|
+
ReverseAdoc.cleaner.preprocess_word_html(input.document.html),
|
72
72
|
WordToMarkdown::REVERSE_MARKDOWN_OPTIONS
|
73
73
|
)
|
74
74
|
end
|
75
75
|
let(:input) do
|
76
76
|
WordToMarkdown.new('spec/assets/external_images.docx',
|
77
|
-
|
77
|
+
ReverseAdoc.config.sourcedir)
|
78
78
|
end
|
79
79
|
it_behaves_like 'converting source with external images included',
|
80
80
|
['001.gif', '002.gif']
|
@@ -82,7 +82,7 @@ describe ReverseAsciidoctor do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
context 'when html file input' do
|
85
|
-
subject(:convert) {
|
85
|
+
subject(:convert) { ReverseAdoc.convert(input) }
|
86
86
|
let(:input) { File.read('spec/assets/external_images.html') }
|
87
87
|
it_behaves_like 'converting source with external images included',
|
88
88
|
['001.gif']
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
let(:cleaner) {
|
3
|
+
describe ReverseAdoc::Cleaner do
|
4
|
+
let(:cleaner) { ReverseAdoc::Cleaner.new }
|
5
5
|
|
6
6
|
describe '#scrub_whitespace' do
|
7
7
|
it "makes consistent nonbreaking spaces" do
|
@@ -86,7 +86,7 @@ describe ReverseAsciidoctor::Cleaner do
|
|
86
86
|
|
87
87
|
describe '#clean_tag_borders' do
|
88
88
|
context 'with default_border is set to space' do
|
89
|
-
before {
|
89
|
+
before { ReverseAdoc.config.tag_border = ' ' }
|
90
90
|
|
91
91
|
it 'removes not needed whitespaces from strong tags' do
|
92
92
|
input = "foo ** foobar ** bar"
|
@@ -132,7 +132,7 @@ describe ReverseAsciidoctor::Cleaner do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
context 'with default_border set to no space' do
|
135
|
-
before {
|
135
|
+
before { ReverseAdoc.config.tag_border = '' }
|
136
136
|
|
137
137
|
it 'removes not needed whitespaces from strong tags' do
|
138
138
|
input = "foo ** foobar ** bar"
|