metanorma 0.2.2 → 0.2.3

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: fb95e4682cc1dd93a06c5c535647d4ad80ce55ed7a5e249de095f523dadfcd33
4
- data.tar.gz: 423951596f64008539514331a2b5b5bf0c91c3957bd8853df7cb3c7d8db582b5
3
+ metadata.gz: 99633abe164a9d72691d8b84c6f24fc55833ecba84c3488c3639c20576dd1c74
4
+ data.tar.gz: 4253c7ed5ef852b58323623c42b2be8ae75abae69ee2a47d7ee6b2c6d65c0117
5
5
  SHA512:
6
- metadata.gz: baa84d18f7109e43e04f66052076490ea5c43379a64c0f1b03b548a85dc6d59ca2826436bfbf102923bf91b3206c98279056b3d313754b8f8c0bdd98eb0bead6
7
- data.tar.gz: 9f6d285f34a46e4d215cb2b3f8325906b17065d5b3689b709419d6dd3d3f5e792140a3c697bd6f7e03ea043d3e78d8bb6b1573cd4431c4031c543ae8feb485c9
6
+ metadata.gz: 48593b786f081e33d578e284712f40698989269121464e4b9bab7f7a79e1fff323f97514960364a72a18c8d244f17bd1863a748f679bb046d8d079e3003e7dd1
7
+ data.tar.gz: fec2ed02e9f5f6016d54dc11f9e2f5709ba09f79c71a4d73dc5070a194b585fc7eac2d8f8f3641087f596e2047505bb99fce64fe3a4ff55ef9d26d79757b3e81
@@ -1,5 +1,12 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.3
5
- before_install: gem install bundler -v 1.16.1
4
+ - 2.5.1
5
+ node_js:
6
+ - "iojs"
7
+ - "8"
8
+ before_install:
9
+ - gem install bundler -v 1.16.1
10
+ - npm install -g puppeteer
11
+ - npm install
12
+
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metanorma (0.2.1)
4
+ metanorma (0.2.2)
5
5
  asciidoctor-csand (>= 0.3.0)
6
6
  asciidoctor-csd (>= 0.4.0)
7
7
  asciidoctor-gb (>= 0.3.0)
8
- asciidoctor-iso (>= 0.9.0)
8
+ asciidoctor-iso (>= 0.9.1)
9
9
  asciidoctor-m3d (>= 0.3.1)
10
10
  asciidoctor-rfc (>= 0.9.0)
11
11
  asciidoctor-rsd (>= 0.3.0)
@@ -38,7 +38,7 @@ GEM
38
38
  asciidoctor-iso (>= 0.9.0)
39
39
  isodoc (>= 0.8.0)
40
40
  twitter_cldr
41
- asciidoctor-iso (0.9.0)
41
+ asciidoctor-iso (0.9.1)
42
42
  asciidoctor (~> 1.5.7)
43
43
  iso-bib-item (~> 0.1.6)
44
44
  isobib (~> 0.1.6)
@@ -63,7 +63,7 @@ GEM
63
63
  nokogiri
64
64
  ruby-jing
65
65
  thread_safe
66
- asciidoctor-rsd (0.3.0)
66
+ asciidoctor-rsd (0.3.1)
67
67
  asciidoctor (~> 1.5.7)
68
68
  asciidoctor-iso (>= 0.8.0)
69
69
  asciimath
@@ -77,10 +77,13 @@ GEM
77
77
  thread_safe
78
78
  uuidtools
79
79
  asciimath (1.0.4)
80
+ byebug (10.0.2)
80
81
  camertron-eprun (1.1.1)
81
82
  cldr-plurals-runtime-rb (1.0.1)
82
83
  diff-lcs (1.3)
83
84
  duplicate (1.1.1)
85
+ equivalent-xml (0.6.0)
86
+ nokogiri (>= 1.4.3)
84
87
  ffi (1.9.25)
85
88
  html2doc (0.8.0)
