metanorma 0.3.6 → 0.3.7

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: 6d843209061879c8c480450a7b96dcb18316b3a548b3251ecb3e2b6c82de2a83
4
- data.tar.gz: fa86d23716b90c30e67ae3a2ff591ce519e6cd93e3026acb60b02864c1d6fea8
3
+ metadata.gz: fbe49b657d41e2d71ea35393334a71bf9ae2392b9de90d696cb54783f3fe520e
4
+ data.tar.gz: 4fd60291f8196e53db4e55c3f33d6fb4705a3984f7c110ad7643997f26a2b8d1
5
5
  SHA512:
6
- metadata.gz: 456219d55650a7a12c3f7d70aba2fcdf379ce7545a511c6debc26214e47ce95ccf4234e3efad70d75af6e12999868bf9ddb00681320f039c27a7a2828d835ae7
7
- data.tar.gz: '081e968760169e138184897552b0489b2d1496f81b9b2ae23884b1eb81c082218b8a2a325cc7f3cc0358c72bea5a81659da5c8ae3ef9fedbe391faba5fe3f939'
6
+ metadata.gz: d74a51133af96c89f4c0afd0d4c0c2438865f3d8a93dd4830908fdb462df5ae40edc9c6b1a1e65b94fdb9c7923ec5bea6a9feb5e65f4637a53aba2ef499d510e
7
+ data.tar.gz: 9b20f7bb1c651caa048207d62bbb800808a71e377a55a7b1c0283861a5b87e4dc6c6df2b2028512cd58f99c838e3ec50d0a99a88d556e1fdaa853bbf6400ff89
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metanorma (0.3.6)
4
+ metanorma (0.3.7)
5
5
  asciidoctor
6
6
 
7
7
  GEM
data/README.adoc CHANGED
@@ -1,8 +1,9 @@
1
1
  = Metanorma: the standard for standards
2
2
 
3
3
  image:https://img.shields.io/gem/v/metanorma.svg["Gem Version", link="https://rubygems.org/gems/metanorma"]
4
- image:https://img.shields.io/travis/riboseinc/metanorma/master.svg["Build Status", link="https://travis-ci.com/riboseinc/metanorma"]
4
+ image:https://img.shields.io/travis/riboseinc/metanorma/master.svg["Build Status", link="https://travis-ci.org/riboseinc/metanorma"]
5
5
  image:https://codeclimate.com/github/riboseinc/metanorma/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/riboseinc/metanorma"]
6
+ image:https://ci.appveyor.com/api/projects/status/t8irmy9iq4xf1ouy?svg=true["AppVeyor Build Status", link="https://ci.appveyor.com/project/ribose/metanorma"]
6
7
 
7
8
  Metanorma is dedicated to harmonizing standard documents
8
9
  produced by different standard-setting bodies in a manner that
@@ -141,6 +142,7 @@ Usage: metanorma [options] <file>
141
142
  -w, --wrapper Create wrapper folder for HTML output
142
143
  -d, --data-uri-image Encode HTML output images as data URIs
143
144
  -R, --relaton FILENAME Export Relaton XML (bibdata) for this document to FILENAME
145
+ (Also triggered through -x rxl)
144
146
  -h, --help Show this message
145
147
  ----
146
148
 
@@ -196,15 +198,16 @@ $ metanorma -t mpfd mpfd-bpn.adoc
196
198
  $ metanorma -t mpfd -r metanorma-mpfd mpfd-bpn.adoc
197
199
  ----
198
200
 
199
- The `type` and `extension` options can be omitted if the corresponding metanorma directives
201
+ The `type`, `extension` and `relaton` options can be omitted if the corresponding metanorma directives
200
202
  are included in the document as Metanorma directives; for Asciidoctor input, these take the form
201
- of document attributes `mn-document-class:` and `:mn-output-extensions:`, e.g.
203
+ of document attributes `mn-document-class:`, `:mn-output-extensions:` and `:mn-relaton-output-file:`, e.g.
202
204
 
203
205
  [source,asciidoctor]
204
206
  ----
205
207
  = My ISO document
206
208
  :mn-document-class: iso
207
209
  :mn-output-extensions: html,xml,pdf
210
+ :mn-relaton-output-file: test.xml
208
211
 
209
212
  .Foreword
210
213
  ----
@@ -29,6 +29,8 @@ module Metanorma
29
29
  def options_extract(filename, options)
