reverse_adoc 0.2.10 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +15 -0
  3. data/.github/workflows/rake.yml +32 -0
  4. data/.github/workflows/release.yml +45 -0
  5. data/.gitignore +10 -0
  6. data/.hound.yml +3 -1
  7. data/.rubocop.yml +7 -7
  8. data/README.adoc +1 -3
  9. data/{bin → exe}/reverse_adoc +0 -0
  10. data/{bin → exe}/w2a +0 -0
  11. data/lib/reverse_adoc/cleaner.rb +24 -23
  12. data/lib/reverse_adoc/converters/base.rb +3 -1
  13. data/lib/reverse_adoc/converters/img.rb +2 -2
  14. data/lib/reverse_adoc/html_converter.rb +38 -38
  15. data/lib/reverse_adoc/version.rb +1 -1
  16. data/reverse_adoc.gemspec +17 -15
  17. data/spec/assets/escapables.html +2 -0
  18. data/spec/bin/reverse_adoc_spec.rb +2 -2
  19. data/spec/bin/w2a_spec.rb +7 -7
  20. data/spec/components/basic_spec.rb +1 -1
  21. data/spec/components/code_spec.rb +0 -1
  22. data/spec/components/escapables_spec.rb +8 -0
  23. data/spec/components/html_fragment_spec.rb +0 -1
  24. data/spec/components/unknown_tags_spec.rb +0 -1
  25. data/spec/lib/reverse_adoc/converters/audio_spec.rb +0 -1
  26. data/spec/lib/reverse_adoc/converters/code_spec.rb +0 -1
  27. data/spec/lib/reverse_adoc/converters/div_spec.rb +0 -1
  28. data/spec/lib/reverse_adoc/converters/figure_spec.rb +0 -1
  29. data/spec/lib/reverse_adoc/converters/img_spec.rb +0 -1
  30. data/spec/lib/reverse_adoc/converters/p_spec.rb +0 -1
  31. data/spec/lib/reverse_adoc/converters/pre_spec.rb +0 -1
  32. data/spec/lib/reverse_adoc/converters/video_spec.rb +0 -1
  33. metadata +36 -36
  34. data/.github/workflows/macos.yml +0 -41
  35. data/.github/workflows/ubuntu.yml +0 -40
  36. data/.github/workflows/windows.yml +0 -44
  37. data/Gemfile.lock +0 -85
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abd0bf0dce3d437c176a1c3486d565fedd235d4b4e58cfdb4259188a1a94e090
4
- data.tar.gz: '08926fcde9721aecc4672ac81c1dce18bf750763fe60621f57eb4cc32605eb70'
3
+ metadata.gz: 36f817d275ce6148cc1013a3b50e313b481d44121babe05d13fc07d49e221c2d
4
+ data.tar.gz: 6885e6d6810fb0c0113ff2108c50e7326eb74479501607b4825fe9581ab7b03f
5
5
  SHA512:
