metanorma 1.3.9 → 1.3.12

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: 46ea9a7ce8316d94001c40043488f3472bcf639264e446bfb5bfaad88b6bed70
4
- data.tar.gz: 7e4bfc4c4346c518d845052fd2dbb0b1f51f63e2951a317c18d938f9663cdea3
3
+ metadata.gz: 6e0318ba6a8281b9d412916b46fa57cc2de00a2738dd7703425c3f3736d92ae8
4
+ data.tar.gz: 03d43c3e079517e202ba7e6d48f67ba792741db08ad026392169d19ffdc5a5d5
5
5
  SHA512:
6
- metadata.gz: fdb777c1e35bbeeac65f3e5b0654ead9633a196340017da8cd4bd84342a9500a891a14ac19d83cc0cda0e5301728afdddf367fa3871eece62b389d93d0144238
7
- data.tar.gz: c264222db4c7e2cbd7342aac8da9c5480a1d48f277ce2c5ef23000443d618379abb0769d111a8846733d60a53364706a65edd1a14de7ada03b94d16182c479bb
6
+ metadata.gz: 3cc705935cee37831ad02b8ca85f556f9d2ec8cec8c341a045f34d96621b20e79455533a22262004b363d6f10a1523505cea14bc489fa1d47d9406870e1acc7f
7
+ data.tar.gz: a9d55375a16afb0ed0ee9e392dc2cc134f9a0e424fbadbb8f7b9f5fe940d944867c9d5e32e39f79fcf6d594381a7f2c90a9d70502b5108668c181e628e32f83e
@@ -44,7 +44,7 @@ module Metanorma
44
44
  newbib = dup_bibitem(docid, bib)
45
45
  bib.replace(newbib)
46
46
  _file, url = targetfile(@files[docid], relative: true, read: false,
47
- doc: !@files[docid][:attachment])
47
+ doc: !@files[docid][:attachment])
48
48
  uri_node = Nokogiri::XML::Node.new "uri", newbib
49
49
  uri_node[:type] = "citation"
50
50
  uri_node.content = url
@@ -53,7 +53,7 @@ module Metanorma
53
53
 
54
54
  def fail_update_bibitem(docid, identifier)
55
55
  error = "[metanorma] Cannot find crossreference to document #{docid} "\
56
- "in document #{identifier}."
56
+ "in document #{identifier}."
57
57
  @log.add("Cross-References", nil, error)
58
58
  Util.log(error, :warning)
59
59
  end
@@ -78,6 +78,7 @@ module Metanorma
78
78
  # @return [String] XML content
79
79
  def update_xrefs(file, identifier, internal_refs)
80
80
  docxml = Nokogiri::XML(file) { |config| config.huge }
81
+ supply_repo_ids(docxml)
81
82
  update_indirect_refs_to_docs(docxml, internal_refs)
82
83
  add_document_suffix(identifier, docxml)
83
84
  update_direct_refs_to_docs(docxml, identifier)
@@ -89,6 +90,18 @@ module Metanorma
89
90
  docxml.to_xml
90
91
  end
91
92
 
93
+ def supply_repo_ids(docxml)
94
+ docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |b|
95
+ next if b&.at(ns("./docidentifier[@type = 'repository']"))
96
+
97
+ b.xpath(ns("./docidentifier")).each do |d|
98
+ next unless @files[d.text]
99
+
100
+ d.next = "<docidentifier type='repository'>current-metanorma-collection/#{d.text}"
101
+ end
102
+ end
103
+ end
104
+
92
105
  def datauri_encode(docxml)
93
106
  docxml.xpath(ns("//image")).each do |i|
94
107
  i["src"] = Metanorma::Utils::datauri(i["src"])
@@ -161,7 +174,7 @@ module Metanorma
161
174
  if @files[docid] then update_anchor_loc(bib, e, docid)
162
175
  else
163
176
  e << "<strong>** Unresolved reference to document #{docid} "\
164
- "from eref</strong>"
177
+ "from eref</strong>"
165
178
  end
166
179
  end
167
180
  end
@@ -188,7 +201,7 @@ module Metanorma
188
201
  ref = ins&.at(ns("./locality/referenceFrom"))&.text
189
202
  anchor = @files[docid][:anchors].dig(type, ref) or return
190
203
  ins << "<locality type='anchor'><referenceFrom>#{anchor.sub(/^_/, '')}"\
191
- "</referenceFrom></locality>"
204
+ "</referenceFrom></locality>"
192
205
  end
193
206
 
194
207
  # gather internal bibitem references
@@ -49,7 +49,7 @@ module Metanorma
49
49
  end
50
50
 
51
51
  def add_section_split_cover(files, manifest, ident)
52
- cover = section_split_cover(manifest, ident)
52
+ cover = section_split_cover(manifest, dir_name_cleanse(ident))
53
53
  files[ident][:out_path] = cover
54
54
  { attachment: true, index: false, out_path: cover,
55
55
  ref: File.join(File.dirname(manifest.file), cover) }
