metanorma-ieee 1.2.12 → 1.2.13

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: 7c662d2e1d2098e3135362a0d30c7faa4f2bc09d7ff48ed141634d6387bd87f5
4
- data.tar.gz: 92a643d3c59276828c5d2176a05a16bcfdd5f70ee24d2425133356c04c183d72
3
+ metadata.gz: bc4895281aceec332b1a16b2d481ffcaf9e336ba9e2c49cfdc2d81015e85998c
4
+ data.tar.gz: ca5a9aae41560f57de081927bc688a5151c9deee0c0c1a75511f87de8e088f9a
5
5
  SHA512:
6
- metadata.gz: 72e2433351b0e929361911adf0069f4426a8e50c10b1c503a22d5c18aa0a2c6fcf6c9df33c43c96d5a63cb8ed8a60b9422d55f0516ed7490f93a374c7470e6c1
7
- data.tar.gz: c7b1b210e0cf40b99750a71cb24459485c79fc0bed2859258d2506dfe4c6a091f86142ccf01bdfba954a7e778330e8a0e1f5b939d789a254ddf021e4575c3ecb
6
+ metadata.gz: 42db1434c3b10a3d6389b5708f925a78fb5074aab2e2f9b29ec479e247733771f08fba5d0169ebb3e65f5a8fb7dcf1d9567728bdbc3fa65eb79d50c79eaaca80
7
+ data.tar.gz: 6fc8000efd5d636ad4e9c4ed869627e4a47344c2055597d8392cd45cc1d1064370a7e1cf03e10c46e32ced8e2a7bad73f63b3bce1aea720653a386a893f6315e
@@ -50,7 +50,8 @@ class Html2Doc
50
50
  l["class"] ||= list_style(type, level, "Middle")
51
51
  next unless l&.first_element_child&.name == "p"
52
52
 
53
- l["style"] += (l.first_element_child["style"]&.sub(/mso-list[^;]+;/, "") || "")
53
+ l["style"] +=
54
+ l.first_element_child["style"]&.sub(/mso-list[^;]+;/, "") || ""
54
55
  l.first_element_child.replace(l.first_element_child.children)
55
56
  end
56
57
  list.replace(list.children)
@@ -9887,18 +9887,33 @@
9887
9887
 
9888
9888
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name()='localityStack']"/>
9889
9889
 
9890
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="pdfAttachmentsList_">
9891
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
9892
+ <attachment filename="{@name}"/>
9893
+ </xsl:for-each>
9894
+ </xsl:variable>
9895
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
9896
+
9890
9897
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name()='link']" name="link">
9898
+ <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
9899
+ <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
9891
9900
  <xsl:variable name="target">
9892
9901
  <xsl:choose>
9893
9902
  <xsl:when test="@updatetype = 'true'">
9894
9903
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
9895
9904
  </xsl:when>
9905
+ <!-- link to the PDF attachment -->
9906
+ <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
9907
+ <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
9908
+ </xsl:when>
9909
+ <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
9910
+ <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
9911
+ </xsl:when>
9896
9912
  <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
9897
- <!-- link to the PDF attachment -->
9898
9913
  <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
9899
9914
  <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
9900
9915
  <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
9901
- </xsl:when>
9916
+ </xsl:when> -->
9902
9917
  <xsl:otherwise>
9903
9918
  <xsl:value-of select="normalize-space(@target)"/>
9904
9919
  </xsl:otherwise>
@@ -14544,6 +14559,17 @@
14544
14559
  <xsl:copy-of select="."/>
14545
14560
  </xsl:template>
14546
14561
 
14562
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
14563
+ <xsl:copy>
14564
+ <xsl:copy-of select="@*"/>
14565
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
14566
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
14567
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
14568
+ <xsl:value-of select="."/>
14569
+ </xsl:if>
14570
+ </xsl:copy>
14571
+ </xsl:template>
14572
+
14547
14573
  <!-- add @id, mandatory for table auto-layout algorithm -->
14548
14574
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
14549
14575
  <xsl:copy>
@@ -15520,7 +15546,8 @@
15520
15546
  </xsl:when>
