metanorma-iho 1.1.9 → 1.2.0

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.
@@ -13,6 +13,19 @@ module IsoDoc
13
13
  a = xml.at(ns("//bibdata/series[@type = 'main']/abbreviation"))&.text and
14
14
  set(:seriesabbr, a)
15
15
  end
16
+
17
+ def title1(xml, type)
18
+ xml.at(ns("//bibdata/title[@type='title-#{type}']"))
19
+ &.children&.to_xml
20
+ end
21
+
22
+ def title(isoxml, _out)
23
+ set(:doctitle, isoxml.at(ns("//bibdata/title[@type='main']"))
24
+ &.children&.to_xml || "")
25
+ %w(main appendix annex part supplement).each do |e|
26
+ t = title1(isoxml, e) and set("#{e}title".to_sym, t)
27
+ end
28
+ end
16
29
  end
17
30
  end
18
31
  end
@@ -0,0 +1,46 @@
1
+ module Metanorma
2
+ module Iho
3
+ class Converter < Metanorma::Generic::Converter
4
+ def bibdata_docidentifier_cleanup(isoxml)
5
+ bibdata_docidentifier_i18n(isoxml)
6
+ super
7
+ end
8
+
9
+ def bibdata_docidentifier_i18n(isoxml)
10
+ id, parts = bibdata_docidentifier_i18n_prep(isoxml)
11
+ parts.empty? and return
12
+ id_alt = id.dup
13
+ id.next = id_alt
14
+ id_alt["type"] = "IHO-parent-document"
15
+ id_alt.delete("primary")
16
+ bibdata_docidentifier_enhance(id, parts)
17
+ end
18
+
19
+ def bibdata_docidentifier_i18n_prep(isoxml)
20
+ id = isoxml.at("//bibdata/docidentifier[@type = 'IHO']")
21
+ parts = %w(appendixid annexid part supplementid)
22
+ .each_with_object({}) do |w, m|
23
+ dn = isoxml.at("//bibdata/ext/structuredidentifier/#{w}") and
24
+ m[w] = dn.text
25
+ end
26
+ [id, parts]
27
+ end
28
+
29
+ ID_LABELS = {
30
+ appendixid: "Appendix",
31
+ annexid: "Annex",
32
+ part: "Part",
33
+ supplementid: "Supplement",
34
+ }.freeze
35
+
36
+ # not language-specific, just space-delimited
37
+ def bibdata_docidentifier_enhance(id, parts)
38
+ ret = %w(part appendixid annexid supplementid)
39
+ .each_with_object([]) do |w, m|
40
+ p = parts[w] and m << "#{ID_LABELS[w.to_sym]} #{p}"
41
+ end
42
+ id.children = "#{id.text} #{ret.join(' ')}"
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,5 +1,7 @@
1
1
  require "metanorma/standoc/converter"
2
2
  require "metanorma/generic/converter"
3
+ require_relative "cleanup"
4
+ require_relative "front"
3
5
 
4
6
  module Metanorma
5
7
  module Iho
@@ -10,78 +12,6 @@ module Metanorma
10
12
  true
11
13
  end
12
14
 
13
- SERIESNAME = {
14
- B: "Bathymetric",
15
- C: "Capacity Building",
16
- M: "Miscellaneous",
17
- P: "Periodic",
18
- S: "Standards and Specifications",
19
- }.freeze
20
-
21
- def metadata_series(node, xml)
22
- series = node.attr("series") or return
23
- xml.series type: "main" do |s|
24
- s.title SERIESNAME[series.to_sym] || "N/A"
25
- s.abbreviation series
26
- end
27
- end
28
-
29
- def metadata_ext(node, ext)
30
- super
31
- metadata_commentperiod(node, ext)
32
- end
33
-
34
- def metadata_commentperiod(node, xml)
35
- from = node.attr("comment-from") or return
36
- to = node.attr("comment-to")
37
- xml.commentperiod do |c|
38
- c.from from
39
- c.to to if to
40
- end
41
- end
42
-
43
- def metadata_committee(node, xml)
44
- unless node.attr("workgroup")
45
- @log.add("AsciiDoc Input", nil,
46
- "Missing workgroup attribute for document")
47
- return
48
- end
49
- metadata_committee1(node, xml)
50
- end
51
-
52
- def metadata_committee1(node, xml)
53
- xml.editorialgroup do |a|
54
- a.committee do |n|
55
- n.abbreviation node.attr("committee").upcase
56
- end
57
- a.workgroup do |n|
58
- n.abbreviation node.attr("workgroup").upcase
59
- end
60
- end
61
- i = 2
62
- while node.attr("workgroup_#{i}")
63
- xml.editorialgroup do |a|
64
- a.committee do |n|
65
- n.abbreviation node.attr("committee_#{i}").upcase
66
- end
67
- a.workgroup do |n|
68
- n.abbreviation node.attr("workgroup_#{i}").upcase
69
- end
70
- end
71
- i += 1
72
- end
73
- end
74
-
75
- def metadata_version(node, xml)
76
- if node.attr("edition-major")
77
- ed = node.attr("edition-major")
78
- e1 = node.attr("edition-minor") and ed += ".#{e1}"
79
- (e2 = node.attr("edition-patch")) && e1 and ed += ".#{e2}"
80
- node.set_attribute("edition", ed)
81
- end
82
- super
83
- end
84
-
85
15
  def configuration