86
89
  asciimath
@@ -94,11 +97,11 @@ GEM
94
97
  htmlentities (4.3.4)
95
98
  httpclient (2.8.3)
96
99
  image_size (2.0.0)
97
- iso-bib-item (0.1.6)
100
+ iso-bib-item (0.1.8)
98
101
  duplicate
99
102
  isoics (~> 0.1.6)
100
103
  nokogiri
101
- isobib (0.1.6)
104
+ isobib (0.1.7)
102
105
  algoliasearch
103
106
  iso-bib-item (~> 0.1.2)
104
107
  isodoc (0.8)
@@ -121,6 +124,7 @@ GEM
121
124
  mime-types-data (~> 3.2015)
122
125
  mime-types-data (3.2016.0521)
123
126
  mini_portile2 (2.3.0)
127
+ mixlib-shellout (2.3.2)
124
128
  nokogiri (1.8.3)
125
129
  mini_portile2 (~> 2.3.0)
126
130
  optout (0.0.2)
@@ -133,11 +137,18 @@ GEM
133
137
  rspec-core (~> 3.7.0)
134
138
  rspec-expectations (~> 3.7.0)
135
139
  rspec-mocks (~> 3.7.0)
140
+ rspec-command (1.0.3)
141
+ mixlib-shellout (~> 2.0)
142
+ rspec (~> 3.2)
143
+ rspec-its (~> 1.2)
136
144
  rspec-core (3.7.1)
137
145
  rspec-support (~> 3.7.0)
138
146
  rspec-expectations (3.7.0)
139
147
  diff-lcs (>= 1.2.0, < 2.0)
140
148
  rspec-support (~> 3.7.0)
149
+ rspec-its (1.2.0)
150
+ rspec-core (>= 3.0.0)
151
+ rspec-expectations (>= 3.0.0)
141
152
  rspec-mocks (3.7.0)
142
153
  diff-lcs (>= 1.2.0, < 2.0)
143
154
  rspec-support (~> 3.7.0)
@@ -164,9 +175,12 @@ PLATFORMS
164
175
 
165
176
  DEPENDENCIES
166
177
  bundler (~> 1.16)
178
+ byebug (~> 10.0)
179
+ equivalent-xml (~> 0.6)
167
180
  metanorma!
168
181
  rake (~> 10.0)
169
182
  rspec (~> 3.0)
183
+ rspec-command (~> 1.0.3)
170
184
 
171
185
  BUNDLED WITH
172
186
  1.16.2
@@ -62,6 +62,7 @@ Usage: metanorma [options] <file>
62
62
  :m3d=>{:html=>"html", :doc=>"doc"},
63
63
  :rsd=>{:html=>"html"}
64
64
  }
65
+ In addition, xml (outside of rfc2, rfc3) generates IsoDoc XML
65
66
  -f, --format FORMAT Format of source file: asciidoc (current default, only format supported)
66
67
  -r, --require LIBRARY Require LIBRARY prior to execution
67
68
  -h, --help Show this message
@@ -41,7 +41,8 @@ opt_parser = OptionParser.new do |opts|
41
41
  '-x',
42
42
  '--extensions EXT1,EXT2,...',
43
43
  Array,
44
- "Type of extension to generate per type: #{registry.output_formats}"
44
+ "Type of extension to generate per type: #{registry.output_formats}\n"\
45
+ "In addition, xml (outside of rfc2, rfc3) generates IsoDoc XML"
45
46
  ) { |v| options[:extension_keys] = v.map(&:to_sym) }
46
47
 