15521
15547
  <xsl:otherwise>
15522
15548
  <!-- _{filename}_attachments -->
15523
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
15549
+ <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
15550
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15524
15551
  <pdf:embedded-file src="{$url}" filename="{@name}"/>
15525
15552
  </xsl:otherwise>
15526
15553
  </xsl:choose>
@@ -9887,18 +9887,33 @@
9887
9887
 
9888
9888
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name()='localityStack']"/>
9889
9889
 
9890
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="pdfAttachmentsList_">
9891
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
9892
+ <attachment filename="{@name}"/>
9893
+ </xsl:for-each>
9894
+ </xsl:variable>
9895
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
9896
+
9890
9897
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name()='link']" name="link">
9898
+ <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
9899
+ <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
9891
9900
  <xsl:variable name="target">
9892
9901
  <xsl:choose>
9893
9902
  <xsl:when test="@updatetype = 'true'">
9894
9903
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
9895
9904
  </xsl:when>
9905
+ <!-- link to the PDF attachment -->
9906
+ <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
9907
+ <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
9908
+ </xsl:when>
9909
+ <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
9910
+ <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
9911
+ </xsl:when>
9896
9912
  <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
9897
- <!-- link to the PDF attachment -->
9898
9913
  <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
9899
9914
  <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
9900
9915
  <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
9901
- </xsl:when>
9916
+ </xsl:when> -->
9902
9917
  <xsl:otherwise>
9903
9918
  <xsl:value-of select="normalize-space(@target)"/>
9904
9919
  </xsl:otherwise>
@@ -14544,6 +14559,17 @@
14544
14559
  <xsl:copy-of select="."/>
14545
14560
  </xsl:template>
14546
14561
 
14562
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
14563
+ <xsl:copy>
14564
+ <xsl:copy-of select="@*"/>
14565
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
14566
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
14567
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
14568
+ <xsl:value-of select="."/>
14569
+ </xsl:if>
14570
+ </xsl:copy>
14571
+ </xsl:template>
14572
+
14547
14573
  <!-- add @id, mandatory for table auto-layout algorithm -->
14548
14574
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
14549
14575
  <xsl:copy>
@@ -15520,7 +15546,8 @@
15520
15546
  </xsl:when>
15521
15547
  <xsl:otherwise>
15522
15548
  <!-- _{filename}_attachments -->
15523
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
15549
+ <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
15550
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15524
15551
  <pdf:embedded-file src="{$url}" filename="{@name}"/>
15525
15552
  </xsl:otherwise>
15526
15553
  </xsl:choose>
@@ -10,15 +10,6 @@ module IsoDoc
10
10
  logos
11
11
  end
12
12
 
13
- def logos
14
- here = File.join(File.dirname(__FILE__), "html")
15
- %i(wp_image001_emz wp_image003_emz wp_image008_emz)
16
- .each do |w|
17
- img = w.to_s.sub("_emz", ".emz")
18
- set(w, File.expand_path(File.join(here, img)))
19
- end
20
- end
21
-
22
13
  def logos
23
14
  here = File.join(File.dirname(__FILE__), "html")
24
15
  suffix = ".emz"
@@ -33,7 +24,7 @@ module IsoDoc
33
24
 
34
25
  def bibdate(isoxml, _out)
35
26
  isoxml.xpath(ns("//bibdata/date[@format = 'ddMMMyyyy']")).each do |d|
36
- set("#{d['type'].gsub('-', '_')}date".to_sym, Common::date_range(d))
27
+ set("#{d['type'].tr('-', '_')}date".to_sym, Common::date_range(d))
37
28
  end
38
29
  draft = isoxml.at(ns("//bibdata/date[@type = 'issued']")) ||
39
30
  isoxml.at(ns("//bibdata/date[@type = 'circulated']")) ||
@@ -45,15 +45,36 @@ module IsoDoc
45
45
  super
46
46
  end
47
47
 
48
+ KEEP_BIBRENDER_XPATH =
49
+ "./docidentifier | ./uri | ./note | ./title | ./biblio-tag".freeze
50
+
48
51
  def bibrender_relaton(xml, renderings)
