metanorma 1.4.14 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +3 -0
- data/lib/metanorma/collection_fileparse.rb +24 -10
- data/lib/metanorma/collection_renderer.rb +14 -8
- data/lib/metanorma/compile_validate.rb +17 -16
- data/lib/metanorma/document.rb +7 -6
- data/lib/metanorma/input/asciidoc.rb +2 -1
- data/lib/metanorma/version.rb +1 -1
- data/metanorma.gemspec +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c62d15c313b6595ca184016faa8f0996de7d1d8f1321e932e6adc89d230682d
|
4
|
+
data.tar.gz: f13f182618c3fec66f42e412bfe3d4baa142b877421458fb2555912ce077f8e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d7e934fa1d1f0348a9877f25e037294e09513a3df04873ec6394b908d443cb2152480bd14c3e5948071657a6c4bcee2907964b8a2b408c7bb0d67a3f99e37c5
|
7
|
+
data.tar.gz: e1e626b4795c18b5a934262bc37faf0c4fe997832661f73e27e852f6bf66f67bde8c2b2edc86343463e3fde70eefd722e9af19fca186957761048193c70fc29b
|
@@ -18,6 +18,9 @@ jobs:
|
|
18
18
|
uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
|
19
19
|
with:
|
20
20
|
next_version: ${{ github.event.inputs.next_version }}
|
21
|
+
release_command: rake release
|
22
|
+
bundler_cache: false
|
23
|
+
post_install: gem install bundler rake rspec
|
21
24
|
secrets:
|
22
25
|
rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
|
23
26
|
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
@@ -8,7 +8,8 @@ module Metanorma
|
|
8
8
|
# UUIDs, so that their IDs can at least be registered to be tracked
|
9
9
|
# as existing.
|
10
10
|
def read_anchors(xml)
|
11
|
-
xrefs = @isodoc.xref_init(@lang, @script, @isodoc, @isodoc.i18n,
|
11
|
+
xrefs = @isodoc.xref_init(@lang, @script, @isodoc, @isodoc.i18n,
|
12
|
+
{ locale: @locale })
|
12
13
|
xrefs.parse xml
|
13
14
|
xrefs.get.each_with_object({}) do |(k, v), ret|
|
14
15
|
read_anchors1(k, v, ret)
|
@@ -37,10 +38,8 @@ module Metanorma
|
|
37
38
|
|
38
39
|
# @param bib [Nokogiri::XML::Element]
|
39
40
|
# @param identifier [String]
|
40
|
-
def update_bibitem(bib, identifier)
|
41
|
-
docid = bib
|
42
|
-
return fail_update_bibitem(docid, identifier) unless @files[docid]
|
43
|
-
|
41
|
+
def update_bibitem(bib, identifier)
|
42
|
+
docid = get_bibitem_docid(bib, identifier) or return
|
44
43
|
newbib = dup_bibitem(docid, bib)
|
45
44
|
bib.replace(newbib)
|
46
45
|
_file, url = targetfile(@files[docid], relative: true, read: false,
|
@@ -51,6 +50,19 @@ module Metanorma
|
|
51
50
|
newbib.at(ns("./docidentifier")).previous = uri_node
|
52
51
|
end
|
53
52
|
|
53
|
+
def get_bibitem_docid(bib, identifier)
|
54
|
+
# IDs for repo references are untyped by default
|
55
|
+
docid = bib.at(ns("./docidentifier[not(@type)]")) ||
|
56
|
+
bib.at(ns("./docidentifier"))
|
57
|
+
docid &&= docid.children.to_xml
|
58
|
+
if @files[docid]
|
59
|
+
docid
|
60
|
+
else
|
61
|
+
fail_update_bibitem(docid, identifier)
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
54
66
|
def fail_update_bibitem(docid, identifier)
|
55
67
|
error = "[metanorma] Cannot find crossreference to document #{docid} "\
|
56
68
|
"in document #{identifier}."
|
@@ -74,7 +86,8 @@ module Metanorma
|
|
74
86
|
# in another file in the collection)
|
75
87
|
# @param file [String] XML content
|
76
88
|
# @param identifier [String] docid
|
77
|
-
# @param internal_refs [Hash{String=>Hash{String=>String}] schema name to
|
89
|
+
# @param internal_refs [Hash{String=>Hash{String=>String}] schema name to
|
90
|
+
# anchor to filename
|
78
91
|
# @return [String] XML content
|
79
92
|
def update_xrefs(file, identifier, internal_refs)
|
80
93
|
docxml = Nokogiri::XML(file) { |config| config.huge }
|
@@ -141,11 +154,12 @@ module Metanorma
|
|
141
154
|
def update_direct_refs_to_docs(docxml, identifier)
|
142
155
|
erefs = collect_erefs(docxml)
|
143
156
|
docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |b|
|
144
|
-
docid = b
|
157
|
+
docid = b.at(ns("./docidentifier[@type = 'repository']"))&.text
|
145
158
|
next unless docid && %r{^current-metanorma-collection/}.match(docid)
|
146
159
|
|
147
160
|
update_bibitem(b, identifier)
|
148
|
-
docid = b
|
161
|
+
docid = b.at(ns("./docidentifier")) or next
|
162
|
+
docid = docid.children.to_xml
|
149
163
|
erefs[:citeas][docid] and update_anchors(b, docxml, docid)
|
150
164
|
end
|
151
165
|
end
|
@@ -210,9 +224,9 @@ module Metanorma
|
|
210
224
|
# anchor given the locality, and insert it into the crossref
|
211
225
|
def update_anchor_create_loc(_bib, eref, docid)
|
212
226
|
ins = eref.at(ns("./localityStack")) or return
|
213
|
-
type = ins
|
227
|
+
type = ins.at(ns("./locality/@type"))&.text
|
214
228
|
type = "clause" if type == "annex"
|
215
|
-
ref = ins
|
229
|
+
ref = ins.at(ns("./locality/referenceFrom"))&.text
|
216
230
|
anchor = @files[docid][:anchors].dig(type, ref) or return
|
217
231
|
ins << "<locality type='anchor'><referenceFrom>#{anchor.sub(/^_/, '')}"\
|
218
232
|
"</referenceFrom></locality>"
|
@@ -25,8 +25,9 @@ module Metanorma
|
|
25
25
|
def initialize(collection, folder, options = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
26
26
|
check_options options
|
27
27
|
@xml = Nokogiri::XML collection.to_xml # @xml is the collection manifest
|
28
|
-
@lang = @xml
|
29
|
-
@script = @xml
|
28
|
+
@lang = @xml.at(ns("//bibdata/language"))&.text || "en"
|
29
|
+
@script = @xml.at(ns("//bibdata/script"))&.text || "Latn"
|
30
|
+
@locale = @xml.at(ns("//bibdata/locale"))&.text
|
30
31
|
@doctype = doctype
|
31
32
|
require "metanorma-#{@doctype}"
|
32
33
|
|
@@ -47,8 +48,7 @@ module Metanorma
|
|
47
48
|
# list of files in the collection
|
48
49
|
@files = read_files folder
|
49
50
|
isodoc_populate(@isodoc)
|
50
|
-
|
51
|
-
FileUtils.mkdir_p @outdir
|
51
|
+
create_non_existing_directory(@outdir)
|
52
52
|
end
|
53
53
|
|
54
54
|
def dir_name_cleanse(name)
|
@@ -96,7 +96,7 @@ module Metanorma
|
|
96
96
|
def concatenate1(out, ext)
|
97
97
|
out.directives << "documents-inline"
|
98
98
|
out.documents.each_key do |id|
|
99
|
-
|
99
|
+
@files[id][:attachment] || @files[id][:outputs].nil? and next
|
100
100
|
|
101
101
|
out.documents[id] =
|
102
102
|
Metanorma::Document.raw_file(@files[id][:outputs][ext])
|
@@ -134,8 +134,8 @@ module Metanorma
|
|
134
134
|
def isodoc
|
135
135
|
x = Asciidoctor.load nil, backend: @doctype.to_sym
|
136
136
|
isodoc = x.converter.html_converter(Dummy.new)
|
137
|
-
isodoc.i18n_init(@lang, @script) # read in internationalisation
|
138
|
-
isodoc.metadata_init(@lang, @script, isodoc.i18n)
|
137
|
+
isodoc.i18n_init(@lang, @script, @locale) # read in internationalisation
|
138
|
+
isodoc.metadata_init(@lang, @script, @locale, isodoc.i18n)
|
139
139
|
isodoc.info(@xml, nil)
|
140
140
|
isodoc
|
141
141
|
end
|
@@ -146,7 +146,7 @@ module Metanorma
|
|
146
146
|
nav = indexfile(@xml.at(ns("//manifest")))
|
147
147
|
i18n = isodoc.i18n
|
148
148
|
i18n.set("navigation", nav)
|
149
|
-
isodoc.metadata_init(@lang, @script, i18n)
|
149
|
+
isodoc.metadata_init(@lang, @script, @locale, i18n)
|
150
150
|
# populate the @meta class of isodoc with the various metadata fields
|
151
151
|
# native to the flavour; used to populate Liquid
|
152
152
|
isodoc.info(@xml, nil)
|
@@ -240,6 +240,12 @@ module Metanorma
|
|
240
240
|
|
241
241
|
private
|
242
242
|
|
243
|
+
def create_non_existing_directory(output_directory)
|
244
|
+
if !File.exist?(output_directory)
|
245
|
+
FileUtils.mkdir_p(output_directory)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
243
249
|
def format_sort(formats)
|
244
250
|
ret = []
|
245
251
|
formats.include?(:xml) and ret << :xml
|
@@ -29,31 +29,32 @@ module Metanorma
|
|
29
29
|
Util.log("[metanorma] Info: Loading `#{flavor}` gem "\
|
30
30
|
"for standard type `#{stdtype}`.", :info)
|
31
31
|
end
|
32
|
-
require_flavor(flavor
|
32
|
+
require_flavor(flavor)
|
33
33
|
unless @registry.supported_backends.include? stdtype
|
34
|
-
Util.log("[metanorma] Error: The `#{flavor}` gem "\
|
35
|
-
"
|
34
|
+
Util.log("[metanorma] Error: The `#{flavor}` gem does not "\
|
35
|
+
"support the standard type #{stdtype}. Exiting.", :fatal)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def require_flavor(flavor
|
39
|
+
def require_flavor(flavor)
|
40
40
|
require flavor
|
41
41
|
Util.log("[metanorma] Info: gem `#{flavor}` loaded.", :info)
|
42
|
-
rescue
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
rescue LoadError
|
42
|
+
rescue LoadError => e
|
43
|
+
error_log = "#{Date.today}-error.log"
|
44
|
+
File.write(error_log, e)
|
45
|
+
|
47
46
|
msg = <<~MSG
|
48
|
-
|
47
|
+
Error: #{e.message}
|
48
|
+
Metanorma has encountered an exception.
|
49
|
+
|
50
|
+
If this problem persists, please report this issue at the following link:
|
51
|
+
|
52
|
+
* https://github.com/metanorma/metanorma/issues/new
|
49
53
|
|
50
|
-
|
51
|
-
|
52
|
-
Gemfile contains a line:
|
53
|
-
gem "metanorma-#{stdtype}"
|
54
|
+
Please attach the #{error_log} file.
|
55
|
+
Your valuable feedback is very much appreciated!
|
54
56
|
|
55
|
-
|
56
|
-
to https://github.com/metanorma/packed-mn/issues/new"
|
57
|
+
- The Metanorma team
|
57
58
|
MSG
|
58
59
|
Util.log(msg, :fatal)
|
59
60
|
end
|
data/lib/metanorma/document.rb
CHANGED
@@ -40,9 +40,9 @@ module Metanorma
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def attachment_bibitem(identifier)
|
43
|
-
Nokogiri::XML
|
44
|
-
|
45
|
-
|
43
|
+
Nokogiri::XML <<~DOCUMENT
|
44
|
+
<bibdata><docidentifier>#{identifier}</docidentifier></bibdata>
|
45
|
+
DOCUMENT
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
@@ -94,9 +94,10 @@ module Metanorma
|
|
94
94
|
|
95
95
|
# @return [String]
|
96
96
|
def type
|
97
|
-
|
98
|
-
|
99
|
-
|
97
|
+
first = @bibitem.docidentifier.first
|
98
|
+
@type ||= (first&.type&.downcase ||
|
99
|
+
first&.id&.match(/^[^\s]+/)&.to_s)&.downcase ||
|
100
|
+
"standoc"
|
100
101
|
end
|
101
102
|
|
102
103
|
private
|
@@ -70,7 +70,8 @@ module Metanorma
|
|
70
70
|
pdf-allow-print pdf-allow-print-hq pdf-allow-fill-in-forms
|
71
71
|
toc-figures toc-tables toc-recommendations fonts
|
72
72
|
font-license-agreement pdf-allow-access-content
|
73
|
-
pdf-encrypt-metadata iso-word-template document-scheme
|
73
|
+
pdf-encrypt-metadata iso-word-template document-scheme
|
74
|
+
localize-number).freeze
|
74
75
|
|
75
76
|
def extract_options(file)
|
76
77
|
header = file.sub(/\n\n.*$/m, "\n")
|
data/lib/metanorma/version.rb
CHANGED
data/metanorma.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_runtime_dependency "asciidoctor"
|
26
26
|
spec.add_runtime_dependency "fontist", ">= 1.14.3"
|
27
27
|
spec.add_runtime_dependency "htmlentities"
|
28
|
-
spec.add_runtime_dependency "isodoc", ">= 2.
|
28
|
+
spec.add_runtime_dependency "isodoc", ">= 2.3.1"
|
29
29
|
spec.add_runtime_dependency "metanorma-utils", "~> 1.4.0"
|
30
30
|
spec.add_runtime_dependency "mn2pdf", "~> 1"
|
31
31
|
spec.add_runtime_dependency "nokogiri"
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
|
38
38
|
spec.add_development_dependency "debug"
|
39
39
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
40
|
-
spec.add_development_dependency "metanorma-iso"
|
40
|
+
spec.add_development_dependency "metanorma-iso"
|
41
41
|
spec.add_development_dependency "mnconvert"
|
42
42
|
spec.add_development_dependency "rake", "~> 13.0"
|
43
43
|
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.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: 2.3.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
68
|
+
version: 2.3.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: metanorma-utils
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,16 +154,16 @@ dependencies:
|
|
154
154
|
name: metanorma-iso
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
159
|
+
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
166
|
+
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: mnconvert
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|