metanorma 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +12 -10
- data/README.adoc +38 -29
- data/lib/metanorma/compile.rb +46 -4
- data/lib/metanorma/version.rb +1 -1
- data/metanorma.gemspec +3 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 557db569d4700a9cf6ace8a14b05a889ce6f87cea027b778812903719dfd8e18
|
4
|
+
data.tar.gz: 0b8bd009747c7da6c111ead0ab76c77debc3262f03d97ade6564779312d90fa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c430032f283fae4569805a7a0a539eadd393d1209f7e0ab00482e9a59ca2a3a84de5958b1d4bdd7fd96a5732941172d3d114443318a18e534ba3f8712d02cc00
|
7
|
+
data.tar.gz: e08907e2d2eb37b0938debf6233ceb3ac483fd10fc44e4c01e9eea36cb4a1a4f5edc56b0beb0804719332b0e6ad5e350c22c800855039e3e7862363f429f38ff
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
metanorma (0.3.
|
4
|
+
metanorma (0.3.10)
|
5
5
|
asciidoctor
|
6
6
|
htmlentities
|
7
7
|
|
@@ -17,7 +17,7 @@ GEM
|
|
17
17
|
asciimath (1.0.8)
|
18
18
|
byebug (10.0.2)
|
19
19
|
cnccs (0.1.3)
|
20
|
-
concurrent-ruby (1.1.
|
20
|
+
concurrent-ruby (1.1.5)
|
21
21
|
diff-lcs (1.3)
|
22
22
|
equivalent-xml (0.6.0)
|
23
23
|
nokogiri (>= 1.4.3)
|
@@ -43,7 +43,7 @@ GEM
|
|
43
43
|
iso-bib-item (~> 0.4.2)
|
44
44
|
ietfbib (0.4.5)
|
45
45
|
iso-bib-item (~> 0.4.2)
|
46
|
-
iev (0.2.
|
46
|
+
iev (0.2.1)
|
47
47
|
nokogiri
|
48
48
|
image_size (2.0.0)
|
49
49
|
iso-bib-item (0.4.4)
|
@@ -69,22 +69,23 @@ GEM
|
|
69
69
|
uuidtools
|
70
70
|
isoics (0.1.7)
|
71
71
|
json (2.2.0)
|
72
|
-
liquid (4.0.
|
73
|
-
metanorma-iso (1.1.
|
72
|
+
liquid (4.0.3)
|
73
|
+
metanorma-iso (1.1.4)
|
74
74
|
asciidoctor (~> 1.5.7)
|
75
75
|
iev (~> 0.2.0)
|
76
76
|
isodoc (~> 0.9.8)
|
77
77
|
metanorma-standoc (~> 1.1.0)
|
78
78
|
ruby-jing
|
79
|
-
metanorma-standoc (1.1.
|
79
|
+
metanorma-standoc (1.1.5)
|
80
80
|
asciidoctor (~> 1.5.7)
|
81
81
|
concurrent-ruby
|
82
82
|
html2doc (~> 0.8.0)
|
83
|
-
iev (~> 0.2.
|
83
|
+
iev (~> 0.2.1)
|
84
84
|
isodoc (~> 0.9.0)
|
85
85
|
relaton (~> 0.3.1)
|
86
86
|
ruby-jing
|
87
87
|
sterile (~> 1.0.14)
|
88
|
+
unicode2latex (~> 0.0.1)
|
88
89
|
mime-types (3.2.2)
|
89
90
|
mime-types-data (~> 3.2015)
|
90
91
|
mime-types-data (3.2018.0812)
|
@@ -98,7 +99,7 @@ GEM
|
|
98
99
|
rb-fsevent (0.10.3)
|
99
100
|
rb-inotify (0.10.0)
|
100
101
|
ffi (~> 1.0)
|
101
|
-
relaton (0.3.
|
102
|
+
relaton (0.3.2)
|
102
103
|
algoliasearch
|
103
104
|
gbbib (~> 0.4.0)
|
104
105
|
iecbib (~> 0.2.0)
|
@@ -141,6 +142,7 @@ GEM
|
|
141
142
|
sterile (1.0.14)
|
142
143
|
nokogiri
|
143
144
|
thread_safe (0.3.6)
|
145
|
+
unicode2latex (0.0.2)
|
144
146
|
uuidtools (2.1.5)
|
145
147
|
|
146
148
|
PLATFORMS
|
@@ -152,8 +154,8 @@ DEPENDENCIES
|
|
152
154
|
equivalent-xml (~> 0.6)
|
153
155
|
isodoc (= 0.9.13)
|
154
156
|
metanorma!
|
155
|
-
metanorma-iso (~> 1.1.
|
156
|
-
metanorma-standoc (~> 1.1.
|
157
|
+
metanorma-iso (~> 1.1.3)
|
158
|
+
metanorma-standoc (~> 1.1.4)
|
157
159
|
rake (~> 12.0)
|
158
160
|
rspec (~> 3.0)
|
159
161
|
rspec-command (~> 1.0.3)
|
data/README.adoc
CHANGED
@@ -1,9 +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/
|
5
|
-
image:https://codeclimate.com/github/
|
6
|
-
image:https://ci.appveyor.com/api/projects/status/t8irmy9iq4xf1ouy?svg=true["AppVeyor Build Status", link="https://ci.appveyor.com/project/
|
4
|
+
image:https://img.shields.io/travis/metanorma/metanorma/master.svg["Build Status", link="https://travis-ci.org/metanorma/metanorma"]
|
5
|
+
image:https://codeclimate.com/github/metanorma/metanorma/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma"]
|
6
|
+
image:https://ci.appveyor.com/api/projects/status/t8irmy9iq4xf1ouy?svg=true["AppVeyor Build Status", link="https://ci.appveyor.com/project/metanorma/metanorma"]
|
7
7
|
|
8
8
|
Metanorma is dedicated to harmonizing standard documents
|
9
9
|
produced by different standard-setting bodies in a manner that
|
@@ -20,36 +20,36 @@ document model.
|
|
20
20
|
|
21
21
|
Metanorma includes the following sub-projects:
|
22
22
|
|
23
|
-
* The https://github.com/
|
23
|
+
* The https://github.com/metanorma/metanorma-model-standoc[Metanorma Standard Document model]
|
24
24
|
|
25
25
|
* IETF Internet-Drafts and RFCs: the https://datatracker.ietf.org/doc/draft-ribose-asciirfc/[AsciiRFC syntax],
|
26
|
-
the https://github.com/
|
26
|
+
the https://github.com/metanorma/asciidoctor-rfc/[asciidoctor-rfc RFC XML v2 and v3 implementations]
|
27
27
|
|
28
28
|
* ISO Standards: the AsciiISO syntax,
|
29
|
-
the https://github.com/
|
30
|
-
the https://github.com/
|
29
|
+
the https://github.com/metanorma/metanorma-model-iso/[Metanorma ISO model],
|
30
|
+
the https://github.com/metanorma/metanorma-iso/[metanorma-iso IsoDoc implementation]
|
31
31
|
|
32
32
|
* CalConnect Standard Documents (CSD): the AsciiCSD syntax,
|
33
|
-
https://github.com/
|
34
|
-
the https://github.com/
|
33
|
+
https://github.com/metanorma/metanorma-model-csd[Metanorma CSD model],
|
34
|
+
the https://github.com/metanorma/metanorma-csd/[metanorma-csd implementation]
|
35
35
|
|
36
36
|
* Chinese GuoBiao (GB) Standards: the AsciiGB syntax,
|
37
|
-
https://github.com/
|
38
|
-
the https://github.com/
|
37
|
+
https://github.com/metanorma/metanorma-model-gb[Metanorma GB models, for Chinese standards],
|
38
|
+
the https://github.com/metanorma/metanorma-gb/[metanorma-gb implementation]
|
39
39
|
|
40
40
|
* Cloud Security Alliance Normal Documents (CSAND): the AsciiCSAND syntax,
|
41
|
-
https://github.com/
|
42
|
-
the https://github.com/
|
41
|
+
https://github.com/metanorma/metanorma-model-csand[Metanorma CSAND model],
|
42
|
+
the https://github.com/metanorma/metanorma-csand/[metanorma-csand implementation]
|
43
43
|
|
44
44
|
* M3AAWG Documents (M3D): the AsciiM3D syntax,
|
45
|
-
https://github.com/
|
46
|
-
the https://github.com/
|
45
|
+
https://github.com/metanorma/metanorma-model-m3d[Metanorma M3D model],
|
46
|
+
the https://github.com/metanorma/metanorma-m3d/[metanorma-m3d implementation]
|
47
47
|
|
48
|
-
* Ribose Specification Documents (RSD): AsciiRSD, RSD XML schema, and the https://github.com/
|
48
|
+
* Ribose Specification Documents (RSD): AsciiRSD, RSD XML schema, and the https://github.com/metanorma/metanorma-rsd[metanorma-rsd implementation]
|
49
49
|
|
50
|
-
* Mandatory Provident Fund Schemes Authority of Hong Kong Documents (MPFD): https://github.com/
|
50
|
+
* Mandatory Provident Fund Schemes Authority of Hong Kong Documents (MPFD): https://github.com/metanorma/metanorma-mpfd[metanorma-mpfd implementation] (still at proof-of-concept stage)
|
51
51
|
|
52
|
-
* United Nations Economic Commision for Europe Documents (UNECE): https://github.com/
|
52
|
+
* United Nations Economic Commision for Europe Documents (UNECE): https://github.com/metanorma/metanorma-unece[metanorma-unece implementation]
|
53
53
|
|
54
54
|
|
55
55
|
== Installation on supported platforms
|
@@ -58,7 +58,7 @@ the https://github.com/riboseinc/metanorma-m3d/[metanorma-m3d implementation]
|
|
58
58
|
|
59
59
|
We recommend macOS users to directly run the Metanorma setup script
|
60
60
|
located here:
|
61
|
-
https://github.com/
|
61
|
+
https://github.com/metanorma/metanorma-macos-setup
|
62
62
|
|
63
63
|
This is a one-stop installation script that setups Ruby, Node
|
64
64
|
and all necessary parts for running Metanorma.
|
@@ -67,13 +67,13 @@ Alternatively, you can also use the Metanorma Docker container (see below).
|
|
67
67
|
|
68
68
|
=== Linux
|
69
69
|
|
70
|
-
Please see: https://github.com/
|
70
|
+
Please see: https://github.com/metanorma/metanorma-linux-setup
|
71
71
|
|
72
72
|
Alternatively, you can also use the Metanorma Docker container (see below).
|
73
73
|
|
74
74
|
=== Docker: Windows and other platforms
|
75
75
|
|
76
|
-
Please use the Metanorma Docker container: https://github.com/
|
76
|
+
Please use the Metanorma Docker container: https://github.com/metanorma/metanorma-docker
|
77
77
|
|
78
78
|
|
79
79
|
////
|
@@ -137,15 +137,15 @@ Usage: metanorma [options] <file>
|
|
137
137
|
}
|
138
138
|
In addition, xml (outside of rfc2, rfc3) generates IsoDoc XML. If the argument is "all" or the option is
|
139
139
|
missing, all available extensions are generated.
|
140
|
-
-f, --format FORMAT
|
141
|
-
-r, --require LIBRARY
|
142
|
-
-w, --wrapper
|
143
|
-
-d, --data-uri-image
|
144
|
-
-a, --asciimath
|
145
|
-
-R, --relaton FILENAME
|
140
|
+
-f, --format FORMAT Format of source file: asciidoc (current default, only format supported)
|
141
|
+
-r, --require LIBRARY Require LIBRARY prior to execution
|
142
|
+
-w, --wrapper Create wrapper folder for HTML output
|
143
|
+
-d, --data-uri-image Encode HTML output images as data URIs
|
144
|
+
-a, --asciimath Preserve AsciiMath in Metanorma XML, instead of transforming it into MathML
|
145
|
+
-R, --relaton FILENAME Export Relaton XML (bibdata) for this document to FILENAME
|
146
146
|
(Also triggered through -x rxl)
|
147
|
-
-
|
148
|
-
-h, --help
|
147
|
+
-e, --extract DIR(,ASSET1,ASSET2...) Extract assets from this document to directory DIR. If ASSET1,ASSET2 are named, only those types of asset are extracted.
|
148
|
+
-h, --help Show this message
|
149
149
|
----
|
150
150
|
|
151
151
|
Basically it is used like this:
|
@@ -177,6 +177,15 @@ more straightforward.
|
|
177
177
|
`relaton`:: exports the bibdata Relaton XML description of the document (which is part of its Metanorma XML)
|
178
178
|
to the nominated directory. The filename is the document identifier, if present, else the document filename.
|
179
179
|
|
180
|
+
`asciimath`:: Preserve AsciiMath in Metanorma XML, instead of transforming it into MathML (which is the default).
|
181
|
+
|
182
|
+
`extract`:: export assets found in the document to the nominated directory. If no other arguments are given,
|
183
|
+
then all asset classes are exported, each to its own subdirectory. If trailing arguments are given, they
|
184
|
+
are taken as naming which asset classes to extract from the document. Three asset classes are recognised:
|
185
|
+
`sourcecode`, `image`, and `requirement` (which includes `recommendation` and `permission` elements).
|
186
|
+
The assets are given autonumbered names, unless they were given a `filename` attribute in the source
|
187
|
+
Metanorma XML, which is used instead.
|
188
|
+
|
180
189
|
`format`:: (optional, specified via `--format` or `-f`) only accepts `asciidoc` for now,
|
181
190
|
defaults to `asciidoc`
|
182
191
|
|
data/lib/metanorma/compile.rb
CHANGED
@@ -16,7 +16,7 @@ module Metanorma
|
|
16
16
|
extensions = get_extensions(options) or return nil
|
17
17
|
(file, isodoc = process_input(filename, options)) or return nil
|
18
18
|
relaton_export(isodoc, options)
|
19
|
-
|
19
|
+
extract(isodoc, options[:extract], options[:extract_type])
|
20
20
|
process_extensions(extensions, file, isodoc, options)
|
21
21
|
end
|
22
22
|
|
@@ -126,13 +126,55 @@ module Metanorma
|
|
126
126
|
HTMLEntities.new.decode(xml.children.to_xml)
|
127
127
|
end
|
128
128
|
|
129
|
-
def
|
129
|
+
def extract(isodoc, dirname, extract_types)
|
130
130
|
return unless dirname
|
131
|
-
|
131
|
+
if extract_types.nil? || extract_types.empty?
|
132
|
+
extract_types = [:sourcecode, :image, :requirement]
|
133
|
+
end
|
132
134
|
FileUtils.rm_rf dirname
|
133
135
|
FileUtils.mkdir_p dirname
|
136
|
+
xml = Nokogiri::XML(isodoc)
|
137
|
+
sourcecode_export(xml, dirname) if extract_types.include? :sourcecode
|
138
|
+
image_export(xml, dirname) if extract_types.include? :image
|
139
|
+
requirement_export(xml, dirname) if extract_types.include? :requirement
|
140
|
+
end
|
141
|
+
|
142
|
+
def sourcecode_export(xml, dirname)
|
143
|
+
xml.at("//sourcecode | //xmlns:sourcecode") or return
|
144
|
+
FileUtils.mkdir_p "#{dirname}/sourcecode"
|
134
145
|
xml.xpath("//sourcecode | //xmlns:sourcecode").each_with_index do |s, i|
|
135
|
-
|
146
|
+
filename = s["filename"] || sprintf("sourcecode-%04d.txt", i)
|
147
|
+
File.open("#{dirname}/sourcecode/#{filename}", "w:UTF-8") do |f|
|
148
|
+
f.write clean_sourcecode(s.dup)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def image_export(xml, dirname)
|
154
|
+
xml.at("//image | //xmlns:image") or return
|
155
|
+
FileUtils.mkdir_p "#{dirname}/image"
|
156
|
+
xml.xpath("//image | //xmlns:image").each_with_index do |s, i|
|
157
|
+
next unless /^data:image/.match s["src"]
|
158
|
+
%r{^data:image/(?<imgtype>[^;]+);base64,(?<imgdata>.+)$} =~ s["src"]
|
159
|
+
filename = s["filename"] || sprintf("image-%04d.%s", i, imgtype)
|
160
|
+
File.open("#{dirname}/image/#{filename}", "wb") do |f|
|
161
|
+
f.write(Base64.strict_decode64(imgdata))
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
REQUIREMENT_XPATH = "//requirement | //xmlns:requirement | "\
|
167
|
+
"//recommendation | //xmlns:recommendation | //permission | "\
|
168
|
+
"//xmlns:permission".freeze
|
169
|
+
|
170
|
+
def requirement_export(xml, dirname)
|
171
|
+
xml.at(REQUIREMENT_XPATH) or return
|
172
|
+
FileUtils.mkdir_p "#{dirname}/requirement"
|
173
|
+
xml.xpath(REQUIREMENT_XPATH).each_with_index do |s, i|
|
174
|
+
filename = s["filename"] || sprintf("%s-%04d.xml", s.name, i)
|
175
|
+
File.open("#{dirname}/requirement/#{filename}", "w:UTF-8") do |f|
|
176
|
+
f.write s
|
177
|
+
end
|
136
178
|
end
|
137
179
|
end
|
138
180
|
|
data/lib/metanorma/version.rb
CHANGED
data/metanorma.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{Metanorma is the standard of standards; the metanorma gem allows you to create any standard document type supported by Metanorma.}
|
13
13
|
spec.description = %q{Library to process any Metanorma standard.}
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/metanorma/metanorma"
|
15
15
|
spec.license = "BSD-2-Clause"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency "byebug", "~> 10.0"
|
34
34
|
spec.add_development_dependency "rspec-command", "~> 1.0.3"
|
35
35
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
36
|
-
spec.add_development_dependency "metanorma-iso", "~> 1.1.
|
37
|
-
spec.add_development_dependency "metanorma-standoc", "~> 1.1.
|
36
|
+
spec.add_development_dependency "metanorma-iso", "~> 1.1.3"
|
37
|
+
spec.add_development_dependency "metanorma-standoc", "~> 1.1.4"
|
38
38
|
spec.add_development_dependency "isodoc", "0.9.13"
|
39
39
|
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.
|
4
|
+
version: 0.3.10
|
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-
|
11
|
+
date: 2019-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -128,28 +128,28 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.1.
|
131
|
+
version: 1.1.3
|
132
132
|
type: :development
|
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: 1.1.
|
138
|
+
version: 1.1.3
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: metanorma-standoc
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.1.
|
145
|
+
version: 1.1.4
|
146
146
|
type: :development
|
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.1.
|
152
|
+
version: 1.1.4
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: isodoc
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,7 +206,7 @@ files:
|
|
206
206
|
- lib/metanorma/registry.rb
|
207
207
|
- lib/metanorma/version.rb
|
208
208
|
- metanorma.gemspec
|
209
|
-
homepage: https://github.com/
|
209
|
+
homepage: https://github.com/metanorma/metanorma
|
210
210
|
licenses:
|
211
211
|
- BSD-2-Clause
|
212
212
|
metadata: {}
|