reverse_adoc 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +8 -1
- data/.github/workflows/ubuntu.yml +8 -1
- data/.github/workflows/windows.yml +8 -1
- data/Gemfile +1 -1
- data/README.adoc +5 -5
- data/Rakefile +1 -1
- data/bin/reverse_adoc +18 -18
- data/bin/w2a +15 -15
- data/lib/{reverse_asciidoctor.rb → reverse_adoc.rb} +9 -9
- data/lib/{reverse_asciidoctor → reverse_adoc}/cleaner.rb +4 -4
- 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 +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/example.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/express_ref.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/ext_description.rb +1 -1
- data/lib/{reverse_asciidoctor → reverse_adoc}/converters/ext_descriptions.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 +7 -7
- 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/note.rb +1 -1
- 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/smrl_description_converter.rb +45 -0
- data/lib/reverse_adoc/version.rb +3 -0
- data/reverse_adoc.gemspec +2 -2
- 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_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 -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/example_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/express_ref_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/ext_description_spec.rb +2 -2
- data/spec/lib/{reverse_asciidoctor → reverse_adoc}/converters/ext_descriptions_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/note_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 +3 -3
- metadata +100 -100
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 906cadff19bcc530a5aa527f3a7cb87bd80050163638ce87d052d3615e82c68d
|
4
|
+
data.tar.gz: ffaf10410be78e4971c80a7c45c946aa4d4803546102b90c0c5bc01342dd962d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1436a34f5bd46e9c73d41028562f9edd78970bc5c88acf3cf815c6b76975c228045266c32e6cbc63ffcef3fc9d05101f51de446476f10ace57d565cc306d8629
|
7
|
+
data.tar.gz: 78e5514b5d5e01e5407d12644db5deda0d73e9d62f274932a2dee50de098dd65e36ddd96ef0a523726ec1915d80e42ab847d6227e8d927b5a85e229f53aaff86
|
data/.github/workflows/macos.yml
CHANGED
@@ -6,22 +6,29 @@ on:
|
|
6
6
|
push:
|
7
7
|
branches: [ master ]
|
8
8
|
pull_request:
|
9
|
+
paths-ignore:
|
10
|
+
- .github/workflows/ubuntu.yml
|
11
|
+
- .github/workflows/windows.yml
|
9
12
|
|
10
13
|
jobs:
|
11
14
|
test-macos:
|
12
15
|
name: Test on Ruby ${{ matrix.ruby }} macOS
|
13
16
|
runs-on: macos-latest
|
17
|
+
continue-on-error: ${{ matrix.experimental }}
|
14
18
|
strategy:
|
15
19
|
fail-fast: false
|
16
20
|
matrix:
|
17
21
|
ruby: [ '2.6', '2.5', '2.4' ]
|
22
|
+
experimental: [false]
|
23
|
+
include:
|
24
|
+
- ruby: '2.7'
|
25
|
+
experimental: true
|
18
26
|
steps:
|
19
27
|
- uses: actions/checkout@master
|
20
28
|
- name: Use Ruby
|
21
29
|
uses: actions/setup-ruby@v1
|
22
30
|
with:
|
23
31
|
ruby-version: ${{ matrix.ruby }}
|
24
|
-
architecture: 'x64'
|
25
32
|
- name: Update gems
|
26
33
|
run: |
|
27
34
|
sudo gem install bundler --force
|
@@ -6,22 +6,29 @@ on:
|
|
6
6
|
push:
|
7
7
|
branches: [ master ]
|
8
8
|
pull_request:
|
9
|
+
paths-ignore:
|
10
|
+
- .github/workflows/macos.yml
|
11
|
+
- .github/workflows/windows.yml
|
9
12
|
|
10
13
|
jobs:
|
11
14
|
test-linux:
|
12
15
|
name: Test on Ruby ${{ matrix.ruby }} Ubuntu
|
13
16
|
runs-on: ubuntu-latest
|
17
|
+
continue-on-error: ${{ matrix.experimental }}
|
14
18
|
strategy:
|
15
19
|
fail-fast: false
|
16
20
|
matrix:
|
17
21
|
ruby: [ '2.6', '2.5', '2.4' ]
|
22
|
+
experimental: [false]
|
23
|
+
include:
|
24
|
+
- ruby: '2.7'
|
25
|
+
experimental: true
|
18
26
|
steps:
|
19
27
|
- uses: actions/checkout@master
|
20
28
|
- name: Use Ruby
|
21
29
|
uses: actions/setup-ruby@v1
|
22
30
|
with:
|
23
31
|
ruby-version: ${{ matrix.ruby }}
|
24
|
-
architecture: 'x64'
|
25
32
|
- name: Install LibreOffice
|
26
33
|
run: sudo apt-get -y --no-install-recommends install libreoffice
|
27
34
|
- name: Update gems
|
@@ -6,22 +6,29 @@ on:
|
|
6
6
|
push:
|
7
7
|
branches: [ master ]
|
8
8
|
pull_request:
|
9
|
+
paths-ignore:
|
10
|
+
- .github/workflows/macos.yml
|
11
|
+
- .github/workflows/ubuntu.yml
|
9
12
|
|
10
13
|
jobs:
|
11
14
|
test-windows:
|
12
15
|
name: Test on Ruby ${{ matrix.ruby }} Windows
|
13
16
|
runs-on: windows-latest
|
17
|
+
continue-on-error: ${{ matrix.experimental }}
|
14
18
|
strategy:
|
15
19
|
fail-fast: false
|
16
20
|
matrix:
|
17
21
|
ruby: [ '2.6', '2.5', '2.4' ]
|
22
|
+
experimental: [false]
|
23
|
+
include:
|
24
|
+
- ruby: '2.7'
|
25
|
+
experimental: true
|
18
26
|
steps:
|
19
27
|
- uses: actions/checkout@master
|
20
28
|
- name: Use Ruby
|
21
29
|
uses: actions/setup-ruby@v1
|
22
30
|
with:
|
23
31
|
ruby-version: ${{ matrix.ruby }}
|
24
|
-
architecture: 'x64'
|
25
32
|
- name: Install LibreOffice
|
26
33
|
run: |
|
27
34
|
choco install libreoffice-still
|
data/Gemfile
CHANGED
data/README.adoc
CHANGED
@@ -247,7 +247,7 @@ The gem does not support:
|
|
247
247
|
=== MathML support
|
248
248
|
|
249
249
|
If you are using this gem in the context of https://www.metanorma.com[Metanorma],
|
250
|
-
Metanorma
|
250
|
+
Metanorma AsciiDoc accepts MathML as a native mathematical format. So you do not need
|
251
251
|
to convert the MathML to AsciiMath.
|
252
252
|
|
253
253
|
The gem will optionally invoke the https://github.com/metanorma/mathml2asciimath
|
@@ -265,7 +265,7 @@ uses the output) as such; so this is still much better than nothing for stem pro
|
|
265
265
|
|
266
266
|
=== Word cleanup
|
267
267
|
|
268
|
-
This gem is routinely used in the Metanorma project to export Word documents to
|
268
|
+
This gem is routinely used in the Metanorma project to export Word documents to AsciiDoc.
|
269
269
|
The HTML export from Word that the gem uses, from LibreOffice, is much cleaner than the
|
270
270
|
native HTML 4 export from Word; but it has some infelicities which this gem cleans up:
|
271
271
|
|
@@ -284,7 +284,7 @@ Simple to use.
|
|
284
284
|
|
285
285
|
[source,ruby]
|
286
286
|
----
|
287
|
-
result =
|
287
|
+
result = ReverseAdoc.convert input
|
288
288
|
result.inspect # " *feelings* "
|
289
289
|
----
|
290
290
|
|
@@ -294,7 +294,7 @@ Just pass your chosen configuration options in after the input. The given option
|
|
294
294
|
|
295
295
|
[source,ruby]
|
296
296
|
----
|
297
|
-
|
297
|
+
ReverseAdoc.convert(input, unknown_tags: :raise, mathml2asciimath: true)
|
298
298
|
----
|
299
299
|
|
300
300
|
|
@@ -304,7 +304,7 @@ Or configure it block style on a initializer level. These configurations will la
|
|
304
304
|
|
305
305
|
[source,ruby]
|
306
306
|
----
|
307
|
-
|
307
|
+
ReverseAdoc.config do |config|
|
308
308
|
config.unknown_tags = :bypass
|
309
309
|
config.mathml2asciimath = true
|
310
310
|
config.tag_border = ''
|
data/Rakefile
CHANGED
data/bin/reverse_adoc
CHANGED
@@ -1,38 +1,38 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# Usage:
|
3
|
-
# Usage: cat FILE |
|
2
|
+
# Usage: reverse_adoc [FILE]...
|
3
|
+
# Usage: cat FILE | reverse_adoc
|
4
4
|
require 'rubygems'
|
5
5
|
require 'bundler/setup'
|
6
6
|
|
7
|
-
require '
|
7
|
+
require 'reverse_adoc'
|
8
8
|
require 'optparse'
|
9
9
|
require 'fileutils'
|
10
10
|
|
11
11
|
OptionParser.new do |opts|
|
12
12
|
opts.banner = "Usage: reverse_adoc [options] <file>"
|
13
13
|
opts.on('-m', '--mathml2asciimath', 'Convert MathML to AsciiMath') do |v|
|
14
|
-
|
14
|
+
ReverseAdoc.config.mathml2asciimath = true
|
15
15
|
end
|
16
16
|
|
17
17
|
opts.on('-oFILENAME', '--output=FILENAME', 'Output file to write to') do |v|
|
18
|
-
|
19
|
-
# puts "output goes to #{
|
18
|
+
ReverseAdoc.config.destination = File.expand_path(v)
|
19
|
+
# puts "output goes to #{ReverseAdoc.config.destination}"
|
20
20
|
end
|
21
21
|
|
22
22
|
opts.on('-e', '--external-images', 'Export images if data URI') do |v|
|
23
|
-
|
23
|
+
ReverseAdoc.config.external_images = true
|
24
24
|
end
|
25
25
|
|
26
26
|
opts.on('-f', '--input_format [html, smrl_description]', 'Unknown input format (default: html)') do |v|
|
27
|
-
|
27
|
+
ReverseAdoc.config.input_format = v
|
28
28
|
end
|
29
29
|
|
30
30
|
opts.on('-u', '--unknown_tags [pass_through, drop, bypass, raise]', 'Unknown tag handling (default: pass_through)') do |v|
|
31
|
-
|
31
|
+
ReverseAdoc.config.unknown_tags = v
|
32
32
|
end
|
33
33
|
|
34
34
|
opts.on('-v', '--version', 'Version information') do |v|
|
35
|
-
puts "reverse_adoc: v#{
|
35
|
+
puts "reverse_adoc: v#{ReverseAdoc::VERSION}"
|
36
36
|
exit
|
37
37
|
end
|
38
38
|
|
@@ -45,30 +45,30 @@ end.parse!
|
|
45
45
|
|
46
46
|
if filename = ARGV.pop
|
47
47
|
input_content = IO.read(filename)
|
48
|
-
|
48
|
+
ReverseAdoc.config.sourcedir = File.dirname(File.expand_path(filename))
|
49
49
|
else
|
50
|
-
if
|
50
|
+
if ReverseAdoc.config.external_images
|
51
51
|
raise "The -e | --external-images feature cannot be used with STDIN input. Exiting."
|
52
52
|
end
|
53
53
|
|
54
54
|
input_content = ARGF.read
|
55
55
|
end
|
56
56
|
|
57
|
-
if
|
57
|
+
if ReverseAdoc.config.external_images && ReverseAdoc.config.destination.nil?
|
58
58
|
raise "The -e | --external-images feature must be used with -o | --output. Exiting."
|
59
59
|
end
|
60
60
|
|
61
61
|
# Read from STDIN
|
62
|
-
adoc_content =
|
62
|
+
adoc_content = ReverseAdoc.convert(input_content)
|
63
63
|
|
64
64
|
# Print to STDOUT
|
65
|
-
unless
|
65
|
+
unless ReverseAdoc.config.destination
|
66
66
|
puts adoc_content
|
67
67
|
exit
|
68
68
|
end
|
69
69
|
|
70
|
-
# Write output to
|
71
|
-
FileUtils.mkdir_p(File.dirname(
|
72
|
-
File.open(
|
70
|
+
# Write output to ReverseAdoc.config.destination
|
71
|
+
FileUtils.mkdir_p(File.dirname(ReverseAdoc.config.destination))
|
72
|
+
File.open(ReverseAdoc.config.destination, "w") do |file|
|
73
73
|
file.write(adoc_content)
|
74
74
|
end
|
data/bin/w2a
CHANGED
@@ -6,27 +6,27 @@ require 'bundler/setup'
|
|
6
6
|
|
7
7
|
require 'word-to-markdown'
|
8
8
|
require 'optparse'
|
9
|
-
require '
|
9
|
+
require 'reverse_adoc'
|
10
10
|
|
11
11
|
ARGV.push('-h') if ARGV.empty?
|
12
12
|
|
13
13
|
OptionParser.new do |opts|
|
14
14
|
opts.banner = "Usage: w2a [options] <file>"
|
15
15
|
opts.on('-m', '--mathml2asciimath', 'Convert MathML to AsciiMath') do |v|
|
16
|
-
|
16
|
+
ReverseAdoc.config.mathml2asciimath = true
|
17
17
|
end
|
18
18
|
|
19
19
|
opts.on('-oFILENAME', '--output=FILENAME', 'Output file to write to') do |v|
|
20
|
-
|
21
|
-
# puts "output goes to #{
|
20
|
+
ReverseAdoc.config.destination = File.expand_path(v)
|
21
|
+
# puts "output goes to #{ReverseAdoc.config.destination}"
|
22
22
|
end
|
23
23
|
|
24
24
|
opts.on('-e', '--external-images', 'Export images if data URI') do |v|
|
25
|
-
|
25
|
+
ReverseAdoc.config.external_images = true
|
26
26
|
end
|
27
27
|
|
28
28
|
opts.on('-v', '--version', 'Version information') do |v|
|
29
|
-
puts "reverse_adoc: v#{
|
29
|
+
puts "reverse_adoc: v#{ReverseAdoc::VERSION}"
|
30
30
|
puts "[dependency] WordToMarkdown: v#{WordToMarkdown::VERSION}"
|
31
31
|
unless Gem.win_platform?
|
32
32
|
puts "[dependency] LibreOffice: v#{WordToMarkdown.soffice.version}"
|
@@ -46,28 +46,28 @@ end.parse!
|
|
46
46
|
filename = ARGV.pop
|
47
47
|
raise "Please provide an input file to process. Exiting." unless filename
|
48
48
|
|
49
|
-
if
|
49
|
+
if ReverseAdoc.config.external_images && ReverseAdoc.config.destination.nil?
|
50
50
|
raise "The -e | --external-images feature must be used with -o | --output. Exiting."
|
51
51
|
end
|
52
52
|
|
53
|
-
|
53
|
+
ReverseAdoc.config.sourcedir = Dir.mktmpdir
|
54
54
|
|
55
|
-
doc = WordToMarkdown.new(filename,
|
55
|
+
doc = WordToMarkdown.new(filename, ReverseAdoc.config.sourcedir)
|
56
56
|
#File.open("test.html", "w:UTF-8") { |f| f.write doc.document.html }
|
57
|
-
adoc_content =
|
58
|
-
|
57
|
+
adoc_content = ReverseAdoc.convert(
|
58
|
+
ReverseAdoc.cleaner.preprocess_word_html(doc.document.html),
|
59
59
|
WordToMarkdown::REVERSE_MARKDOWN_OPTIONS
|
60
60
|
)
|
61
61
|
# puts scrub_whitespace(doc.document.html)
|
62
62
|
|
63
63
|
# Print to STDOUT
|
64
|
-
unless
|
64
|
+
unless ReverseAdoc.config.destination
|
65
65
|
puts adoc_content
|
66
66
|
exit
|
67
67
|
end
|
68
68
|
|
69
|
-
# Write output to
|
70
|
-
FileUtils.mkdir_p(File.dirname(
|
71
|
-
File.open(
|
69
|
+
# Write output to ReverseAdoc.config.destination
|
70
|
+
FileUtils.mkdir_p(File.dirname(ReverseAdoc.config.destination))
|
71
|
+
File.open(ReverseAdoc.config.destination, "w") do |file|
|
72
72
|
file.write(adoc_content)
|
73
73
|
end
|
@@ -2,20 +2,20 @@
|
|
2
2
|
|
3
3
|
require 'digest'
|
4
4
|
require 'nokogiri'
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
require '
|
9
|
-
require '
|
10
|
-
require '
|
5
|
+
require 'reverse_adoc/version'
|
6
|
+
require 'reverse_adoc/errors'
|
7
|
+
require 'reverse_adoc/cleaner'
|
8
|
+
require 'reverse_adoc/config'
|
9
|
+
require 'reverse_adoc/converters'
|
10
|
+
require 'reverse_adoc/converters/base'
|
11
11
|
|
12
|
-
module
|
12
|
+
module ReverseAdoc
|
13
13
|
def self.convert(input, options = {})
|
14
14
|
type = config.input_format
|
15
15
|
name = "#{type}_converter"
|
16
|
-
require "
|
16
|
+
require "reverse_adoc/#{type}_converter"
|
17
17
|
constant = name.split('_').map(&:capitalize).join.to_s
|
18
|
-
|
18
|
+
ReverseAdoc.const_get(constant).convert(input, options)
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.config
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ReverseAdoc
|
2
2
|
class Cleaner
|
3
3
|
|
4
4
|
def tidy(string)
|
@@ -36,19 +36,19 @@ module ReverseAsciidoctor
|
|
36
36
|
# Same for underscores and brackets.
|
37
37
|
def clean_tag_borders(string)
|
38
38
|
result = string.gsub(/\s?\*{2,}.*?\*{2,}\s?/) do |match|
|
39
|
-
preserve_border_whitespaces(match, default_border:
|
39
|
+
preserve_border_whitespaces(match, default_border: ReverseAdoc.config.tag_border) do
|
40
40
|
match.strip.sub('** ', '**').sub(' **', '**')
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
result = result.gsub(/\s?\_{2,}.*?\_{2,}\s?/) do |match|
|
45
|
-
preserve_border_whitespaces(match, default_border:
|
45
|
+
preserve_border_whitespaces(match, default_border: ReverseAdoc.config.tag_border) do
|
46
46
|
match.strip.sub('__ ', '__').sub(' __', '__')
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
result = result.gsub(/\s?~{2,}.*?~{2,}\s?/) do |match|
|
51
|
-
preserve_border_whitespaces(match, default_border:
|
51
|
+
preserve_border_whitespaces(match, default_border: ReverseAdoc.config.tag_border) do
|
52
52
|
match.strip.sub('~~ ', '~~').sub(' ~~', '~~')
|
53
53
|
end
|
54
54
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ReverseAdoc
|
2
2
|
module Converters
|
3
3
|
def self.register(tag_name, converter)
|
4
4
|
@@converters ||= {}
|
@@ -16,17 +16,17 @@ module ReverseAsciidoctor
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def self.default_converter(tag_name)
|
19
|
-
case
|
19
|
+
case ReverseAdoc.config.unknown_tags.to_sym
|
20
20
|
when :pass_through
|
21
|
-
|
21
|
+
ReverseAdoc::Converters::PassThrough.new
|
22
22
|
when :drop
|
23
|
-
|
23
|
+
ReverseAdoc::Converters::Drop.new
|
24
24
|
when :bypass
|
25
|
-
|
25
|
+
ReverseAdoc::Converters::Bypass.new
|
26
26
|
when :raise
|
27
27
|
raise UnknownTagError, "unknown tag: #{tag_name}"
|
28
28
|
else
|
29
|
-
raise InvalidConfigurationError, "unknown value #{
|
29
|
+
raise InvalidConfigurationError, "unknown value #{ReverseAdoc.config.unknown_tags.inspect} for ReverseAdoc.config.unknown_tags"
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|