6
- metadata.gz: 39bf9ee3868bbb02440e2d853839a267f4c385e84204aedaeabe1000a7fa3fdc3f9e6baf381025548633b02b5c9e8f7d87925044c3ec992ca1eca2b83e7722b6
7
- data.tar.gz: 5c34f9d71fa904a05c2e726b627d944f61a09f08e50ff587a102cc6e42c107600e08ad4b583fb5c9a07d678c09f06bc86fe25c15b94ae2dbefa0f29d046796bf
6
+ metadata.gz: a38b5a9afc809ff511606abfd62a2cd3bf75e3c632bd60319be2477e8879626ba20151ba1dd31b9114adc28492ebf864f9dc189e175bfb47b91b551ed0f8e701
7
+ data.tar.gz: b9ce3a1c1123166c2ecf2f5bdde273ecb003505071b8863196fe99e3d7a4d6225ea1d362c010ec034f8f60df8cf920ca7ef63ed0bc1f05b7ec3f51a7b66f687e
data/.editorconfig ADDED
@@ -0,0 +1,15 @@
1
+ # EditorConfig is awesome: http://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ # Unix-style newlines with a newline ending every file
7
+ [*]
8
+ charset = utf-8
9
+ end_of_line = lf
10
+
11
+ [{*.adoc,*.html,*.js,*.json,*.rake,*.rb,*.rf,*.yaml,*.yml,Rakefile,rakefile}]
12
+ indent_style = space
13
+ indent_size = 2
14
+ insert_final_newline = true
15
+ trim_trailing_whitespace = true
@@ -0,0 +1,32 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
+ runs-on: ${{ matrix.os }}
15
+ continue-on-error: ${{ matrix.experimental }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
21
+ experimental: [ false ]
22
+ steps:
23
+ - uses: actions/checkout@master
24
+
25
+ - uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby }}
28
+ bundler-cache: true
29
+
30
+ - uses: metanorma/metanorma-build-scripts/libreoffice-setup-action@master
31
+
32
+ - run: bundle exec rake
@@ -0,0 +1,45 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: release
4
+
5
+ on:
6
+ workflow_dispatch:
7
+ inputs:
8
+ next_version:
9
+ description: |
10
+ Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
+ required: true
12
+ default: 'skip'
13
+ push:
14
+ tags: [ v* ]
15
+
16
+ jobs:
17
+ release:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: '2.6'
25
+ bundler-cache: true
26
+
27
+ - run: gem install gem-release
28
+
29
+ - if: ${{ github.event_name == 'workflow_dispatch' }} && ${{ github.event.inputs.next_version != 'skip' }}
30
+ run: |
31
+ git config user.name github-actions
32
+ git config user.email github-actions@github.com
33
+ gem bump --version ${{ github.event.inputs.next_version }} --tag --push
34
+
35
+ - name: publish to rubygems.org
36
+ env:
37
+ RUBYGEMS_API_KEY: ${{secrets.METANORMA_CI_RUBYGEMS_API_KEY}}
38
+ run: |
39
+ gem install gem-release
40
+ envsubst << 'EOF' > ~/.gem/credentials
41
+ ---
42
+ :rubygems_api_key: ${RUBYGEMS_API_KEY}
43
+ EOF
44
+ chmod 0600 ~/.gem/credentials
45
+ gem release
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /coverage
2
+ /Gemfile.lock
3
+
4
+ .DS_Store
5
+
6
+ # RuboCop's remote style books
7
+ .rubocop-https---*
8
+
9
+ # Some odd files created by specs
10
+ /test1
data/.hound.yml CHANGED
@@ -1,3 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
1
3
  ruby:
2
- Enabled: true
4
+ enabled: true
3
5
  config_file: .rubocop.yml
data/.rubocop.yml CHANGED
@@ -1,10 +1,10 @@
1
- # This project follows the Ribose OSS style guide.
2
- # https://github.com/riboseinc/oss-guides
3
- # All project-specific additions and overrides should be specified in this file.
4
-
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
5
3
  inherit_from:
6
4
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
5
+
6
+ # local repo-specific modifications
7
+ # ...
8
+
7
9
  AllCops:
8
- TargetRubyVersion: 2.3
9
- Rails:
10
- Enabled: true
10
+ TargetRubyVersion: 2.5
data/README.adoc CHANGED
@@ -1,9 +1,7 @@
1
1
  = AsciiDoc from HTML and Microsoft Word: reverse_adoc
2
2
 
3
3
  https://github.com/metanorma/reverse_adoc[reverse_adoc] image:https://img.shields.io/gem/v/reverse_adoc.svg["Gem Version", link="https://rubygems.org/gems/reverse_adoc"]::
4
- image:https://github.com/metanorma/reverse_adoc/workflows/macos/badge.svg["Build Status", link="https://github.com/metanorma/reverse_adoc/actions?workflow=macos"]
5
- image:https://github.com/metanorma/reverse_adoc/workflows/windows/badge.svg["Build Status", link="https://github.com/metanorma/reverse_adoc/actions?workflow=windows"]
6
- image:https://github.com/metanorma/reverse_adoc/workflows/ubuntu/badge.svg["Build Status", link="https://github.com/metanorma/reverse_adoc/actions?workflow=ubuntu"]
4
+ image:https://github.com/metanorma/reverse_adoc/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/reverse_adoc/actions?workflow=rake"]
7
5
  image:https://codeclimate.com/github/metanorma/reverse_adoc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/reverse_adoc"]
8
6
  image:https://img.shields.io/github/issues-pr-raw/metanorma/reverse_adoc.svg["Pull Requests", link="https://github.com/metanorma/reverse_adoc/pulls"]
9
7
  image:https://img.shields.io/github/commits-since/metanorma/reverse_adoc/latest.svg["Commits since latest",link="https://github.com/metanorma/reverse_adoc/releases"]
File without changes
data/{bin → exe}/w2a RENAMED
File without changes
@@ -1,6 +1,5 @@
1
1
  module ReverseAdoc
2
2
  class Cleaner
3
-
4
3
  def tidy(string)
5
4
  result = remove_inner_whitespaces(string)
6
5
  result = remove_newlines(result)
@@ -14,7 +13,7 @@ module ReverseAdoc
14
13
  end
15
14
 
16
15
  def remove_leading_newlines(string)
17
- string.gsub(/\A\n+/, '')
16
+ string.gsub(/\A\n+/, "")
18
17
  end
19
18
 
20
19
  def remove_inner_whitespaces(string)
@@ -25,7 +24,7 @@ module ReverseAdoc
25
24
  end
26
25
  string.each_line.inject("") do |memo, line|
27
26
  memo + preserve_border_whitespaces(line) do
28
- line.strip.gsub(/[ \t]{2,}/, ' ')
27
+ line.strip.gsub(/[ \t]{2,}/, " ")
29
28
  end
30
29
  end
31
30
  end
@@ -37,64 +36,67 @@ module ReverseAdoc
37
36
  def clean_tag_borders(string)
38
37
  result = string.gsub(/\s?\*{2,}.*?\*{2,}\s?/) do |match|
39
38
  preserve_border_whitespaces(match, default_border: ReverseAdoc.config.tag_border) do
40
- match.strip.sub('** ', '**').sub(' **', '**')
39
+ match.strip.sub("** ", "**").sub(" **", "**")
41
40
  end
42
41
  end
43
42
 
44
- result = result.gsub(/\s?\_{2,}.*?\_{2,}\s?/) do |match|
43
+ result = result.gsub(/\s?_{2,}.*?_{2,}\s?/) do |match|
45
44
  preserve_border_whitespaces(match, default_border: ReverseAdoc.config.tag_border) do
46
- match.strip.sub('__ ', '__').sub(' __', '__')
45
+ match.strip.sub("__ ", "__").sub(" __", "__")
47
46
  end
48
47
  end
49
48
 
50
49
  result = result.gsub(/\s?~{2,}.*?~{2,}\s?/) do |match|
51
50
  preserve_border_whitespaces(match, default_border: ReverseAdoc.config.tag_border) do
52
- match.strip.sub('~~ ', '~~').sub(' ~~', '~~')
51
+ match.strip.sub("~~ ", "~~").sub(" ~~", "~~")
53
52
  end
54
53
  end
55
54
 
56
55
  result.gsub(/\s?\[.*?\]\s?/) do |match|
57
56
  preserve_border_whitespaces(match) do
58
- match.strip.sub('[ ', '[').sub(' ]', ']')
57
+ match.strip.sub("[ ", "[").sub(" ]", "]")
59
58
  end
60
59
  end
61
60
  end
62
61
 
63
62
  def clean_punctuation_characters(string)
