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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.adoc +6 -3
- data/lib/metanorma/compile.rb +13 -6
- data/lib/metanorma/input/asciidoc.rb +2 -0
- data/lib/metanorma/output/pdf.rb +3 -1
- data/lib/metanorma/processor.rb +2 -1
- data/lib/metanorma/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbe49b657d41e2d71ea35393334a71bf9ae2392b9de90d696cb54783f3fe520e
|
4
|
+
data.tar.gz: 4fd60291f8196e53db4e55c3f33d6fb4705a3984f7c110ad7643997f26a2b8d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d74a51133af96c89f4c0afd0d4c0c2438865f3d8a93dd4830908fdb462df5ae40edc9c6b1a1e65b94fdb9c7923ec5bea6a9feb5e65f4637a53aba2ef499d510e
|
7
|
+
data.tar.gz: 9b20f7bb1c651caa048207d62bbb800808a71e377a55a7b1c0283861a5b87e4dc6c6df2b2028512cd58f99c838e3ec50d0a99a88d556e1fdaa853bbf6400ff89
|
data/Gemfile.lock
CHANGED
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.
|
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 `
|
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-
|
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
|
----
|
data/lib/metanorma/compile.rb
CHANGED
@@ -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
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
-
|
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
|
|
data/lib/metanorma/output/pdf.rb
CHANGED
@@ -3,7 +3,9 @@ module Metanorma
|
|
3
3
|
class Pdf < Base
|
4
4
|
|
5
5
|
def convert(url_path, output_path)
|
6
|
-
file_url =
|
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}"
|
data/lib/metanorma/processor.rb
CHANGED
data/lib/metanorma/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|