86
16
  Metanorma::Iho.configuration
87
17
  end
@@ -0,0 +1,142 @@
1
+ module Metanorma
2
+ module Iho
3
+ class Converter < Metanorma::Generic::Converter
4
+ SERIESNAME = {
5
+ B: "Bathymetric",
6
+ C: "Capacity Building",
7
+ M: "Miscellaneous",
8
+ P: "Periodic",
9
+ S: "Standards and Specifications",
10
+ }.freeze
11
+
12
+ def metadata_series(node, xml)
13
+ series = node.attr("series") or return
14
+ xml.series type: "main" do |s|
15
+ s.title SERIESNAME[series.to_sym] || "N/A"
16
+ s.abbreviation series
17
+ end
18
+ end
19
+
20
+ def metadata_ext(node, ext)
21
+ super
22
+ metadata_commentperiod(node, ext)
23
+ end
24
+
25
+ def metadata_commentperiod(node, xml)
26
+ from = node.attr("comment-from") or return
27
+ to = node.attr("comment-to")
28
+ xml.commentperiod do |c|
29
+ c.from from
30
+ c.to to if to
31
+ end
32
+ end
33
+
34
+ def metadata_committee(node, xml)
35
+ unless node.attr("workgroup")
36
+ @log.add("AsciiDoc Input", nil,
37
+ "Missing workgroup attribute for document")
38
+ return
39
+ end
40
+ metadata_committee1(node, xml)
41
+ end
42
+
43
+ def metadata_committee1(node, xml)
44
+ xml.editorialgroup do |a|
45
+ a.committee do |n|
46
+ n.abbreviation node.attr("committee").upcase
47
+ end
48
+ a.workgroup do |n|
49
+ n.abbreviation node.attr("workgroup").upcase
50
+ end
51
+ end
52
+ i = 2
53
+ while node.attr("workgroup_#{i}")
54
+ xml.editorialgroup do |a|
55
+ a.committee do |n|
56
+ n.abbreviation node.attr("committee_#{i}").upcase
57
+ end
58
+ a.workgroup do |n|
59
+ n.abbreviation node.attr("workgroup_#{i}").upcase
60
+ end
61
+ end
62
+ i += 1
63
+ end
64
+ end
65
+
66
+ def metadata_version(node, xml)
67
+ if node.attr("edition-major")
68
+ ed = node.attr("edition-major")
69
+ e1 = node.attr("edition-minor") and ed += ".#{e1}"
70
+ (e2 = node.attr("edition-patch")) && e1 and ed += ".#{e2}"
71
+ node.set_attribute("edition", ed)
72
+ end
73
+ super
74
+ end
75
+
76
+ def title(node, xml)
77
+ m = full_title_prep(node)
78
+ full_title(m, xml)
79
+ title = node.attr("title")
80
+ xml.title **attr_code(type: "title-main") do |t1|
81
+ t1 << Metanorma::Utils::asciidoc_sub(title)
82
+ end
83
+ %i(appendix annex part supplement).each do |w|
84
+ typed_title(m, xml, w)
85
+ end
86
+ end
87
+
88
+ def typed_title(metadata, xml, type)
89
+ metadata[type] or return
90
+ title = full_title_part(metadata, type, TITLE_COMPONENTS[type][:id],
91
+ TITLE_COMPONENTS[type][:info])
92
+ xml.title **attr_code(type: "title-#{type}") do |t1|
93
+ t1 << Metanorma::Utils::asciidoc_sub(title)
94
+ end
95
+ end
96
+
97
+ TITLE_COMPONENTS = {
98
+ main: {},
99
+ part: { id: :partid },
100
+ annex: { id: :annexid, info: :infoannex },
101
+ appendix: { id: :appendixid },
102
+ supplement: { id: :supplementid },
103
+ }.freeze
104
+
105
+ def full_title(metadata, xml)
106
+ parts = TITLE_COMPONENTS.keys.each_with_object([]) do |p, acc|
107
+ acc << full_title_part(metadata, p, TITLE_COMPONENTS[p][:id],
108
+ TITLE_COMPONENTS[p][:info])
109
+ end
110
+ xml.title **attr_code(type: "main") do |t1|
111
+ t1 << Metanorma::Utils::asciidoc_sub(parts.compact.join(", "))
112
+ end
113
+ end
114
+
115
+ TITLE_ID_LABELS = { main: "", annex: "Annex", appendix: "Appendix",
116
+ part: "Part", supplement: "Supplement" }.freeze
117
+
118
+ def full_title_part(metadata, type, id, info)
119
+ metadata[type] or return nil
120
+ lbl = TITLE_ID_LABELS[type.to_sym]
121
+ metadata[id] and lbl += " #{metadata[id]}"
122
+ metadata[info] and lbl += " (Informative)"
123
+ %i(appendix supplement part).include?(type) and lbl += ":"
124
+ lbl == :main or lbl += " "
125
+ lbl + metadata[type]
126
+ end
127
+
128
+ def full_title_prep(node)
129
+ { main: node.attr("title") || node.title,
130
+ annex: node.attr("title-annex"),
131
+ appendix: node.attr("title-appendix"),
132
+ supplement: node.attr("title-supplement"),
133
+ part: node.attr("title-part"),
134
+ partid: node.attr("partnumber"),
135
+ annexid: node.attr("annex-id"),
136
+ appendixid: node.attr("appendix-id"),
137
+ supplementid: node.attr("supplement-id"),
138
+ infoannex: node.attr("semantic-metadata-annex-informative") == "true" }
139
+ end
140
+ end
141
+ end
142
+ end
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <!-- VERSION v2.0.7 -->
3
+ <!-- VERSION v2.0.8 -->
4
4
 
5
5
  <!--
6
6
  ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
@@ -72,6 +72,46 @@ but to `@anchor`, the user-supplied cross-reference</a:documentation>
72
72
  </oneOrMore>
73
73
  </element>
74
74
  </define>
75
+ <define name="review">
76
+ <a:documentation>Generalise BasicDoc element from just review comments, to general annotations;
77
+ the type attribute defaults to `review` for reviews</a:documentation>
78
+ <element name="annotation">
79
+ <ref name="RequiredId"/>
80
+ <ref name="ReviewAttributes"/>
81
+ <oneOrMore>
82
+ <ref name="paragraph">
83
+ <a:documentation>Reviewer comments content</a:documentation>
84
+ </ref>
85
+ </oneOrMore>
86
+ </element>
87
+ </define>
88
+ <define name="ruby_pronunciation">
89
+ <a:documentation>Ruby annotation giving pronunciation of text: change tag from BasicDoc for disambiguation</a:documentation>
90
+ <element name="ruby-pronunciation">
91
+ <attribute name="value">
92
+ <a:documentation>Ruby annotation value</a:documentation>
93
+ </attribute>
94
+ <ref name="LocalizedStringAttributes"/>
95
+ </element>
96
+ </define>
97
+ <define name="ruby_annotation">
98
+ <a:documentation>Ruby annotation giving information other than pronunciation of text: change tag from BasicDoc for disambiguation</a:documentation>
99
+ <element name="ruby-annotation">
100
+ <attribute name="value">
101
+ <a:documentation>Ruby annotation value</a:documentation>
102
+ </attribute>
103
+ <ref name="LocalizedStringAttributes"/>
104
+ </element>
105
+ </define>
106
+ <define name="annotation">
107
+ <a:documentation>Source code annotation, corresponding to a callout</a:documentation>
108
+ <element name="callout-annotation">
109
+ <ref name="RequiredId"/>
110
+ <oneOrMore>
111
+ <ref name="paragraph"/>
112
+ </oneOrMore>
113
+ </element>
114
+ </define>
75
115
  <define name="section-title">