64
- string.gsub(/(\*\*|~~|__)\s([\.!\?'"])/, "\\1".strip + "\\2")
63
+ string.gsub(/(\*\*|~~|__)\s([.!?'"])/, "\\1".strip + "\\2")
65
64
  end
66
65
 
67
- # preprocesses HTML, rather than postprocessing it
66
+ # preprocesses HTML, rather than postprocessing it
68
67
  def preprocess_word_html(string)
69
68
  clean_headings(scrub_whitespace(string.dup))
70
69
  end
71
70
 
72
71
  def scrub_whitespace(string)
73
- string.gsub!(/&nbsp;|\&#xA0;|\u00a0/i, '&#xA0;') # HTML encoded spaces
74
- string.sub!(/^\A[[:space:]]+/m, '') # document leading whitespace
75
- string.sub!(/[[:space:]]+\z$/m, '') # document trailing whitespace
76
- string.gsub!(/([ ]+)$/, ' ') # line trailing whitespace
77
- string.gsub!(/\n\n\n\n/, "\n\n") # Quadruple line breaks
78
- #string.delete!('?| ') # Unicode non-breaking spaces, injected as tabs
72
+ string.gsub!(/&nbsp;|&#xA0;|\u00a0/i, "&#xA0;") # HTML encoded spaces
73
+ string.sub!(/^\A[[:space:]]+/m, "") # document leading whitespace
74
+ string.sub!(/[[:space:]]+\z$/m, "") # document trailing whitespace
75
+ string.gsub!(/( +)$/, " ") # line trailing whitespace
76
+ string.gsub!(/\n\n\n\n/, "\n\n") # Quadruple line breaks
77
+ # string.delete!('?| ') # Unicode non-breaking spaces, injected as tabs
79
78
  string
80
79
  end
81
80
 
82
81
  # following added by me
83
82
  def clean_headings(string)
84
- string.gsub!(%r{<h([1-9])[^>]*></h\1>}, " ") # I don't know why Libre Office is inserting them, but they need to go
83
+ string.gsub!(%r{<h([1-9])[^>]*></h\1>}, " ")
84
+ # I don't know why Libre Office is inserting them, but they need to go
85
85
  string.gsub!(%r{<h([1-9])[^>]* style="vertical-align: super;[^>]*>(.+?)</h\1>},
86
- "<sup>\\2</sup>") # I absolutely don't know why Libre Office is rendering superscripts as h1
86
+ "<sup>\\2</sup>")
87
+ # I absolutely don't know why Libre Office is rendering superscripts as h1
87
88
  string
88
89
  end
89
90
 
90
91
  private
91
92
 
92
- def preserve_border_whitespaces(string, options = {}, &block)
93
- return string if string =~ /\A\s*\Z/
94
- default_border = options.fetch(:default_border, '')
93
+ def preserve_border_whitespaces(string, options = {})
94
+ return string if /\A\s*\Z/.match?(string)
95
+
96
+ default_border = options.fetch(:default_border, "")
95
97
  # If the string contains part of a link so the characters [,],(,)
96
98
  # then don't add any extra spaces
97
- default_border = '' if string =~ /[\[\(\]\)]/
99
+ default_border = "" if /[\[(\])]/.match?(string)
98
100
  string_start = present_or_default(string[/\A\s*/], default_border)
99
101
  string_end = present_or_default(string[/\s*\Z/], default_border)
100
102
  result = yield
@@ -108,6 +110,5 @@ module ReverseAdoc
108
110
  string
109
111
  end
110
112
  end
111
-
112
113
  end
113
114
  end
@@ -12,7 +12,9 @@ module ReverseAdoc
12
12
  end
13
13
 
14
14
  def escape_keychars(string)
15
- string.gsub(/(?<!\\)[*_]/, '*' => '\*', '_' => '\_')
15
+ subs = { '*' => '\*', '_' => '\_' }
16
+ string
17
+ .gsub(/((?<=\s)[\*_]+)|[\*_]+(?=\s)/) { |n| n.chars.map { |char| subs[char] }.join }
16
18
  end
17
19
 
18
20
  def extract_title(node)
@@ -2,7 +2,7 @@ require "fileutils"
2
2
  require "pathname"
3
3
  require "tempfile"
4
4
  require "base64"
5
- require "mimemagic"
5
+ require "marcel"
6
6
 
7
7
  module ReverseAdoc
8
8
  module Converters
@@ -50,7 +50,7 @@ module ReverseAdoc
50
50
  f.binmode
51
51
  f.write(Base64.strict_decode64(imgdata))
52
52
  f.rewind
53
- ext = MimeMagic.by_magic(f).subtype
53
+ ext = Marcel::MimeType.for(f).sub(%r{^[^/]+/}, "")
54
54
  [ext, f.path]
55
55
  end
56
56
  end
@@ -1,51 +1,51 @@
1
1
  # frozen_string_literal: true
2
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'
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
36
 
37
37
  module ReverseAdoc
38
38
  class HtmlConverter
39
39
  def self.convert(input, options = {})
40
40
  root = if input.is_a?(String)
41
41
  then Nokogiri::HTML(input).root
42
- elsif input.is_a?(Nokogiri::XML::Document)
42
+ elsif input.is_a?(Nokogiri::XML::Document)
43
43
  then input.root
44
- elsif input.is_a?(Nokogiri::XML::Node)
44
+ elsif input.is_a?(Nokogiri::XML::Node)
45
45
  then input
46
- end
46
+ end
47
47
 
48
- root || (return '')
48
+ root || (return "")
49
49
 
50
50
  ReverseAdoc.config.with(options) do
51
51
  result = ReverseAdoc::Converters.lookup(root.name).convert(root)
@@ -53,4 +53,4 @@ module ReverseAdoc
53
53
  end
54
54
  end
55
55
  end
56
- end
56
+ end
@@ -1,3 +1,3 @@
1
1
  module ReverseAdoc
2
- VERSION = '0.2.10'
2
+ VERSION = "0.3.4".freeze
3
3
  end
data/reverse_adoc.gemspec CHANGED
@@ -1,5 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ $:.push File.expand_path("lib", __dir__)
3
4
  require "reverse_adoc/version"
4
5
 
5
6
  Gem::Specification.new do |s|
@@ -9,29 +10,30 @@ Gem::Specification.new do |s|
9
10
  s.email = ["open.source@ribose.com"]
10
11
 
11
12
  s.homepage = "http://github.com/metanorma/reverse_adoc"
12
- s.summary = %q{Generate AsciiDoc from HTML and Microsoft Word via CLI or library.}
13
- s.description = %q{Generate AsciiDoc from HTML and Microsoft Word via CLI or library.}
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 -- bin/*`.split("\n").map{ |f| File.basename(f) }
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
- s.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
22
+ s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
21
23
 
22
24
  # specify any dependencies here; for example:
23
- s.add_dependency 'nokogiri', ">= 1.10.4"
24
- s.add_dependency 'mathml2asciimath'
25
- s.add_dependency 'mimemagic'
26
- s.add_development_dependency 'rspec'
27
- s.add_development_dependency 'simplecov'
28
- s.add_development_dependency 'rake'
29
- s.add_development_dependency 'redcarpet'
30
- s.add_development_dependency 'codeclimate-test-reporter'
25
+ s.add_dependency "marcel", "~> 1.0.0"
26
+ s.add_dependency "mathml2asciimath"
27
+ s.add_dependency "nokogiri", "~> 1.12"
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 'word-to-markdown'
36
- s.add_dependency 'premailer', '~> 1.11.0'
37
+ s.add_dependency "premailer", "~> 1.11.0"
38
+ s.add_dependency "word-to-markdown"
37
39
  end
@@ -4,8 +4,10 @@
4
4
 
5
5
  **two asterisks**
6
6
  ***three asterisks***
7
+ ***three *and*the* asterisc*word and asterisc**multword asterisks***
7
8
  __two underscores__
8
9
  ___three underscores___
10
+ ___three__underscores___ and another_undersocre
9
11
 
10
12
  some text...
11
13
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe 'bin/revrse_adoc' do
5
+ describe 'exe/revrse_adoc' do
6
6
  subject(:convert) do
7
- ShellUtils.execute!("./bin/reverse_adoc -e -o test1 #{input_file_path}")
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 'bin/w2a' do
5
+ describe 'exe/w2a' do
6
6
  subject(:convert) do
7
- ShellUtils.execute!("./bin/w2a -e -o test1 #{input_file_path}")
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 'exatracts images from source html' do
25
+ it 'extracts images from source html' do
26
26
  expect { convert }
27
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']))
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
@@ -8,7 +8,7 @@ describe ReverseAdoc do
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/ }
@@ -25,4 +25,3 @@ describe ReverseAdoc do
25
25
  end
26
26
 
27
27
  end
28
-
@@ -9,6 +9,9 @@ describe ReverseAdoc do
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 ReverseAdoc 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
@@ -8,4 +8,3 @@ describe ReverseAdoc do
8
8
 
9
9
  it { is_expected.to eq("naked text 1\n\nparagraph text\n\nnaked text 2") }
10
10
  end
11
-
@@ -36,4 +36,3 @@ describe ReverseAdoc do
36
36
  it { expect { result }.to raise_error(ReverseAdoc::InvalidConfigurationError) }
37
37
  end
38
38
  end
39
-
@@ -15,4 +15,3 @@ describe ReverseAdoc::Converters::Audio do
15
15
  end
16
16
 
17
17
  end
18
-
@@ -15,4 +15,3 @@ describe ReverseAdoc::Converters::Code do
15
15
  end
16
16
 
17
17
  end
18
-
@@ -15,4 +15,3 @@ describe ReverseAdoc::Converters::Code do
15
15
  end
16
16
 
17
17
  end
18
-
@@ -10,4 +10,3 @@ describe ReverseAdoc::Converters::Figure do
10
10
 
11
11
  end
12
12
  end
13
-
@@ -25,4 +25,3 @@ describe ReverseAdoc::Converters::Img do
25
25
  end
26
26
 
27
27
  end
28
-
@@ -9,4 +9,3 @@ describe ReverseAdoc::Converters::P do
9
9
  expect(converter.convert(node)).to include "\n[[A]]\nputs foo"
10
10
  end
11
11
  end
12
-
@@ -42,4 +42,3 @@ describe ReverseAdoc::Converters::Pre do
42
42
  end
43
43
  end
44
44
  end
45
-
@@ -15,4 +15,3 @@ describe ReverseAdoc::Converters::Video do
15
15
  end
16
16
 
17
17
  end
18
-
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reverse_adoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-16 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: nokogiri
14
+ name: marcel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.10.4
19
+ version: 1.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.10.4
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mathml2asciimath
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,21 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: mimemagic
42
+ name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.12'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.12'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: codeclimate-test-reporter
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: simplecov
70
+ name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rake
84
+ name: redcarpet
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: redcarpet
98
+ name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: codeclimate-test-reporter
112
+ name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,33 +123,33 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: word-to-markdown
126
+ name: premailer
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: 1.11.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0'
138
+ version: 1.11.0
139
139
  - !ruby/object:Gem::Dependency
140
- name: premailer
140
+ name: word-to-markdown
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 1.11.0
145
+ version: '0'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: 1.11.0
152
+ version: '0'
153
153
  description: Generate AsciiDoc from HTML and Microsoft Word via CLI or library.
154
154
  email:
155
155
  - open.source@ribose.com
@@ -159,18 +159,18 @@ executables:
159
159
  extensions: []
160
160
  extra_rdoc_files: []
161
161
  files:
162
- - ".github/workflows/macos.yml"
163
- - ".github/workflows/ubuntu.yml"
164
- - ".github/workflows/windows.yml"
162
+ - ".editorconfig"
163
+ - ".github/workflows/rake.yml"
164
+ - ".github/workflows/release.yml"
165
+ - ".gitignore"
165
166
  - ".hound.yml"
166
167
  - ".rubocop.yml"
167
168
  - Gemfile
168
- - Gemfile.lock
169
169
  - LICENSE.txt
170
170
  - README.adoc
171
171
  - Rakefile
172
- - bin/reverse_adoc
173
- - bin/w2a
172
+ - exe/reverse_adoc
173
+ - exe/w2a
174
174
  - lib/reverse_adoc.rb
175
175
  - lib/reverse_adoc/cleaner.rb
176
176
  - lib/reverse_adoc/config.rb
@@ -275,14 +275,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - ">="
277
277
  - !ruby/object:Gem::Version
278
- version: 2.4.0
278
+ version: 2.5.0
279
279
  required_rubygems_version: !ruby/object:Gem::Requirement
280
280
  requirements:
281
281
  - - ">="
282
282
  - !ruby/object:Gem::Version
283
283
  version: '0'
284
284
  requirements: []
285
- rubygems_version: 3.0.6
285
+ rubygems_version: 3.2.22
286
286
  signing_key:
287
287
  specification_version: 4
288
288
  summary: Generate AsciiDoc from HTML and Microsoft Word via CLI or library.
@@ -1,41 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: macos
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/ubuntu.yml
11
- - .github/workflows/windows.yml
12
-
13
- jobs:
14
- test-macos:
15
- name: Test on Ruby ${{ matrix.ruby }} macOS
16
- runs-on: macos-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Update gems
33
- run: |
34
- sudo gem install bundler --force
35
- bundle install --jobs 4 --retry 3
36
- - name: Install LibreOffice
37
- run: |
38
- brew cask install libreoffice
39
- - name: Run specs
40
- run: |
41
- bundle exec rake
@@ -1,40 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: ubuntu
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/macos.yml
11
- - .github/workflows/windows.yml
12
-
13
- jobs:
14
- test-linux:
15
- name: Test on Ruby ${{ matrix.ruby }} Ubuntu
16
- runs-on: ubuntu-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Install LibreOffice
33
- run: sudo apt-get -y --no-install-recommends install libreoffice
34
- - name: Update gems
35
- run: |
36
- gem install bundler
37
- bundle install --jobs 4 --retry 3
38
- - name: Run specs
39
- run: |
40
- bundle exec rake
@@ -1,44 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: windows
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/macos.yml
11
- - .github/workflows/ubuntu.yml
12
-
13
- jobs:
14
- test-windows:
15
- name: Test on Ruby ${{ matrix.ruby }} Windows
16
- runs-on: windows-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Install LibreOffice
33
- run: |
34
- choco install libreoffice-still
35
- echo "::add-path::C:\Program Files\LibreOffice\program"
36
- - name: Update gems
37
- shell: pwsh
38
- run: |
39
- gem install bundler
40
- bundle config --local path vendor/bundle
41
- bundle install --jobs 4 --retry 3
42
- - name: Run specs
43
- run: |
44
- bundle exec rake
data/Gemfile.lock DELETED
@@ -1,85 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- reverse_adoc (0.2.10)
5
- mathml2asciimath
6
- mimemagic
7
- nokogiri (>= 1.10.4)
8
- premailer (~> 1.11.0)
9
- word-to-markdown
10
-
11
- GEM
12
- remote: https://rubygems.org/
13
- specs:
14
- addressable (2.7.0)
15
- public_suffix (>= 2.0.2, < 5.0)
16
- byebug (11.1.1)
17
- cliver (0.3.2)
18
- codeclimate-test-reporter (1.0.7)
19
- simplecov
20
- css_parser (1.7.1)
21
- addressable
22
- descriptive_statistics (2.5.1)
23
- diff-lcs (1.3)
24
- docile (1.3.2)
25
- ffi (1.13.1)
26
- htmlentities (4.3.4)
27
- mathml2asciimath (0.0.10)
28
- htmlentities (~> 4.3.4)
29
- nokogiri (>= 1.10.4)
30
- mimemagic (0.3.5)
31
- mini_portile2 (2.4.0)
32
- nokogiri (1.10.10)
33
- mini_portile2 (~> 2.4.0)
34
- nokogiri-styles (0.1.2)
35
- nokogiri
36
- premailer (1.11.1)
37
- addressable
38
- css_parser (>= 1.6.0)
39
- htmlentities (>= 4.0.0)
40
- public_suffix (4.0.6)
41
- rake (13.0.1)
42
- redcarpet (3.5.0)
43
- reverse_markdown (1.4.0)
44
- nokogiri
45
- rspec (3.9.0)
46
- rspec-core (~> 3.9.0)
47
- rspec-expectations (~> 3.9.0)
48
- rspec-mocks (~> 3.9.0)
49
- rspec-core (3.9.1)
50
- rspec-support (~> 3.9.1)
51
- rspec-expectations (3.9.0)
52
- diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.9.0)
54
- rspec-mocks (3.9.1)
55
- diff-lcs (>= 1.2.0, < 2.0)
56
- rspec-support (~> 3.9.0)
57
- rspec-support (3.9.2)
58
- simplecov (0.18.5)
59
- docile (~> 1.1)
60
- simplecov-html (~> 0.11)
61
- simplecov-html (0.12.1)
62
- sys-proctable (1.2.6)
63
- ffi
64
- word-to-markdown (1.1.8)
65
- cliver (~> 0.3)
66
- descriptive_statistics (~> 2.5)
67
- nokogiri-styles (~> 0.1)
68
- premailer (~> 1.8)
69
- reverse_markdown (~> 1.0)
70
- sys-proctable (~> 1.0)
71
-
72
- PLATFORMS
73
- ruby
74
-
75
- DEPENDENCIES
76
- byebug
77
- codeclimate-test-reporter
78
- rake
79
- redcarpet
80
- reverse_adoc!
81
- rspec
82
- simplecov
83
-
84
- BUNDLED WITH
85
- 2.0.2