49
52
  f = renderings[xml["id"]][:formattedref]
50
53
  fn = availability_note(xml)
51
54
  f &&= "<formattedref>#{f}#{fn}</formattedref>"
52
- keep = "./docidentifier | ./uri | ./note | ./title | ./biblio-tag"
53
- xml.children = "#{f}#{xml.xpath(ns(keep)).to_xml}"
55
+ xml.children = "#{f}#{xml.xpath(ns(KEEP_BIBRENDER_XPATH)).to_xml}"
56
+ author_date(xml, renderings)
54
57
  @author[xml["id"]] = renderings[xml["id"]][:author]
55
58
  end
56
59
 
60
+ def author_date(xml, renderings)
61
+ author_date?(xml) or return
62
+ cit = renderings[xml["id"]][:citation]
63
+ xml << "<docidentifier type='metanorma'>#{cit}</docidentifier>"
64
+ xml.at(ns("./biblio-tag"))&.remove
65
+ xml << "<biblio-tag>#{cit}, </biblio-tag>"
66
+ end
67
+
68
+ def author_date?(xml)
69
+ ret = !xml["type"]
70
+ ret ||= %w(standard techreport website webresource)
71
+ .include?(xml["type"])
72
+ ret ||= xml.at(".//ancestor::xmlns:references[@normative = 'false']")
73
+ ret ||= xml.at(ns("./docidentifier[@type = 'metanorma']"))
74
+ ret and return false
75
+ true
76
+ end
77
+
57
78
  def creatornames(bibitem)
58
79
  ::Relaton::Render::IEEE::General
59
80
  .new(language: @lang, i18nhash: @i18n.get,
@@ -86,7 +86,7 @@ module IsoDoc
86
86
  ins = coll.first.previous_element
87
87
  ret = sort_related(coll)
88
88
  coll.each(&:remove)
89
- ret.reverse.each { |t| ins.next = t }
89
+ ret.reverse_each { |t| ins.next = t }
90
90
  ins.parent.xpath(ns("./related"))
91
91
  end
92
92
 
@@ -144,7 +144,7 @@ module IsoDoc
144
144
  coll = terms.xpath(ns("./term"))
145
145
  ret = sort_terms(coll)
146
146
  coll.each(&:remove)
147
- ret.reverse.each { |t| ins.next = t }
147
+ ret.reverse_each { |t| ins.next = t }
148
148
  end
149
149
 
150
150
  def sort_terms(terms)
@@ -63,13 +63,17 @@ module IsoDoc
63
63
  capitalise_xref(node, linkend, anchor_value(node["target"]))
64
64
  end
65
65
 
66
+ def eref_locality_populate(type, node, number)
67
+ type == "page" and return ""
68
+ super
69
+ end
70
+
66
71
  def block_delim
67
72
  "&#x2014;"
68
73
  end
69
74
 
70
75
  def note1(elem)
71
- return if elem.parent.name == "bibitem" || elem["notag"] == "true"
72
-
76
+ elem.parent.name == "bibitem" || elem["notag"] == "true" and return
73
77
  n = @xrefs.get[elem["id"]]
74
78
  lbl = if n.nil? || n[:label].nil? || n[:label].empty? then @i18n.note
75
79
  else l10n("#{@i18n.note} #{n[:label]}")
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module IEEE
3
- VERSION = "1.2.12".freeze
3
+ VERSION = "1.2.13".freeze
4
4
  end
5
5
  end
@@ -41,4 +41,5 @@ Gem::Specification.new do |spec|
41
41
  spec.add_development_dependency "timecop", "~> 0.9"
42
42
  spec.add_development_dependency "vcr", "~> 6.1.0"
43
43
  spec.add_development_dependency "webmock"
44
+ spec.add_development_dependency "xml-c14n"
44
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ieee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.12
4
+ version: 1.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-22 00:00:00.000000000 Z
11
+ date: 2024-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -220,6 +220,20 @@ dependencies:
220
220
  - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: xml-c14n
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
223
237
  description: 'Metanorma for the ITU.
224
238
 
225
239
  '