metanorma-iso 2.1.9 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,12 +3,20 @@ module Metanorma
3
3
  class Modspec
4
4
  # Don't want to inherit from Metanorma::Requirements::Modspec
5
5
  class Iso < ::Metanorma::Requirements::Modspec
6
+ def recommendation_label_xref(elem, label, xrefs, _type)
7
+ id = @reqtlabels[label]
8
+ number = xrefs.anchor(id, :xref_reqt2reqt, false)
9
+ number.nil? and return type
10
+ elem.ancestors("requirement, recommendation, permission").empty? and
11
+ return number
12
+ "<xref target='#{id}'>#{number}</xref>"
13
+ end
14
+
6
15
  def recommendation_label(elem, type, xrefs)
7
16
  lbl = super
8
17
  title = elem.at(ns("./title"))
9
- return lbl unless title # &&
10
-
11
- # elem.ancestors("requirement, recommendation, permission").empty?
18
+ return lbl unless title &&
19
+ elem.ancestors("requirement, recommendation, permission").empty?
12
20
 
13
21
  lbl += l10n(": ") if lbl
14
22
  lbl += title.children.to_xml
@@ -30,7 +38,7 @@ module Metanorma
30
38
  def requirement_component_parse(node, out)
31
39
  if node["exclude"] != "true" && node.name == "description"
32
40
  lbl = "statement"
33
- lbl = "declaration" if recommend_class(node) == "recommendclass"
41
+ lbl = "description" if recommend_class(node.parent) == "recommendclass"
34
42
  out << "<tr><td>#{@labels['modspec'][lbl]}</td>"\
35
43
  "<td>#{node.children.to_xml}</td></tr>"
36
44
  else
@@ -54,6 +62,61 @@ module Metanorma
54
62
  m << t.at(ns("./name")).children.to_xml
55
63
  end.join("<br/>")
56
64
  end
65
+
66
+ def postprocess_anchor_struct(block, anchor)
67
+ super
68
+ anchor[:xref_reqt2reqt] = anchor[:xref_bare]
69
+ if l = block.at(ns("./title"))
70
+ anchor[:xref_reqt2reqt] +=
71
+ l10n(": ") + l.children.to_xml.strip
72
+ end
73
+ anchor
74
+ end
75
+
76
+ def reqt_ids(docxml)
77
+ docxml.xpath(ns("//requirement | //recommendation | //permission"))
78
+ .each_with_object({}) do |r, m|
79
+ id = r.at(ns("./identifier")) or next
80
+ m[id.text] =
81
+ { id: r["id"],
82
+ lbl: @xrefs.anchor(r["id"], :xref_reqt2reqt, false) }
83
+ end
84
+ end
85
+
86
+ def reqt_links_test(docxml)
87
+ docxml.xpath(ns("//requirement | //recommendation | //permission"))
88
+ .each_with_object({}) do |r, m|
89
+ next unless %w(conformanceclass
90
+ verification).include?(r["type"])
91
+
92
+ subj = r.at(ns("./classification[tag = 'target']/value"))
93
+ id = r.at(ns("./identifier")) or next
94
+ lbl = @xrefs.anchor(@reqt_ids[id.text.strip][:id], :xref_reqt2reqt,
95
+ false)
96
+ next unless subj
97
+
98
+ m[subj.text] = { lbl: lbl, id: r["id"] }
99
+ end
100
+ end
101
+
102
+ def reqt_links_class(docxml)
103
+ docxml.xpath(ns("//requirement | //recommendation | //permission"))
104
+ .each_with_object({}) do |r, m|
105
+ next unless %w(class
106
+ conformanceclass).include?(r["type"])
107
+
108
+ id = r.at(ns("./identifier")) or next
109
+ r.xpath(ns("./requirement | ./recommendation | ./permission"))
110
+ .each do |r1|
111
+ id1 = r1.at(ns("./identifier")) or next
112
+ lbl = @xrefs.anchor(@reqt_ids[id.text.strip][:id],
113
+ :xref_reqt2reqt, false)
114
+ next unless lbl
115
+
116
+ m[id1.text] = { lbl: lbl, id: r["id"] }
117
+ end
118
+ end
119
+ end
57
120
  end
58
121
  end
59
122
  end
data/lib/metanorma-iso.rb CHANGED
@@ -10,6 +10,7 @@ require_relative "isodoc/iso/isosts_convert"
10
10
  require_relative "isodoc/iso/presentation_xml_convert"
11
11
  require_relative "html2doc/lists"
12
12
  require "asciidoctor/extensions"
13
+ require "metanorma"
13
14
 
14
15
  if defined? Metanorma::Registry
15
16
  require_relative "metanorma/iso"
@@ -1,4 +1,56 @@
1
+ extenttemplate:
2
+ book: "{{ volume }} {{ page }}"
3
+ booklet: book
4
+ proceedings: book
5
+ journal: book
6
+ standard: book
7
+ techreport: book
8
+ inbook: "{{ volume }} {{ page }}"
9
+ misc: "{{ volume }} {{issue}} {{ page }}, {{ duration }}"
10
+ nametemplate:
11
+ one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0]}} {{initials[0] | join: ''}}.{% endif %}"
12
+ two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0]}} {{initials[0] | join: ''}}.{% endif %} , & {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1]}} {{initials[1] | join: ''}}.{% endif %}"
13
+ more: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0]}} {{initials[0] | join: ''}}.{% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1]}} {{initials[1] | join: ''}}. {% endif %} , & {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{{surname[2]}} {{initials[2] | join: ''}}.{% endif %}"
14
+ # disabled the following: they should be provided in inheriting calls
15
+ # etal: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] | upcase}} ,_{%if given[0]%}{{given[0]}} {{middle[0]}}{%else%}{{initials[0] | join: ' '}}.{%endif%}{% endif %}, {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{%if given[1]%}{{given[1]}} {{middle[1]}}{%else%}{{initials[1] | join: ' '}}.{%endif%} {{surname[1] | upcase}}{% endif %} <em>et al.</em>"
16
+ # etal_count: 5
17
+ seriestemplate: "{% if series_formatted %}{{ series_formatted }}{%else%}{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %} ({{series_run}}) {{series_num}}|({{series_partnumber}}){%endif%}"
18
+ journaltemplate: "<em>{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %}</em> ({{series_run}}) {{ labels['volume'] }}_{{series_num}} {{ labels['part'] }}_{{series_partnumber}}"
1
19
  template:
2
20
  # skip standardidentifier, it is inserted in front of formattedref within metanorma
3
21
  standard: "<em><span_class='stddocTitle'>{{ title }}</span></em> ,_{{ extent }}."
4
- website: "{{ creatornames }} ({{ role }}) . <em><span_class='stddocTitle'>{{ title }}</span></em> [website]. {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{ place }}: {{ publisher }}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ standardidentifier | first }}. {{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
22
+ website: "<smallcap>{{ creatornames }}</smallcap> ({{ role }}) . <em><span_class='stddocTitle'>{{ title }}</span></em> [website]. {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{place}}: {{ publisher }}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
23
+ book: "<smallcap>{{ creatornames }}</smallcap> ({{role}}) . <em>{{ title }}</em> . {{ edition | capitalize_first }}. ({{ series }}). {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}. {{date}}. {{size}}. {{extent}}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
24
+ booklet: book
25
+ manual: book
26
+ proceedings: book
27
+ inbook: "<smallcap>{{ creatornames }}</smallcap> ({{role}}) . {{ title }} . <em>{{host_title}}</em> ({{host_role}} {{ host_creatornames}}). {{ edition | capitalize_first }}. ({{ series }}). {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}. {{date}}. {{size}}. {{extent}}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
28
+ inproceedings: inbook
29
+ incollection: inbook
30
+ journal: "<em>{{ title}}</em> . {{ edition | capitalize_first }}. {{place}}: {{publisher}}. {{date}}. {{size}}. {{extent}}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
31
+ article: "<smallcap>{{ creatornames }}</smallcap> ({{role}}) . {{ title }}. {{ series }} . {{date}}, {{ extent }}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
32
+ software: "<smallcap>{{ creatornames }}</smallcap> ({{ role}}) . <em>{{ title }}</em> . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize}}. {{place}}: {{publisher}}. {{date}}. {{size}}. {{extent}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
33
+ electronic resource: software
34
+ dataset: "<smallcap>{{ creatornames }}</smallcap> ({{ role }}) . <em>{{ title }}</em> . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize }}. {{ labels['in'] | capitalize }}:_{{series}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join '. ' }}. {{ other_identifier | join '. ' }}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. {{ size }}. {{ extent}}. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
35
+ webresource: website
36
+ unpublished: "<smallcap>{{ creatornames }}</smallcap> ({{ role }}) . <em>{{ title }}</em> . {{ medium | capitalize }}. {{ date }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. [{{ labels['viewed'] }}:_{{date_accessed}}]."
37
+ presentation: unpublished
38
+ thesis: "<smallcap>{{ creatornames }}</smallcap> ({{ role }}) . <em>{{ title }}</em> . {{ medium | capitalize }}. {{place}}: {{ publisher }}. {{ date }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. ._{{ labels['availablefrom'] }}:_<span_class='biburl'>{{ uri }}</span>. [{{ labels['viewed'] }}:_{{date_accessed}}]."
39
+ misc: "<smallcap>{{ creatornames }}</smallcap> ({{ role }}) . <em>{{ title }}</em> . {{ date }}."
40
+ # following are # unsupported types:
41
+ map: misc
42
+ audiovisual: misc
43
+ film: misc
44
+ video: misc
45
+ broadcast: misc
46
+ graphic_work: misc
47
+ music: misc
48
+ performance: misc
49
+ patent: misc
50
+ archival: misc
51
+ social_media: misc
52
+ alert: misc
53
+ message: misc
54
+ conversation: misc
55
+ internal: misc
56
+
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
30
30
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
31
31
 
32
- spec.add_dependency "metanorma-standoc", "~> 2.2.0"
32
+ spec.add_dependency "metanorma-standoc", "~> 2.2.4"
33
33
  spec.add_dependency "mnconvert", "~> 1.14"
34
34
  spec.add_dependency "pubid-iso"
35
35
  spec.add_dependency "ruby-jing"
@@ -1332,7 +1332,7 @@ RSpec.describe IsoDoc do
1332
1332
  <clause id="D" obligation="normative" type="scope" displayorder='3'>
1333
1333
  <title depth="1">1<tab/>Scope</title>
1334
1334
  <p id="E">
1335
- <eref bibitemid="ISO712" type="inline"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality>ISO 712, <span class='citetbl'>第1–1表</span></eref>
1335
+ <eref bibitemid="ISO712" type="inline"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality>ISO 712 <span class='citetbl'>第1–1表</span></eref>
1336
1336
  </p>
1337
1337
  </clause>
1338
1338
  <clause id="H" obligation="normative" displayorder='5'>
@@ -1423,7 +1423,7 @@ RSpec.describe IsoDoc do
1423
1423
  <div id='D'>
1424
1424
  <h1>1 Scope</h1>
1425
1425
  <p id='E'>
1426
- <a href='#ISO712'>ISO 712, 第1–1表</a>
1426
+ <a href='#ISO712'>ISO 712 第1–1表</a>
1427
1427
  </p>
1428
1428
  </div>
1429
1429
  <div>
@@ -209,12 +209,12 @@ RSpec.describe IsoDoc do
209
209
  <references id="_bibliography" normative="false" obligation="informative" displayorder="3">
210
210
  <title depth="1">Bibliography</title>
211
211
  <bibitem id="ISBN" type="book">
212
- <formattedref><em>Chemicals for analytical laboratory use</em>. n.p.: n.d. ISBN.</formattedref>
212
+ <formattedref><em>Chemicals for analytical laboratory use</em>. n.p.: n.d. </formattedref>
213
213
  <docidentifier type="metanorma-ordinal">[1]</docidentifier>
214
214
  <docidentifier type="ISBN">ISBN</docidentifier>
215
215
  </bibitem>
216
216
  <bibitem id="ISSN" type="journal">
217
- <formattedref><em>Instruments for analytical laboratory use</em>. n.d. ISSN.</formattedref>
217
+ <formattedref><em>Instruments for analytical laboratory use</em>. n.d.</formattedref>
218
218
  <docidentifier type="metanorma-ordinal">[2]</docidentifier>
219
219
  <docidentifier type="ISSN">ISSN</docidentifier>
220
220
  </bibitem>
@@ -326,12 +326,12 @@ RSpec.describe IsoDoc do
326
326
  <p id='ISBN' class='Biblio'>
327
327
  [1] 
328
328
  <i>Chemicals for analytical laboratory use</i>
329
- . n.p.: n.d. ISBN.
329
+ . n.p.: n.d.
330
330
  </p>
331
331
  <p id='ISSN' class='Biblio'>
332
332
  [2] 
333
333
  <i>Instruments for analytical laboratory use</i>
334
- . n.d. ISSN.
334
+ . n.d.
335
335
  </p>
336
336
  <div class='Note'>
337
337
  <p>