47
48
  opts.on(
@@ -62,7 +63,7 @@ opt_parser = OptionParser.new do |opts|
62
63
  opts.on(
63
64
  '-v',
64
65
  '--version',
65
- "Print version of code",
66
+ "Print version of code (accompanied with -t)",
66
67
  ) { options[:version] = true }
67
68
 
68
69
  opts.on_tail("-h", "--help", "Show this message") do
@@ -74,23 +75,13 @@ end
74
75
 
75
76
  opt_parser.parse!(ARGV)
76
77
 
77
- # TODO: move this to individual Processors
78
78
  if options[:version]
79
- case options[:type]
80
- when :iso
81
- puts "Asciidoctor::ISO #{Asciidoctor::ISO::VERSION}/IsoDoc #{IsoDoc::VERSION}"
82
- when :gb
83
- puts "Asciidoctor::Gb #{Asciidoctor::Gb::VERSION}"
84
- when :csd
85
- puts "Asciidoctor::Csd #{Asciidoctor::Csd::VERSION}"
86
- when :csand
87
- puts "Asciidoctor::Csand #{Asciidoctor::Csand::VERSION}"
88
- when :m3d
89
- puts "Asciidoctor::M3d #{Asciidoctor::M3d::VERSION}"
90
- when :rsd
91
- puts "Asciidoctor::Rsd #{Asciidoctor::Rsd::VERSION}"
79
+ case options[:format]
80
+ when :asciidoc
81
+ processor = registry.find_processor(options[:type].to_sym)
82
+ puts processor.version
83
+ exit
92
84
  end
93
- exit
94
85
  end
95
86
 
96
87
  options[:filename] = ARGV.pop
@@ -126,16 +117,30 @@ case options[:format]
126
117
  when :asciidoc
127
118
  processor = registry.find_processor(options[:type].to_sym)
128
119
 
120
+ options[:extension_keys] ||= processor.output_formats.inject([]) do |memo, (k, _)|
121
+ memo << k; memo
122
+ end
123
+ extensions = options[:extension_keys].inject([]) do |memo, e|
124
+ if processor.output_formats[e] || e == :xml then memo << e
125
+ else
126
+ warn "[metanorma] Error: #{e} format is not supported for this standard"
127
+ end
128
+ memo
129
+ end
130
+ exit 0 if extensions.empty?
131
+
129
132
  file = File.read(options[:filename], encoding: "utf-8")
130
133
  isodoc = processor.input_to_isodoc(file)
134
+ isodoc_options = processor.extract_options(file)
131
135
 
132
- options[:extension_keys].each do |ext|
133
-
134
- file_extension = processor.output_formats[ext]
136
+ extensions.each do |ext|
137
+ file_extension = ext == :xml ? "xml" : processor.output_formats[ext]
135
138
  outfilename = options[:filename].sub(/\.[^.]+$/, ".#{file_extension}")
136
- # puts "made outfilename #{outfilename}"
137
- processor.output(isodoc, outfilename, ext)
138
-
139
+ if ext == :xml
140
+ File.open(outfilename, "w:UTF-8") { |f| f.write(isodoc) }
141
+ else
142
+ processor.output(isodoc, outfilename, ext, isodoc_options)
143
+ end
139
144
  end
140
145
  end
141
146
 
@@ -18,12 +18,12 @@ module Metanorma
18
18
  def extract_options(file)
19
19
  header = file.sub(/\n\n.*$/m, "")
20
20
 
21
- /\nscript: (?<script>[^\n]+)\n/ =~ header
22
- /\nbody-font: (?<bodyfont>[^\n]+)\n/ =~ header
23
- /\nheader-font: (?<headerfont>[^\n]+)\n/ =~ header
24
- /\nmonospace-font: (?<monospacefont>[^\n]+)\n/ =~ header
25
- /\ntitle-font: (?<titlefont>[^\n]+)\n/ =~ header
26
- /\ni18nyaml: (?<ni18nyaml>[^\n]+)\n/ =~ header
21
+ /\n:script: (?<script>[^\n]+)\n/ =~ header
22
+ /\n:body-font: (?<bodyfont>[^\n]+)\n/ =~ header
23
+ /\n:header-font: (?<headerfont>[^\n]+)\n/ =~ header
24
+ /\n:monospace-font: (?<monospacefont>[^\n]+)\n/ =~ header
25
+ /\n:title-font: (?<titlefont>[^\n]+)\n/ =~ header
26
+ /\n:i18nyaml: (?<ni18nyaml>[^\n]+)\n/ =~ header
27
27
  {
28
28
  script: defined?(script) ? script : nil,
29
29
  bodyfont: defined?(bodyfont) ? bodyfont : nil,
@@ -31,7 +31,7 @@ module Metanorma
31
31
  monospacefont: defined?(monospacefont) ? monospacefont : nil,
32
32
  titlefont: defined?(titlefont) ? titlefont : nil,
33
33
  i18nyaml: defined?(i18nyaml) ? i18nyaml : nil,
34
- }.reject { |_, val| val.nil? }.map
34
+ }.reject { |_, val| val.nil? }
35
35
  end