@@ -33,7 +33,7 @@ module Metanorma
33
33
  # output processor for flavour
34
34
  @isodoc = isodoc
35
35
 
36
- @outdir = options[:output_folder]
36
+ @outdir = dir_name_cleanse(options[:output_folder])
37
37
  @coverpage = options[:coverpage]
38
38
  @format = Util.sort_extensions_execution(options[:format])
39
39
  @compile_options = options[:compile] || {}
@@ -51,6 +51,10 @@ module Metanorma
51
51
  FileUtils.mkdir_p @outdir
52
52
  end
53
53
 
54
+ def dir_name_cleanse(name)
55
+ name.gsub(/[<>:"|?*]/, "_")
56
+ end
57
+
54
58
  # @param col [Metanorma::Collection] XML collection
55
59
  # @param options [Hash]
56
60
  # @option options [String] :coverpage cover page HTML (Liquid template)
@@ -214,6 +214,10 @@ module Metanorma
214
214
  elsif ext == :html && options[:sectionsplit]
215
215
  sectionsplit_convert(xml_name, isodoc, outfilename, isodoc_options)
216
216
  else
217
+ if ext == :pdf
218
+ floc = FontistUtils.fontist_font_locations(@processor, options)
219
+ isodoc_options[:mn2pdf] = { font_manifest_file: floc.path } if floc
220
+ end
217
221
  begin
218
222
  if @processor.use_presentation_xml(ext)
219
223
  @processor.output(nil, presentationxml_name, outfilename, ext,
@@ -245,13 +249,10 @@ module Metanorma
245
249
  isodoc_options = @processor.extract_options(file)
246
250
  isodoc_options[:datauriimage] = true if options[:datauriimage]
247
251
  isodoc_options[:sourcefilename] = options[:filename]
248
- %i(bare sectionsplit no_install_fonts).each do |x|
252
+ %i(bare sectionsplit no_install_fonts baseassetpath aligncrosselements)
253
+ .each do |x|
249
254
  isodoc_options[x] ||= options[x]
250
255
  end
251
- if ext == :pdf
252
- floc = FontistUtils.fontist_font_locations(@processor, options) and
253
- isodoc_options[:mn2pdf] = { font_manifest_file: floc.path }
254
- end
255
256
  isodoc_options
256
257
  end
257
258
 
@@ -49,7 +49,7 @@ module Metanorma
49
49
  extensions: defined?(extensions) ? extensions : nil,
50
50
  relaton: defined?(relaton) ? relaton : nil,
51
51
  asciimath: asciimath,
52
- }.reject { |_, val| val.nil? }
52
+ }.compact
53
53
  end
54
54
 
55
55
  def empty_attr(attr, name)
@@ -60,9 +60,9 @@ module Metanorma
60
60
  scripts-override scripts-pdf wordstylesheet i18nyaml
61
61
  standardstylesheet header wordcoverpage wordintropage
62
62
  ulstyle olstyle htmlstylesheet-override bare
63
- htmltoclevels doctoclevels sectionsplit
63
+ htmltoclevels doctoclevels sectionsplit base-asset-path
64
64
  body-font header-font monospace-font title-font
65
- wordstylesheet-override).freeze
65
+ align-cross-elements wordstylesheet-override).freeze
66
66
 
67
67
  def extract_options(file)
68
68
  header = file.sub(/\n\n.*$/m, "\n")
@@ -75,6 +75,7 @@ module Metanorma
75
75
  /\n:(?<hier_assets>hierarchical-assets:[^\n]*)\n/ =~ header
76
76
  /\n:(?<use_xinclude>use-xinclude:[^\n]*)\n/ =~ header
77
77
  /\n:(?<break_up>break-up-urls-in-tables:[^\n]*)\n/ =~ header
78
+ /\n:suppress-asciimath-dup: (?<suppress_asciimath_dup>[^\n]+)\n/ =~ header
78
79
 
79
80
  defined?(hier_assets) and
80
81
  hier_assets = empty_attr(hier_assets, "hierarchical-assets")
@@ -84,10 +85,11 @@ module Metanorma
84
85
  break_up = empty_attr(break_up, "break-up-urls-in-tables")
85
86
  ret.merge(
86
87
  datauriimage: defined?(datauriimage) ? datauriimage != "false" : nil,
88
+ suppressasciimathdup: defined?(suppress_asciimath_dup) ? suppress_asciimath_dup != "false" : nil,
87
89
  hierarchical_assets: defined?(hier_assets) ? hier_assets : nil,
88
90
  use_xinclude: defined?(use_xinclude) ? use_xinclude : nil,
89
91
  break_up_urls_in_tables: defined?(break_up) ? break_up : nil,
90
- ).reject { |_, val| val.nil? }
92
+ ).compact
91
93
  end
92
94
  end
93
95
  end
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "1.3.9".freeze
2
+ VERSION = "1.3.12".freeze
3
3
  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.3.9
4
+ version: 1.3.12
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-08-16 00:00:00.000000000 Z
11
+ date: 2021-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor