metanorma 1.0.1 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b847f719ea09aa03edc9b67fc73f955c682bbff4690c0d5cea06561f7fbc478
4
- data.tar.gz: c545afe2938e475a9360d5ae5bd1031920de4c279edf1d1860b83ee287367faf
3
+ metadata.gz: 0b51503237da3dfd54719591c47f599bca877d414528c4cf9a69abdb19aec9e9
4
+ data.tar.gz: 1588206551663889040f94194789cee7f2fb9b095775591a08f7b613ce59fbfe
5
5
  SHA512:
6
- metadata.gz: 98b3f3268ce2ac4f60d71ecff97abe398e4c49ad84ff2d8759c486a3b87788c556e23b10454b9c67b352b8a86418587c969290072ee42d131d0449af030b3466
7
- data.tar.gz: 3f3cf0eb527bf6d2b7db8438d01206961e57bdb2e7249d43537dd635c4bbac3e293b50fd5dcf7f3c069c542c454aa3b2356021aafeecd5ae0fb6c8cf3b198f4f
6
+ metadata.gz: 6f7dd77c9a6bf129594e3bfdabc1626bcb4c58a9b68454b09e1d216f7c9e43d4ebce62ce980ed762e0ad3e9f5c3c3456b9473fe7b1670e13bdc7c2d286edc1ec
7
+ data.tar.gz: 9c4125021226bdd561436e37e2fbacd4bd3c3bfa48845607282dd7ce3b4789e218e2aaa835364de7268c684bbf667e5267a6224db5a4c268fce180136b835391
@@ -6,15 +6,23 @@ 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
@@ -29,10 +37,10 @@ jobs:
29
37
  - name: Use Node
30
38
  uses: actions/setup-node@v1
31
39
  with:
32
- node-version: '8'
40
+ node-version: '12'
33
41
  - name: Install Puppeteer
34
42
  run: |
35
- npm install -g puppeteer
43
+ npm install -g puppeteer@3.0.1
36
44
  - name: Run specs
37
45
  run: |
38
46
  bundle exec rake
@@ -6,15 +6,23 @@ 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
@@ -29,15 +37,17 @@ jobs:
29
37
  - name: Use Node
30
38
  uses: actions/setup-node@v1
31
39
  with:
32
- node-version: '8'
40
+ node-version: '12'
33
41
  - name: Install Puppeteer
34
42
  run: |
35
- npm install -g puppeteer
43
+ sudo apt-get update
44
+ sudo apt-get install libgbm1
45
+ npm install -g puppeteer@3.0.1
36
46
  - name: Run specs
37
47
  run: |
38
48
  bundle exec rake
39
49
  - name: Trigger dependent repositories
40
- if: github.ref == 'refs/heads/master'
50
+ if: github.ref == 'refs/heads/master' && matrix.ruby == '2.6'
41
51
  env:
42
52
  GH_USERNAME: ${{ secrets.PAT_USERNAME }}
43
53
  GH_ACCESS_TOKEN: ${{ secrets.PAT_TOKEN }}
@@ -6,15 +6,23 @@ 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
@@ -31,10 +39,10 @@ jobs:
31
39
  - name: Use Node
32
40
  uses: actions/setup-node@v1
33
41
  with:
34
- node-version: '8'
42
+ node-version: '12'
35
43
  - name: Install Puppeteer
36
44
  run: |
37
- npm install -g puppeteer
45
+ npm install -g puppeteer@3.0.1
38
46
  - name: Run specs
39
47
  run: |
40
48
  bundle exec rake
@@ -9,9 +9,9 @@ module Metanorma
9
9
  end
10
10
 
11
11
  def compile(filename, options = {})
12
+ require_libraries(options)
12
13
  options = options_extract(filename, options)
13
14
  validate(options) or return nil
14
- require_libraries(options)
15
15
  @processor = @registry.find_processor(options[:type].to_sym)
16
16
  extensions = get_extensions(options) or return nil
17
17
  (file, isodoc = process_input(filename, options)) or return nil
@@ -103,7 +103,7 @@ module Metanorma
103
103
  def process_input(filename, options)
104
104
  case extname = File.extname(filename)
105
105
  when ".adoc"
106
- Util.log("[metanorma] Processing: Asciidoctor input.", :info)
106
+ Util.log("[metanorma] Processing: AsciiDoc input.", :info)
107
107
  file = read_file(filename)
108
108
  options[:asciimath] and
109
109
  file.sub!(/^(=[^\n]+\n)/, "\\1:mn-keep-asciimath:\n")
@@ -205,7 +205,11 @@ module Metanorma
205
205
  options[:relaton] = outfilename
206
206
  relaton_export(isodoc, options)
207
207
  else
208
+ begin
208
209
  @processor.output(isodoc, outfilename, ext, isodoc_options)
210
+ rescue StandardError => e
211
+ puts e.message
212
+ end
209
213
  end
210
214
  if options[:wrapper] and /html$/.match file_extension
211
215
  outfilename = outfilename.sub(/\.html$/, "")
@@ -34,6 +34,10 @@ module Metanorma
34
34
  }.reject { |_, val| val.nil? }
35
35
  end
36
36
 
37
+ def empty_attr(attr, name)
38
+ attr&.sub(/^#{name}:\s*$/, "#{name}: true")&.sub(/^#{name}:\s+/, "")
39
+ end
40
+
37
41
  def extract_options(file)
38
42
  headerextract = file.sub(/\n\n.*$/m, "\n")
39
43
 
@@ -58,7 +62,16 @@ module Metanorma
58
62
  /\n:data-uri-image: (?<datauriimage>[^\n]+)\n/ =~ headerextract
59
63
  /\n:htmltoclevels: (?<htmltoclevels>[^\n]+)\n/ =~ headerextract
60
64
  /\n:doctoclevels: (?<doctoclevels>[^\n]+)\n/ =~ headerextract
61
- /\n:hierarchical-assets: (?<hierarchical_assets>[^\n]+)\n/ =~ headerextract
65
+ /\n:(?<hierarchical_assets>hierarchical-assets:[^\n]*)\n/ =~ headerextract
66
+ /\n:(?<use_xinclude>use-xinclude:[^\n]*)\n/ =~ headerextract
67
+ /\n:(?<break_up_urls_in_tables>break-up-urls-in-tables:[^\n]*)\n/ =~ headerextract
68
+
69
+ defined?(hierarchical_assets) and
70
+ hierarchical_assets = empty_attr(hierarchical_assets, "hierarchical-assets")
71
+ defined?(use_xinclude) and
72
+ use_xinclude = empty_attr(use_xinclude, "use-xinclude")
73
+ defined?(break_up_urls_in_tables) and
74
+ break_up_urls_in_tables = empty_attr(break_up_urls_in_tables, "break-up-urls-in-tables")
62
75
  {
63
76
  script: defined?(script) ? script : nil,
64
77
  bodyfont: defined?(bodyfont) ? bodyfont : nil,
@@ -82,6 +95,8 @@ module Metanorma
82
95
  htmltoclevels: defined?(htmltoclevels) ? htmltoclevels : nil,
83
96
  doctoclevels: defined?(doctoclevels) ? doctoclevels : nil,
84
97
  hierarchical_assets: defined?(hierarchical_assets) ? hierarchical_assets : nil,
98
+ use_xinclude: defined?(use_xinclude) ? use_xinclude : nil,
99
+ break_up_urls_in_tables: defined?(break_up_urls_in_tables) ? break_up_urls_in_tables : nil,
85
100
  }.reject { |_, val| val.nil? }
86
101
  end
87
102
 
@@ -1,5 +1,6 @@
1
1
  require_relative "./output/base"
2
2
  require_relative "./output/pdf"
3
+ require_relative "./output/xslfo"
3
4
 
4
5
  module Metanorma
5
6
  module Output
@@ -1,4 +1,5 @@
1
1
  require "open3"
2
+ require_relative "./utils.rb"
2
3
  require "pathname"
3
4
  require "shellwords"
4
5
 
@@ -7,9 +8,7 @@ module Metanorma
7
8
  class Pdf < Base
8
9
 
9
10
  def convert(url_path, output_path)
10
- file_url = url_path
11
- file_url = "file://#{url_path}" if Pathname.new(file_url).absolute?
12
- file_url = "file://#{Dir.pwd}/#{url_path}" unless %r{^file://} =~ file_url
11
+ file_url = Utils::file_path(url_path)
13
12
  pdfjs = File.join(File.dirname(__FILE__), "../../../bin/metanorma-pdf.js")
14
13
 
15
14
  node_path = ENV["NODE_PATH"] || `npm root --quiet -g`.strip
@@ -0,0 +1,16 @@
1
+ require "pathname"
2
+
3
+ module Metanorma
4
+ module Output
5
+ module Utils
6
+ class << self
7
+ def file_path(url_path)
8
+ file_url = url_path
9
+ file_url = "file://#{url_path}" if Pathname.new(file_url).absolute?
10
+ file_url = "file://#{Dir.pwd}/#{url_path}" unless %r{^file://} =~ file_url
11
+ file_url
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ require 'mn2pdf'
2
+ require_relative "./utils.rb"
3
+
4
+ module Metanorma
5
+ module Output
6
+ class XslfoPdf < Base
7
+ def convert(url_path, output_path, xsl_stylesheet)
8
+ return if url_path.nil? || output_path.nil? || xsl_stylesheet.nil?
9
+
10
+ Mn2pdf.convert(url_path, output_path, xsl_stylesheet)
11
+ end
12
+ end
13
+ end
14
+ end
15
+
@@ -48,7 +48,7 @@ module Metanorma
48
48
  @processors.inject({}) do |acc, (k,v)|
49
49
  if v.asciidoctor_backend
50
50
  x = Asciidoctor.load nil, {backend: v.asciidoctor_backend}
51
- acc[k] = x.converter.class::XML_ROOT_TAG
51
+ acc[k] = x.converter.xml_root_tag
52
52
  end
53
53
  acc
54
54
  end
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.6"
3
3
  end
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_runtime_dependency 'asciidoctor'
27
27
  spec.add_runtime_dependency 'htmlentities'
28
28
  spec.add_runtime_dependency 'nokogiri'
29
+ spec.add_runtime_dependency 'mn2pdf', "~> 1"
29
30
 
30
31
  spec.add_development_dependency "rake", "~> 12.0"
31
32
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-03 00:00:00.000000000 Z
11
+ date: 2020-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mn2pdf
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -177,6 +191,8 @@ files:
177
191
  - lib/metanorma/output.rb
178
192
  - lib/metanorma/output/base.rb
179
193
  - lib/metanorma/output/pdf.rb
194
+ - lib/metanorma/output/utils.rb
195
+ - lib/metanorma/output/xslfo.rb
180
196
  - lib/metanorma/processor.rb
181
197
  - lib/metanorma/registry.rb
182
198
  - lib/metanorma/util.rb