36
36
 
37
37
  end
@@ -5,8 +5,6 @@ module Metanorma
5
5
  def convert(url_path, output_path)
6
6
  file_url = "file://#{Dir.pwd}/#{url_path}"
7
7
  pdfjs = File.join(File.dirname(__FILE__), '../../../exe/metanorma-pdf.js')
8
- puts "export NODE_PATH=$(npm root --quiet -g);
9
- node #{pdfjs} #{file_url} #{output_path}"
10
8
  system "export NODE_PATH=$(npm root --quiet -g);
11
9
  node #{pdfjs} #{file_url} #{output_path}"
12
10
  end
@@ -23,5 +23,8 @@ module Metanorma
23
23
  raise "This is an abstract class!"
24
24
  end
25
25
 
26
+ def extract_options(file)
27
+ Metanorma::Input::Asciidoc.new.extract_options(file)
28
+ end
26
29
  end
27
30
  end
@@ -3,6 +3,9 @@
3
3
 
4
4
  require 'singleton'
5
5
 
6
+ class Error < StandardError
7
+ end
8
+
6
9
  module Metanorma
7
10
  class Registry
8
11
  include Singleton
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -22,13 +22,16 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.required_ruby_version = '>= 2.3.0'
25
+ spec.required_ruby_version = '>= 2.5.0'
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.16"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "byebug", "~> 10.0"
31
+ spec.add_development_dependency "rspec-command", "~> 1.0.3"
32
+ spec.add_development_dependency "equivalent-xml", "~> 0.6"
30
33
 
31
- spec.add_runtime_dependency 'asciidoctor-iso', ">= 0.9.0"
34
+ spec.add_runtime_dependency 'asciidoctor-iso', ">= 0.9.1"
32
35
  spec.add_runtime_dependency 'asciidoctor-rfc', ">= 0.9.0"
33
36
  spec.add_runtime_dependency 'asciidoctor-gb', ">= 0.3.0"
34
37
  spec.add_runtime_dependency 'asciidoctor-csd', ">= 0.4.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: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-20 00:00:00.000000000 Z
11
+ date: 2018-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,20 +52,62 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-command
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: equivalent-xml
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.6'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: asciidoctor-iso
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
101
  - - ">="
60
102
  - !ruby/object:Gem::Version
61
- version: 0.9.0
103
+ version: 0.9.1
62
104
  type: :runtime
63
105
  prerelease: false
64
106
  version_requirements: !ruby/object:Gem::Requirement
65
107
  requirements:
66
108
  - - ">="
67
109
  - !ruby/object:Gem::Version
68
- version: 0.9.0
110
+ version: 0.9.1
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: asciidoctor-rfc
71
113
  requirement: !ruby/object:Gem::Requirement
@@ -214,7 +256,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
214
256
  requirements:
215
257
  - - ">="
216
258
  - !ruby/object:Gem::Version
217
- version: 2.3.0
259
+ version: 2.5.0
218
260
  required_rubygems_version: !ruby/object:Gem::Requirement
219
261
  requirements:
220
262
  - - ">="