metanorma 1.4.4 → 1.4.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: c8457479b196c4d3db250ce33f650cd822f1ac8f1a510d1b6ac9653038446e1e
4
- data.tar.gz: f1219e134ab2113cd3e25c5bca39fe3194a3a038f9b6500f0d5e35d66f168d0d
3
+ metadata.gz: ed20add5b0be427c6da63cb6eb9725e2b8bc630248756a3f5a508546ec39d8c0
4
+ data.tar.gz: 7da47c02499a77d1284b3b5f5ea3edc90e7292d36db89181e7e3eff59eaa6346
5
5
  SHA512:
6
- metadata.gz: 8e62d329f40ca168b5f2250ae86e676b89650c754233a4d249eea45bdf7652863ce5824a128bbff0c6225435a97be4bb8b420ce9cfca44587be9d1d852c33599
7
- data.tar.gz: 1b18636330ca30bba9f2a0080e1728c6d05763349ffafebab78e1b61043f3b45c5160156dfdbf541d886fc14e195ee54808cbfbc4dd8d296e7bb56ee5edca735
6
+ metadata.gz: be96d8c7ba4bf588e5f3df380c79234dfde2efd60809d736ace1d9e4fd3f4e30a557d26a6a871c8e60d0b594efac57c1f5ee1e30539cbe74872b09c860deb648
7
+ data.tar.gz: 9b5ef259facad85743f855644b703f11cac05123eaa6a94d3a7239bc300cf915eae21971acf79f57e8dbb8ea1594a6ac3c776fd951dfb1531291f2481152e1b6
@@ -9,35 +9,7 @@ on:
9
9
  pull_request:
10
10
 
11
11
  jobs:
12
- rake:
13
- name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
- runs-on: ${{ matrix.os }}
15
- continue-on-error: ${{ matrix.experimental }}
16
- strategy:
17
- fail-fast: false
18
- matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
- os: [ ubuntu-latest, windows-latest, macos-latest ]
21
- experimental: [ false ]
22
- steps:
23
- - uses: actions/checkout@v2
24
- with:
25
- submodules: true
26
-
27
- - uses: ruby/setup-ruby@v1
28
- with:
29
- ruby-version: ${{ matrix.ruby }}
30
- bundler-cache: true
31
-
32
- - run: bundle exec rake
33
-
34
- tests-passed:
35
- needs: rake
36
- runs-on: ubuntu-latest
37
- steps:
38
- - uses: peter-evans/repository-dispatch@v1
39
- with:
40
- token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
41
- repository: ${{ github.repository }}
42
- event-type: tests-passed
43
- client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
12
+ notify:
13
+ uses: metanorma/metanorma-build-scripts/.github/workflows/inkscape-rake.yml@main
14
+ secrets:
15
+ pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -56,7 +56,7 @@ module Metanorma
56
56
  # @return [String] XML
57
57
  def to_xml
58
58
  b = Nokogiri::XML::Builder.new do |xml|