76
116
  <a:documentation>Title(s) of a clause</a:documentation>
77
117
  <element name="title">
@@ -540,7 +580,7 @@ normative or informative references, some split references into sections organiz
540
580
  <ref name="OptionalId"/>
541
581
  <optional>
542
582
  <attribute name="style">
543
- <a:documentation>CSS style: only background-color supported</a:documentation>
583
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
544
584
  </attribute>
545
585
  </optional>
546
586
  </define>
@@ -620,7 +660,7 @@ This is done if the footnote reference is already presented in some other form,
620
660
  <ref name="RequiredId"/>
621
661
  <optional>
622
662
  <attribute name="style">
623
- <a:documentation>CSS style: only background-color supported</a:documentation>
663
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
624
664
  </attribute>
625
665
  </optional>
626
666
  </define>
@@ -700,6 +740,11 @@ titlecase, or lowercase</a:documentation>
700
740
  <a:documentation>Width of the table block in rendering</a:documentation>
701
741
  </attribute>
702
742
  </optional>
743
+ <optional>
744
+ <attribute name="style">
745
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
746
+ </attribute>
747
+ </optional>
703
748
  <ref name="BlockAttributes"/>
704
749
  </define>
705
750
  <define name="FigureAttributes" combine="interleave">
@@ -1417,7 +1462,7 @@ numbers</a:documentation>
1417
1462
  </optional>
1418
1463
  <ref name="DocumentBody"/>
1419
1464
  <optional>
1420
- <ref name="review-container">
1465
+ <ref name="annotation-container">
1421
1466
  <a:documentation>Annotations to the document</a:documentation>
1422
1467
  </ref>
1423
1468
  </optional>
@@ -1461,8 +1506,8 @@ numbers</a:documentation>
1461
1506
  </oneOrMore>
1462
1507
  </element>
1463
1508
  </define>
1464
- <define name="review-container">
1465
- <element name="review-container">
1509
+ <define name="annotation-container">
1510
+ <element name="annotation-container">
1466
1511
  <oneOrMore>
1467
1512
  <ref name="review"/>
1468
1513
  </oneOrMore>
@@ -27,6 +27,33 @@
27
27
  </oneOrMore>
28
28
  </element>
29
29
  </define>
30
+ <define name="structuredidentifier">
31
+ <element name="structuredidentifier">
32
+ <element name="docnumber">
33
+ <text/>
34
+ </element>
35
+ <optional>
36
+ <element name="part">
37
+ <text/>
38
+ </element>
39
+ </optional>
40
+ <optional>
41
+ <element name="annexid">
42
+ <text/>
43
+ </element>
44
+ </optional>
45
+ <optional>
46
+ <element name="appendixid">
47
+ <text/>
48
+ </element>
49
+ </optional>
50
+ <optional>
51
+ <element name="supplementid">
52
+ <text/>
53
+ </element>
54
+ </optional>
55
+ </element>
56
+ </define>
30
57
  </include>
31
58
  <define name="BibDataExtensionType" combine="interleave">
32
59
  <optional>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Iho
3
- VERSION = "1.1.9".freeze
3
+ VERSION = "1.2.0".freeze
4
4
  end
5
5
  end
data/metanorma.yml CHANGED
@@ -78,3 +78,15 @@ fonts_manifest:
78
78
  Source Han Sans:
79
79
  Source Han Sans Normal:
80
80
  STIX Two Math:
81
+ metadata_extensions:
82
+ structuredidentifier:
83
+ docnumber:
84
+ partnumber:
85
+ _output: part
86
+ appendix-id:
87
+ _output: appendixid
88
+ annex-id:
89
+ _output: annexid
90
+ supplement-id:
91
+ _output: supplementid
92
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iho
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.9
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-06-23 00:00:00.000000000 Z
11
+ date: 2025-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic
@@ -242,7 +242,9 @@ files:
242
242
  - lib/metanorma/iho/biblio-standoc.rng
243
243
  - lib/metanorma/iho/biblio.rng
244
244
  - lib/metanorma/iho/boilerplate.adoc
245
+ - lib/metanorma/iho/cleanup.rb
245
246
  - lib/metanorma/iho/converter.rb
247
+ - lib/metanorma/iho/front.rb
246
248
  - lib/metanorma/iho/iho.rng
247
249
  - lib/metanorma/iho/isodoc.rng
248
250
  - lib/metanorma/iho/processor.rb