metanorma 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +17 -11
- data/lib/metanorma/collection_renderer.rb +27 -15
- data/lib/metanorma/compile.rb +65 -4
- data/lib/metanorma/version.rb +1 -1
- data/metanorma.gemspec +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd65d9c42b99b4d3fb54c89a6189e736fc3927c48cd28da8b96e14ece003c194
|
4
|
+
data.tar.gz: 71d55f8449c7495a348c3acca4f2840562179cfebd96fdeaaf82b59965a4bf98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44b4797c97b3e306c9655c5073ec302563517d49982eba22a99fef10002c48763724309946c89edfd8617d954885b6a72bd7b4463e2a39148e174408f0428909
|
7
|
+
data.tar.gz: 4e77d61c5bb7078f05ce2eabe7a58ba2b451d0d6f257fb6c79855366ad7f4e63fe79bf7851646a5313ff044a5715e21c173d5302e42de6784cc73b4e5bf67f91
|
data/.github/workflows/rake.yml
CHANGED
@@ -4,7 +4,7 @@ name: rake
|
|
4
4
|
|
5
5
|
on:
|
6
6
|
push:
|
7
|
-
branches: [ master ]
|
7
|
+
branches: [ master, main ]
|
8
8
|
tags: [ v* ]
|
9
9
|
pull_request:
|
10
10
|
|
@@ -32,24 +32,30 @@ jobs:
|
|
32
32
|
steps:
|
33
33
|
- uses: actions/checkout@master
|
34
34
|
|
35
|
-
-
|
36
|
-
uses: ruby/setup-ruby@v1
|
35
|
+
- uses: ruby/setup-ruby@v1
|
37
36
|
with:
|
38
37
|
ruby-version: ${{ matrix.ruby }}
|
39
|
-
bundler-cache: true
|
40
38
|
|
41
|
-
-
|
42
|
-
run:
|
39
|
+
- if: matrix.os == 'macos-latest'
|
40
|
+
run: brew install autoconf automake libtool
|
43
41
|
|
44
|
-
-
|
45
|
-
|
42
|
+
- uses: actions/cache@v2
|
43
|
+
with:
|
44
|
+
path: vendor/bundle
|
45
|
+
key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
|
46
|
+
restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
|
47
|
+
|
48
|
+
- run: bundle config set path 'vendor/bundle'
|
49
|
+
|
50
|
+
- run: bundle install --jobs 4 --retry 3
|
51
|
+
|
52
|
+
- run: bundle exec rake
|
46
53
|
|
47
|
-
|
48
|
-
name: Trigger notify workflow
|
54
|
+
tests-passed:
|
49
55
|
needs: rake
|
50
56
|
runs-on: ubuntu-latest
|
51
57
|
steps:
|
52
|
-
- name: Trigger
|
58
|
+
- name: Trigger tests passed event
|
53
59
|
uses: Sibz/github-status-action@v1
|
54
60
|
with:
|
55
61
|
authToken: ${{ secrets.GITHUB_TOKEN }}
|
@@ -33,6 +33,7 @@ module Metanorma
|
|
33
33
|
@outdir = options[:output_folder]
|
34
34
|
@coverpage = options[:coverpage]
|
35
35
|
@format = options[:format]
|
36
|
+
@compile_options = options[:compile] || {}
|
36
37
|
|
37
38
|
# list of files in the collection
|
38
39
|
@files = read_files folder
|
@@ -164,9 +165,13 @@ module Metanorma
|
|
164
165
|
xrefs = @isodoc.xref_init(@lang, @script, @isodoc, @isodoc.i18n, {})
|
165
166
|
xrefs.parse xml
|
166
167
|
xrefs.get.each do |k, v|
|
167
|
-
v[:label] && v[:type] || next
|
168
168
|
ret[v[:type]] ||= {}
|
169
|
-
|
169
|
+
index = v[:container] || v[:label].nil? || v[:label].empty? ?
|
170
|
+
UUIDTools::UUID.random_create.to_s : v[:label]
|
171
|
+
# Note: will only key clauses, which have unambiguous reference label in locality.
|
172
|
+
# Notes, examples etc with containers are just plunked agaisnt UUIDs, so that their
|
173
|
+
# IDs can at least be registered to be tracked as existing.
|
174
|
+
ret[v[:type]][index] = k
|
170
175
|
end
|
171
176
|
ret
|
172
177
|
end
|
@@ -297,7 +302,6 @@ module Metanorma
|
|
297
302
|
docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |b|
|
298
303
|
docid = b&.at(ns("./docidentifier[@type = 'repository']"))&.text
|
299
304
|
next unless docid && %r{^current-metanorma-collection/}.match(docid)
|
300
|
-
|
301
305
|
update_bibitem(b, identifier)
|
302
306
|
update_anchors(b, docxml, docid)
|
303
307
|
end
|
@@ -311,18 +315,25 @@ module Metanorma
|
|
311
315
|
# anchor given the locality, and insert it into the crossref
|
312
316
|
def update_anchors(bib, docxml, _id) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
313
317
|
docid = bib&.at(ns("./docidentifier"))&.text
|
318
|
+
document_suffix = Asciidoctor::Standoc::Cleanup.to_ncname(docid)
|
314
319
|
docxml.xpath("//xmlns:eref[@citeas = '#{docid}']").each do |e|
|
315
|
-
e.at(ns(".//locality[@type = 'anchor']"))
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
320
|
+
if loc = e.at(ns(".//locality[@type = 'anchor']"))
|
321
|
+
ref = loc.at(ns("./referenceFrom")) || next
|
322
|
+
anchor = "#{ref.text}_#{document_suffix}"
|
323
|
+
next unless @files[docid][:anchors].inject([]) { |m, (_, x)| m+= x.values }.include?(anchor)
|
324
|
+
ref.content = anchor
|
325
|
+
else
|
326
|
+
ins = e.at(ns("./localityStack")) || next
|
327
|
+
type = ins&.at(ns("./locality/@type"))&.text
|
328
|
+
ref = ins&.at(ns("./locality/referenceFrom"))&.text
|
329
|
+
(anchor = @files[docid][:anchors][type][ref]) || next
|
330
|
+
ref_from = Nokogiri::XML::Node.new "referenceFrom", bib
|
331
|
+
ref_from.content = anchor.sub(/^_/, "")
|
332
|
+
locality = Nokogiri::XML::Node.new "locality", bib
|
333
|
+
locality[:type] = "anchor"
|
334
|
+
locality.add_child ref_from
|
335
|
+
ins << locality
|
336
|
+
end
|
326
337
|
end
|
327
338
|
end
|
328
339
|
|
@@ -337,7 +348,8 @@ module Metanorma
|
|
337
348
|
f.close
|
338
349
|
# warn "metanorma compile -x html #{f.path}"
|
339
350
|
c = Compile.new
|
340
|
-
|
351
|
+
options = { format: :asciidoc, extension_keys: @format }.merge @compile_options
|
352
|
+
c.compile f.path, options
|
341
353
|
@files[identifier][:outputs] = {}
|
342
354
|
@format.each do |e|
|
343
355
|
ext = c.processor.output_formats[e]
|
data/lib/metanorma/compile.rb
CHANGED
@@ -2,6 +2,9 @@ require "fileutils"
|
|
2
2
|
require "nokogiri"
|
3
3
|
require "htmlentities"
|
4
4
|
|
5
|
+
require "fontist"
|
6
|
+
require "fontist/manifest/install"
|
7
|
+
|
5
8
|
module Metanorma
|
6
9
|
class Compile
|
7
10
|
# @return [Array<String>]
|
@@ -21,6 +24,7 @@ module Metanorma
|
|
21
24
|
(file, isodoc = process_input(filename, options)) or return nil
|
22
25
|
relaton_export(isodoc, options)
|
23
26
|
extract(isodoc, options[:extract], options[:extract_type])
|
27
|
+
install_fonts(options)
|
24
28
|
process_extensions(extensions, file, isodoc, options)
|
25
29
|
end
|
26
30
|
|
@@ -63,21 +67,32 @@ module Metanorma
|
|
63
67
|
Util.log("[metanorma] Error: Please specify a standard type: #{@registry.supported_backends}.", :error)
|
64
68
|
return nil
|
65
69
|
end
|
70
|
+
|
66
71
|
stdtype = options[:type].to_sym
|
72
|
+
metanorma_flavor = "metanorma-#{stdtype}"
|
73
|
+
|
67
74
|
unless @registry.supported_backends.include? stdtype
|
68
|
-
Util.log("[metanorma] Info: Loading
|
75
|
+
Util.log("[metanorma] Info: Loading `#{metanorma_flavor}` gem for standard type `#{stdtype}`.", :info)
|
69
76
|
end
|
77
|
+
|
70
78
|
begin
|
71
79
|
require "metanorma-#{stdtype}"
|
72
|
-
Util.log("[metanorma] Info: gem
|
80
|
+
Util.log("[metanorma] Info: gem `#{metanorma_flavor}` loaded.", :info)
|
81
|
+
|
82
|
+
rescue Gem::ConflictError
|
83
|
+
Util.log("[metanorma] Error: Couldn't resolve dependencies for `metanorma-#{stdtype}`, Please add it to your Gemfile and run bundle install first", :error)
|
84
|
+
return false
|
85
|
+
|
73
86
|
rescue LoadError
|
74
|
-
Util.log("[metanorma] Error: loading gem
|
87
|
+
Util.log("[metanorma] Error: loading gem `#{metanorma_flavor}` failed. Exiting.", :error)
|
75
88
|
return false
|
76
89
|
end
|
90
|
+
|
77
91
|
unless @registry.supported_backends.include? stdtype
|
78
|
-
Util.log("[metanorma] Error: The
|
92
|
+
Util.log("[metanorma] Error: The `#{metanorma_flavor}` gem still doesn't support `#{stdtype}`. Exiting.", :error)
|
79
93
|
return false
|
80
94
|
end
|
95
|
+
|
81
96
|
true
|
82
97
|
end
|
83
98
|
|
@@ -252,8 +267,54 @@ module Metanorma
|
|
252
267
|
end
|
253
268
|
end
|
254
269
|
|
270
|
+
def install_fonts(options)
|
271
|
+
if options[:"no-install-fonts"]
|
272
|
+
Util.log("[fontist] Skip font installation because" \
|
273
|
+
" --no-install-fonts argument passed", :debug)
|
274
|
+
return
|
275
|
+
end
|
276
|
+
|
277
|
+
if !@processor.respond_to?(:fonts_manifest) || @processor.fonts_manifest.nil?
|
278
|
+
Util.log("[fontist] Skip font installation because font_manifest is missing", :debug)
|
279
|
+
return
|
280
|
+
end
|
281
|
+
|
282
|
+
manifest = @processor.fonts_manifest
|
283
|
+
agree_to_terms = options[:"agree-to-terms"] || false
|
284
|
+
continue_without_fonts = options[:"continue-without-fonts"] || false
|
285
|
+
|
286
|
+
install_fonts_safe(manifest, agree_to_terms, continue_without_fonts)
|
287
|
+
end
|
288
|
+
|
255
289
|
private
|
256
290
|
|
291
|
+
def install_fonts_safe(manifest, agree, continue)
|
292
|
+
fontist_install(manifest, agree)
|
293
|
+
rescue Fontist::Errors::LicensingError
|
294
|
+
if continue
|
295
|
+
Util.log("[fontist] Processing will continue without fonts installed", :debug)
|
296
|
+
else
|
297
|
+
Util.log("[fontist] Aborting without proper fonts installed," \
|
298
|
+
" make sure that you have set option --agree-to-terms", :fatal)
|
299
|
+
end
|
300
|
+
rescue Fontist::Errors::MissingFontError => e
|
301
|
+
font = /Font '([^']+)'/.match(e.to_s)[1]
|
302
|
+
Util.log("[fontist] '#{font}' font is not supported. " \
|
303
|
+
"Please report this issue at github.com/metanorma/metanorma-#{@processor.short}/issues" \
|
304
|
+
" to report this issue.", :info)
|
305
|
+
rescue Fontist::Errors::FormulaIndexNotFoundError
|
306
|
+
Util.log("[fontist] Missing formula index. Fetching it...", :debug)
|
307
|
+
Fontist::Formula.update_formulas_repo
|
308
|
+
fontist_install(manifest, agree)
|
309
|
+
end
|
310
|
+
|
311
|
+
def fontist_install(manifest, agree)
|
312
|
+
Fontist::Manifest::Install.from_hash(
|
313
|
+
manifest,
|
314
|
+
confirmation: agree ? "yes" : "no"
|
315
|
+
)
|
316
|
+
end
|
317
|
+
|
257
318
|
# @param options [Hash]
|
258
319
|
# @return [String]
|
259
320
|
def change_output_dir(options)
|
data/lib/metanorma/version.rb
CHANGED
data/metanorma.gemspec
CHANGED
@@ -28,6 +28,8 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_runtime_dependency 'nokogiri'
|
29
29
|
spec.add_runtime_dependency 'mn2pdf', "~> 1"
|
30
30
|
spec.add_runtime_dependency 'pry'
|
31
|
+
spec.add_runtime_dependency 'fontist', '~> 1.8'
|
32
|
+
|
31
33
|
# get relaton-cli to avoic circular reference with metanorma-standoc
|
32
34
|
#spec.add_dependency "relaton-cli"
|
33
35
|
#spec.add_dependency "metanorma-standoc", "~> 1.5.3"
|
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.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fontist
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.8'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.8'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|