59
- xml.send("metanorma-collection",
59
+ xml.send(:"metanorma-collection",
60
60
  "xmlns" => "http://metanorma.org") do |mc|
61
61
  collection_body(mc)
62
62
  end
@@ -183,7 +183,7 @@ module Metanorma
183
183
 
184
184
  def doccontainer1(builder, doc, idx)
185
185
  id = format("doc%<index>09d", index: idx)
186
- builder.send("doc-container", id: id) do |b|
186
+ builder.send(:"doc-container", id: id) do |b|
187
187
  if doc.attachment
188
188
  doc.bibitem and b << doc.bibitem.root.to_xml
189
189
  b.attachment Metanorma::Utils::datauri(doc.file)
@@ -69,8 +69,8 @@ module Metanorma
69
69
  end
70
70
 
71
71
  def add_section_split_instance(file, manifest, key, idx, files)
72
- dir = File.dirname(files[key][:ref])
73
- presfile = File.join(dir, File.basename(file[:url]))
72
+ presfile = File.join(File.dirname(files[key][:ref]),
73
+ File.basename(file[:url]))
74
74
  manifest["#{key} #{file[:title]}"] =
75
75
  { parentid: key, presentationxml: true, type: "fileref",
76
76
  rel_path: file[:url], out_path: File.basename(file[:url]),
@@ -52,7 +52,13 @@ module Metanorma
52
52
  end
53
53
 
54
54
  def dir_name_cleanse(name)
55
- name.gsub(/[<>:"|?*]/, "_")
55
+ path = Pathname.new(name)
56
+ clean_regex = /[<>:"|?*]/
57
+ fallback_sym = "_"
58
+ return name.gsub(clean_regex, fallback_sym) unless path.absolute?
59
+
60
+ File.join(path.dirname,
61
+ path.basename.to_s.gsub(clean_regex, fallback_sym))
56
62
  end
57
63
 
58
64
  # @param col [Metanorma::Collection] XML collection
@@ -79,22 +85,25 @@ module Metanorma
79
85
  next unless %i(presentation xml).include?(e)
80
86
 
81
87
  ext = e == :presentation ? "presentation.xml" : e.to_s
82
- out = col.clone
83
- out.directives << "documents-inline"
84
- out.documents.each_key do |id|
85
- next if @files[id][:attachment] || @files[id][:outputs].nil?
86
-
87
- filename = @files[id][:outputs][e]
88
- out.documents[id] = Metanorma::Document.raw_file(filename)
89
- end
90
88
  File.open(File.join(@outdir, "collection.#{ext}"), "w:UTF-8") do |f|
91
- f.write(out.to_xml)
89
+ f.write(concatenate1(col.clone, e).to_xml)
92
90
  end
93
91
  end
94
92
  options[:format].include?(:pdf) and
95
93
  pdfconv.convert(File.join(@outdir, "collection.presentation.xml"))
96
94
  end
97
95
 
96
+ def concatenate1(out, ext)
97
+ out.directives << "documents-inline"
98
+ out.documents.each_key do |id|
99
+ next if @files[id][:attachment] || @files[id][:outputs].nil?
100
+
101
+ out.documents[id] =
102
+ Metanorma::Document.raw_file(@files[id][:outputs][ext])
103
+ end
104
+ out
105
+ end
106
+
98
107
  def pdfconv
99
108
  doctype = @doctype.to_sym
100
109
  x = Asciidoctor.load nil, backend: doctype
@@ -146,9 +155,9 @@ module Metanorma
146
155
 
147
156
  # infer the flavour from the first document identifier; relaton does that
148
157
  def doctype
149
- if (docid = @xml&.at(ns("//bibdata/docidentifier/@type"))&.text)
158
+ if (docid = @xml.at(ns("//bibdata/docidentifier/@type"))&.text)
150
159
  dt = docid.downcase
151
- elsif (docid = @xml&.at(ns("//bibdata/docidentifier"))&.text)
160
+ elsif (docid = @xml.at(ns("//bibdata/docidentifier"))&.text)
152
161
  dt = docid.sub(/\s.*$/, "").lowercase
153
162
  else return "standoc"
154
163
  end
@@ -173,8 +182,8 @@ module Metanorma
173
182
  # @param elm [Nokogiri::XML::Element]
174
183
  # @return [String]
175
184
  def indexfile_title(elm)
176
- lvl = elm&.at(ns("./level"))&.text&.capitalize
177
- lbl = elm&.at(ns("./title"))&.text
185
+ lvl = elm.at(ns("./level"))&.text&.capitalize
186
+ lbl = elm.at(ns("./title"))&.text
178
187
  "#{lvl}#{lvl && lbl ? ': ' : ''}#{lbl}"
179
188
  end
180
189
 
@@ -5,6 +5,7 @@ require "yaml"
5
5
  require "fontist"
6
6
  require "fontist/manifest/install"
7
7
  require_relative "compile_validate"
8
+ require_relative "compile_options"
8
9
  require_relative "fontist_utils"
9
10
  require_relative "util"
10
11
  require_relative "sectionsplit"
@@ -32,61 +33,10 @@ module Metanorma
32
33
  (file, isodoc = process_input(filename, options)) or return nil
33
34
  relaton_export(isodoc, options)
34
35
  extract(isodoc, options[:extract], options[:extract_type])
35
- FontistUtils.install_fonts(@processor, options) unless @fontist_installed
36
- @fontist_installed = true
36
+ font_install(options)
37
37
  process_exts(filename, extensions, file, isodoc, options)
38
38
  end
39
39
 
40
- def require_libraries(options)
41
- options&.dig(:require)&.each { |r| require r }
42
- end
43
-
44
- def xml_options_extract(file)
45
- xml = Nokogiri::XML(file) { |config| config.huge }
46
- if xml.root
47
- @registry.root_tags.each do |k, v|
48
- return { type: k } if v == xml.root.name
49
- end
50
- end
51
- {}
52
- end
53
-
54
- def options_extract(filename, options)
55
- content = read_file(filename)
56
- o = Metanorma::Input::Asciidoc.new.extract_metanorma_options(content)
57
- .merge(xml_options_extract(content))
58
- options[:type] ||= o[:type]&.to_sym
59
- t = @registry.alias(options[:type]) and options[:type] = t
60
- dir = filename.sub(%r(/[^/]+$), "/")
61
- options[:relaton] ||= "#{dir}/#{o[:relaton]}" if o[:relaton]
62
- options[:sourcecode] ||= "#{dir}/#{o[:sourcecode]}" if o[:sourcecode]
63
- options[:extension_keys] ||= o[:extensions]&.split(/, */)&.map(&:to_sym)
64
- options[:extension_keys] = nil if options[:extension_keys] == [:all]
65
- options[:format] ||= :asciidoc
66
- options[:filename] = filename
67
- options
68
- end
69
-
70
- def get_extensions(options)
71
- options[:extension_keys] ||=
72
- @processor.output_formats.reduce([]) { |memo, (k, _)| memo << k }
73
- extensions = options[:extension_keys].reduce([]) do |memo, e|
74
- if @processor.output_formats[e] then memo << e
75
- else
76
- message = "[metanorma] Error: #{e} format is not supported for this standard."
77
- @errors << message
78
- Util.log(message, :error)
79
- memo
80
- end
81
- end
82
- if !extensions.include?(:presentation) && extensions.any? do |e|
83
- @processor.use_presentation_xml(e)
84
- end
85
- extensions << :presentation
86
- end
87
- extensions
88
- end
89
-
90
40
  def process_input(filename, options)
91
41
  case extname = File.extname(filename)
92
42
  when ".adoc" then process_input_adoc(filename, options)
@@ -174,7 +124,7 @@ module Metanorma
174
124
  if ext == :rxl
175
125
  relaton_export(isodoc, options.merge(relaton: fnames[:out]))
176
126
  elsif options[:passthrough_presentation_xml] && ext == :presentation
177
- f = File.exists?(fnames[:f]) ? fnames[:f] : fnames[:orig_filename]
127
+ f = File.exist?(fnames[:f]) ? fnames[:f] : fnames[:orig_filename]
178
128
  FileUtils.cp f, fnames[:presentationxml]
179
129
  elsif ext == :html && options[:sectionsplit]
180
130
  sectionsplit_convert(fnames[:xml], isodoc, fnames[:out],
@@ -222,18 +172,6 @@ module Metanorma
222
172
  end
223
173
  end
224
174
 
225
- def get_isodoc_options(file, options, ext)
226
- ret = @processor.extract_options(file)
227
- ret[:datauriimage] = true if options[:datauriimage]
228
- ret[:sourcefilename] = options[:filename]
229
- %i(bare sectionsplit no_install_fonts baseassetpath aligncrosselements)
230
- .each { |x| ret[x] ||= options[x] }
231
- ext == :pdf && FontistUtils.has_fonts_manifest?(@processor, options) and
232
- ret[:mn2pdf] =
233
- { font_manifest: FontistUtils.location_manifest(@processor) }
234
- ret
235
- end
236
-
237
175
  # @param options [Hash]
238
176
  # @return [String]
239
177
  def change_output_dir(options)
@@ -0,0 +1,83 @@
1
+ require "csv"
2
+
3
+ module Metanorma
4
+ class Compile
5
+ def require_libraries(options)
6
+ options&.dig(:require)&.each { |r| require r }
7
+ end
8
+
9
+ def xml_options_extract(file)
10
+ xml = Nokogiri::XML(file) { |config| config.huge }
11
+ if xml.root
12
+ @registry.root_tags.each do |k, v|
13
+ return { type: k } if v == xml.root.name
14
+ end
15
+ end
16
+ {}
17
+ end
18
+
19
+ def options_extract(filename, options)
20
+ content = read_file(filename)
21
+ o = Metanorma::Input::Asciidoc.new.extract_metanorma_options(content)
22
+ .merge(xml_options_extract(content))
23
+ options[:type] ||= o[:type]&.to_sym
24
+ t = @registry.alias(options[:type]) and options[:type] = t
25
+ dir = filename.sub(%r(/[^/]+$), "/")
26
+ options[:relaton] ||= File.join(dir, o[:relaton]) if o[:relaton]
27
+ options[:sourcecode] ||= File.join(dir, o[:sourcecode]) if o[:sourcecode]
28
+ options[:extension_keys] ||= o[:extensions]&.split(/, */)&.map(&:to_sym)
29
+ options[:extension_keys] = nil if options[:extension_keys] == [:all]
30
+ options[:format] ||= :asciidoc
31
+ options[:filename] = filename
32
+ options[:fontlicenseagreement] ||= "no-install-fonts"
33
+ options
34
+ end
35
+
36
+ def get_extensions(options)
37
+ options[:extension_keys] ||=
38
+ @processor.output_formats.reduce([]) { |memo, (k, _)| memo << k }
39
+ extensions = options[:extension_keys].reduce([]) do |memo, e|
40
+ if @processor.output_formats[e] then memo << e
41
+ else
42
+ message = "[metanorma] Error: #{e} format is not supported for this standard."
43
+ @errors << message
44
+ Util.log(message, :error)
45
+ memo
46
+ end
47
+ end
48
+ if !extensions.include?(:presentation) && extensions.any? do |e|
49
+ @processor.use_presentation_xml(e)
50
+ end
51
+ extensions << :presentation
52
+ end
53
+ extensions
54
+ end
55
+
56
+ def font_install(opt)
57
+ FontistUtils.install_fonts(@processor, opt) unless @fontist_installed
58
+ @fontist_installed = true
59
+ return if !opt[:fonts] ||
60
+ opt[:fontlicenseagreement] == "continue-without-fonts"
61
+
62
+ confirm = opt[:fontlicenseagreement] == "no-install-fonts" ? "no" : "yes"
63
+ CSV.parse_line(opt[:fonts], col_sep: ";").map(&:strip).each do |f|
64
+ Fontist::Font.install(f, confirmation: confirm)
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ def get_isodoc_options(file, options, ext)
71
+ ret = @processor.extract_options(file)
72
+ ret[:datauriimage] = true if options[:datauriimage]
73
+ ret[:sourcefilename] = options[:filename]
74
+ %i(bare sectionsplit no_install_fonts baseassetpath aligncrosselements
75
+ tocfigures toctables tocrecommendations)
76
+ .each { |x| ret[x] ||= options[x] }
77
+ ext == :pdf && FontistUtils.has_fonts_manifest?(@processor, options) and
78
+ ret[:mn2pdf] =
79
+ { font_manifest: FontistUtils.location_manifest(@processor) }
80
+ ret
81
+ end
82
+ end
83
+ end
@@ -68,7 +68,9 @@ module Metanorma
68
68
  pdf-owner-password pdf-allow-copy-content pdf-allow-edit-content
69
69
  pdf-allow-assemble-document pdf-allow-edit-annotations
70
70
  pdf-allow-print pdf-allow-print-hq pdf-allow-fill-in-forms
71
- pdf-allow-access-content pdf-encrypt-metadata).freeze
71
+ toc-figures toc-tables toc-recommendations fonts
72
+ font-license-agreement pdf-allow-access-content
73
+ pdf-encrypt-metadata).freeze
72
74
 
73
75
  def extract_options(file)
74
76
  header = file.sub(/\n\n.*$/m, "\n")
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "1.4.4".freeze
2
+ VERSION = "1.4.7".freeze
3
3
  end
data/metanorma.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.required_ruby_version = ">= 2.5.0"
24
24
 
25
25
  spec.add_runtime_dependency "asciidoctor"
26
- spec.add_runtime_dependency "fontist", "~> 1.11"
26
+ spec.add_runtime_dependency "fontist"
27
27
  spec.add_runtime_dependency "htmlentities"
28
28
  spec.add_runtime_dependency "metanorma-utils", "~> 1.2.0"
29
29
  spec.add_runtime_dependency "mn2pdf", "~> 1"
@@ -36,12 +36,11 @@ Gem::Specification.new do |spec|
36
36
 
37
37
  spec.add_development_dependency "debug"
38
38
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
39
- spec.add_development_dependency "metanorma-iso", "~> 1.10"
39
+ spec.add_development_dependency "metanorma-iso", "~> 2.0"
40
40
  spec.add_development_dependency "mnconvert"
41
41
  spec.add_development_dependency "rake", "~> 13.0"
42
42
  spec.add_development_dependency "rspec", "~> 3.0"
43
43
  spec.add_development_dependency "rspec-command", "~> 1.0"
44
44
  spec.add_development_dependency "rubocop", "~> 1.5.2"
45
45
  spec.add_development_dependency "sassc", "~> 2.4.0"
46
- spec.add_development_dependency "reline", "~> 0.2.8.pre.11"
47
46
  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: 1.4.4
4
+ version: 1.4.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: 2021-12-27 00:00:00.000000000 Z
11
+ date: 2022-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: fontist
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.11'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.11'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: htmlentities
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '1.10'
145
+ version: '2.0'
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.10'
152
+ version: '2.0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: mnconvert
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -234,20 +234,6 @@ dependencies:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
236
  version: 2.4.0
237
- - !ruby/object:Gem::Dependency
238
- name: reline
239
- requirement: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - "~>"
242
- - !ruby/object:Gem::Version
243
- version: 0.2.8.pre.11
244
- type: :development
245
- prerelease: false
246
- version_requirements: !ruby/object:Gem::Requirement
247
- requirements:
248
- - - "~>"
249
- - !ruby/object:Gem::Version
250
- version: 0.2.8.pre.11
251
237
  description: Library to process any Metanorma standard.
252
238
  email:
253
239
  - open.source@ribose.com
@@ -285,6 +271,7 @@ files:
285
271
  - lib/metanorma/collection_manifest.rb
286
272
  - lib/metanorma/collection_renderer.rb
287
273
  - lib/metanorma/compile.rb
274
+ - lib/metanorma/compile_options.rb
288
275
  - lib/metanorma/compile_validate.rb
289
276
  - lib/metanorma/config.rb
290
277
  - lib/metanorma/document.rb
@@ -319,7 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
306
  - !ruby/object:Gem::Version
320
307
  version: '0'
321
308
  requirements: []
322
- rubygems_version: 3.2.32
309
+ rubygems_version: 3.3.9
323
310
  signing_key:
324
311
  specification_version: 4
325
312
  summary: Metanorma is the standard of standards; the metanorma gem allows you to create