30
30
  o = Metanorma::Input::Asciidoc.new.extract_metanorma_options(File.read(filename, encoding: "utf-8"))
31
31
  options[:type] ||= o[:type]&.to_sym
32
+ dir = filename.sub(%r(/[^/]+$), "/")
33
+ options[:relaton] ||= "#{dir}/#{o[:relaton]}" if o[:relaton]
32
34
  options[:extension_keys] ||= o[:extensions]&.split(/,[ ]*/)&.map(&:to_sym)
33
35
  options[:extension_keys] = nil if options[:extension_keys] == [:all]
34
36
  options[:format] ||= :asciidoc
@@ -103,11 +105,11 @@ module Metanorma
103
105
 
104
106
  def relaton_export(isodoc, options)
105
107
  return unless options[:relaton]
106
- xml = Nokogiri::XML(isodoc)
107
- bibdata = xml.at("//bibdata") || xml.at("//xmlns:bibdata")
108
- #docid = bibdata&.at("./xmlns:docidentifier")&.text || options[:filename]
109
- #outname = docid.sub(/^\s+/, "").sub(/\s+$/, "").gsub(/\s+/, "-") + ".xml"
110
- File.open(options[:relaton], "w:UTF-8") { |f| f.write bibdata.to_xml }
108
+ xml = Nokogiri::XML(isodoc)
109
+ bibdata = xml.at("//bibdata") || xml.at("//xmlns:bibdata")
110
+ #docid = bibdata&.at("./xmlns:docidentifier")&.text || options[:filename]
111
+ #outname = docid.sub(/^\s+/, "").sub(/\s+$/, "").gsub(/\s+/, "-") + ".xml"
112
+ File.open(options[:relaton], "w:UTF-8") { |f| f.write bibdata.to_xml }
111
113
  end
112
114
 
113
115
  def process_extensions(extensions, file, isodoc, options)
@@ -116,7 +118,12 @@ module Metanorma
116
118
  isodoc_options[:datauriimage] = true if options[:datauriimage]
117
119
  file_extension = @processor.output_formats[ext]
118
120
  outfilename = options[:filename].sub(/\.[^.]+$/, ".#{file_extension}")
119
- @processor.output(isodoc, outfilename, ext, isodoc_options)
121
+ if ext == :rxl
122
+ options[:relaton] = outfilename
123
+ relaton_export(isodoc, options)
124
+ else
125
+ @processor.output(isodoc, outfilename, ext, isodoc_options)
126
+ end
120
127
  if options[:wrapper] and /html$/.match file_extension
121
128
  outfilename = outfilename.sub(/\.html$/, "")
122
129
  FileUtils.mkdir_p outfilename
@@ -19,9 +19,11 @@ module Metanorma
19
19
  headerextract = file.sub(/\n\n.*$/m, "\n")
20
20
  /\n:mn-document-class: (?<type>[^\n]+)\n/ =~ headerextract
21
21
  /\n:mn-output-extensions: (?<extensions>[^\n]+)\n/ =~ headerextract
22
+ /\n:mn-relaton-output-file: (?<relaton>[^\n]+)\n/ =~ headerextract
22
23
  {
23
24
  type: defined?(type) ? type : nil,
24
25
  extensions: defined?(extensions) ? extensions : nil,
26
+ relaton: defined?(relaton) ? relaton : nil,
25
27
  }.reject { |_, val| val.nil? }
26
28
  end
27
29
 
@@ -3,7 +3,9 @@ module Metanorma
3
3
  class Pdf < Base
4
4
 
5
5
  def convert(url_path, output_path)
6
- file_url = "file://#{Dir.pwd}/#{url_path}"
6
+ file_url = url_path
7
+ file_url = "file://#{url_path}" if %r{^/}.match file_url
8
+ file_url = "file://#{Dir.pwd}/#{url_path}" unless %r{^file://}.match file_url
7
9
  pdfjs = File.join(File.dirname(__FILE__), '../../../bin/metanorma-pdf.js')
8
10
  ENV['NODE_PATH'] ||= `npm root --quiet -g`.strip
9
11
  system "node #{pdfjs} #{file_url} #{output_path}"
@@ -13,7 +13,8 @@ module Metanorma
13
13
 
14
14
  def output_formats
15
15
  {
16
- xml: "xml"
16
+ xml: "xml",
17
+ rxl: "rxl"
17
18
  }
18
19
  end
19
20
 
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.7"
3
3
  end
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.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-15 00:00:00.000000000 Z
11
+ date: 2019-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor