metanorma-iho 1.1.3 → 1.1.5

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.
@@ -17,19 +17,6 @@ _bib)
17
17
 
18
18
  def middle_title(docxml); end
19
19
 
20
- def preface_rearrange(doc)
21
- preface_move(doc.xpath(ns("//preface/abstract")),
22
- %w(foreword executivesummary introduction clause acknowledgements), doc)
23
- preface_move(doc.xpath(ns("//preface/foreword")),
24
- %w(executivesummary introduction clause acknowledgements), doc)
25
- preface_move(doc.xpath(ns("//preface/executivesummary")),
26
- %w(introduction clause acknowledgements), doc)
27
- preface_move(doc.xpath(ns("//preface/introduction")),
28
- %w(clause acknowledgements), doc)
29
- preface_move(doc.xpath(ns("//preface/acknowledgements")),
30
- %w(), doc)
31
- end
32
-
33
20
  def bibdata(docxml)
34
21
  super
35
22
  dochistory(docxml)
@@ -86,18 +73,19 @@ _bib)
86
73
  end
87
74
 
88
75
  def dochistory_contributor(contrib)
89
- ret = contrib.at("./organization/abbreviation") ||
90
- contrib.at("./organization/subdivision") ||
91
- contrib.at("./organization/name") ||
92
- contrib.at("./person/name/abbreviation") ||
93
- contrib.at("./person/name/completename")
76
+ ret = contrib.at(ns("./organization/abbreviation")) ||
77
+ contrib.at(ns("./organization/subdivision")) ||
78
+ contrib.at(ns("./organization/name")) ||
79
+ contrib.at(ns("./person/name/abbreviation")) ||
80
+ contrib.at(ns("./person/name/completename"))
94
81
  ret and return ret.text
95
82
  format_personalname(contrib)
96
83
  end
97
84
 
98
85
  def format_personalname(contrib)
99
86
  Relaton::Render::General.new(template: { book: "{{ creatornames }}" })
100
- .render("<bibitem type='book'>#{contrib.to_xml}</bibitem>")
87
+ .render("<bibitem type='book'>#{contrib.to_xml}</bibitem>",
88
+ embedded: true)
101
89
  end
102
90
 
103
91
  def dochistory_description(item)
@@ -124,18 +112,6 @@ _bib)
124
112
 
125
113
  def term1(elem); end
126
114
 
127
- # KILL
128
- def termsource1(elem)
129
- elem.parent.nil? and return
130
- while elem&.next_element&.name == "termsource"
131
- elem << "; #{to_xml(elem.next_element.remove.children)}"
132
- end
133
- t = elem.at("./ancestor::xmlns:term") or return
134
- s = l10n(" [#{to_xml(elem.remove.children).strip}]")
135
- defn = t.at(ns(".//definition[last()]")) or return
136
- defn.elements.last << s
137
- end
138
-
139
115
  def termsource1(elem)
140
116
  elem.parent.nil? and return
141
117
  super
@@ -143,8 +119,8 @@ _bib)
143
119
 
144
120
  def termsource_label(elem, sources)
145
121
  elem.at("./ancestor::xmlns:term") or return
146
- elem.replace(l10n("[#{sources}]"))
147
- end
122
+ elem.replace(l10n("[#{sources}]"))
123
+ end
148
124
 
149
125
  def termcleanup(docxml)
150
126
  collapse_term docxml
@@ -162,14 +138,13 @@ _bib)
162
138
  source.remove
163
139
  end
164
140
 
165
- def clausedelim
141
+ def clausedelim
166
142
  ""
167
143
  end
168
144
 
169
- def clause(docxml)
170
- super
171
- docxml.xpath(ns("//executivesummary | //appendix")).each { |x| clause1(x) }
172
- end
145
+ def ul_label_list(_elem)
146
+ %w(&#x2022; &#x2014; &#x6f;)
147
+ end
173
148
 
174
149
  include Init
175
150
  end
@@ -126,7 +126,6 @@ module IsoDoc
126
126
  lbl = clause_number_semx(parentnum, clause, num)
127
127
  @anchors[clause["id"]] =
128
128
  { label: lbl, level: level,
129
- #xref: l10n("#{@labels['subclause']} #{num}"),
130
129
  xref: labelled_autonum(@labels['subclause'], lbl),
131
130
  type: "clause", elem: @labels["subclause"] }
132
131
  i = Counter.new(0)
@@ -1701,16 +1701,22 @@ which can be bookmarks as well as block or section references</a:documentation>
1701
1701
  <a:documentation>Inline reference to a paragraph or paragraphs, appearing as a footnote.
1702
1702
  The target of a footnote is the location it is embedded in within the text</a:documentation>
1703
1703
  <element name="fn">
1704
- <attribute name="reference">
1705
- <a:documentation>The number of the footnote, used to identify it visually</a:documentation>
1706
- </attribute>
1707
- <oneOrMore>
1708
- <ref name="paragraph">
1709
- <a:documentation>The content of the footnote</a:documentation>
1710
- </ref>
1711
- </oneOrMore>
1704
+ <ref name="FnAttributes"/>
1705
+ <ref name="FnBody"/>
1712
1706
  </element>
1713
1707
  </define>
1708
+ <define name="FnBody">
1709
+ <oneOrMore>
1710
+ <ref name="paragraph">
1711
+ <a:documentation>The content of the footnote</a:documentation>
1712
+ </ref>
1713
+ </oneOrMore>
1714
+ </define>
1715
+ <define name="FnAttributes">
1716
+ <attribute name="reference">
1717
+ <a:documentation>The number of the footnote, used to identify it visually</a:documentation>
1718
+ </attribute>
1719
+ </define>
1714
1720
  <define name="callout">
1715
1721
  <a:documentation>Inline reference to a paragraph or paragraphs, appearing as annotation of source code</a:documentation>
1716
1722
  <element name="callout">
@@ -1,13 +1,14 @@
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">
3
- <!--
4
- Add-ons to biblio.rnc for standoc model: defines the extension point BibDataExtensionType
5
- of relaton
6
-
7
- Specialisations as for biblio.rnc. Extension point can be redefined completely for a flavour of standoc
8
- (SDO); but other elements in Bibdata can only be extended (more specialised vocabularies for Bibdata)
9
- -->
10
3
  <include href="biblio.rng">
4
+ <!-- ALERT: we cannot have comments on root element, as they intervene with https://github.com/metanorma/metanorma/issues/437 fix -->
5
+ <!--
6
+ Add-ons to biblio.rnc for standoc model: defines the extension point BibDataExtensionType
7
+ of relaton
8
+
9
+ Specialisations as for biblio.rnc. Extension point can be redefined completely for a flavour of standoc
10
+ (SDO); but other elements in Bibdata can only be extended (more specialised vocabularies for Bibdata)
11
+ -->
11
12
  <define name="BibData">
12
13
  <a:documentation>The bibliographic description of a standardisation document</a:documentation>
13
14
  <ref name="StandardBibliographicItem"/>
@@ -91,6 +92,9 @@ a standards definition organization</a:documentation>
91
92
  <a:documentation>Representation of the identifier for the standardisation document, giving its individual semantic components</a:documentation>
92
93
  </ref>
93
94
  </zeroOrMore>
95
+ <ref name="DocumentImages">
96
+ <a:documentation>Coverpage and other images to be rendered with document</a:documentation>
97
+ </ref>
94
98
  </define>
95
99
  <define name="doctype">
96
100
  <a:documentation>Classification of the standardisation document</a:documentation>
@@ -268,6 +272,32 @@ and not those document components</a:documentation>
268
272
  </optional>
269
273
  </element>
270
274
  </define>
275
+ <define name="DocumentImages">
276
+ <zeroOrMore>
277
+ <element name="coverpage-image">
278
+ <a:documentation>Images to be displayed on the coverpage of the document</a:documentation>
279
+ <ref name="image-no-id"/>
280
+ </element>
281
+ </zeroOrMore>
282
+ <zeroOrMore>
283
+ <element name="innercoverpage-image">
284
+ <a:documentation>Images to be displayed on the inner coverpage of the document</a:documentation>
285
+ <ref name="image-no-id"/>
286
+ </element>
287
+ </zeroOrMore>
288
+ <zeroOrMore>
289
+ <element name="tocside-image">
290
+ <a:documentation>Images to be displayed on the Table of Contents page of the document</a:documentation>
291
+ <ref name="image-no-id"/>
292
+ </element>
293
+ </zeroOrMore>
294
+ <zeroOrMore>
295
+ <element name="backpage-image">
296
+ <a:documentation>Images to be displayed on the backpage of the document</a:documentation>
297
+ <ref name="image-no-id"/>
298
+ </element>
299
+ </zeroOrMore>
300
+ </define>
271
301
  <define name="StandardBibliographicItem">
272
302
  <ref name="BibliographicItem"/>
273
303
  <zeroOrMore>
@@ -1,23 +1,25 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <!--
3
- instantiations of this grammar may replace leaf strings
4
- with more elaborated types; e.g. title (text) replaced with
5
- title-main, title-intro, title-part; type replaced with
6
- enum.
7
-
8
- some renaming at leaf nodes is permissible
9
-
10
- obligations can change both from optional to mandatory,
11
- and from mandatory to optional; optional elements may
12
- be omitted; freely positioned alternatives may be replaced
13
- with strict ordering
14
-
15
- DO NOT introduce a namespace here. We do not want a distinct namespace
16
- for these elements, and a distinct namespace for any grammar inheriting
17
- these elements; we just want one namespace for any child grammars
18
- of this.
19
- -->
20
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
+ <!--
4
+ ALERT: we cannot have comments on root element, as they intervene with https://github.com/metanorma/metanorma/issues/437 fix
5
+
6
+ Instantiations of this grammar may replace leaf strings
7
+ with more elaborated types; e.g. title (text) replaced with
8
+ title-main, title-intro, title-part; type replaced with
9
+ enum.
10
+
11
+ Some renaming at leaf nodes is permissible
12
+
13
+ Obligations can change both from optional to mandatory,
14
+ and from mandatory to optional; optional elements may
15
+ be omitted; freely positioned alternatives may be replaced
16
+ with strict ordering
17
+
18
+ DO NOT introduce a namespace here. We do not want a distinct namespace
19
+ for these elements, and a distinct namespace for any grammar inheriting
20
+ these elements; we just want one namespace for any child grammars
21
+ of this.
22
+ -->
21
23
  <!--
22
24
  https://www.myintervals.com/blog/2009/05/20/iso-8601-date-validation-that-doesnt-suck/
23
25
  iso8601date = xsd:string { pattern = "([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?" }
@@ -1241,6 +1243,11 @@ Refer to `BibliographicItem` for definitions</a:documentation>
1241
1243
  </define>
1242
1244
  <define name="formattedref">
1243
1245
  <element name="formattedref">
1246
+ <optional>
1247
+ <attribute name="format">
1248
+ <a:documentation>format of formatted reference; Metanorma assumes references are formatted as Metanorma XML</a:documentation>
1249
+ </attribute>
1250
+ </optional>
1244
1251
  <oneOrMore>
1245
1252
  <ref name="TextElement"/>
1246
1253
  </oneOrMore>
@@ -1812,6 +1819,11 @@ May be used to differentiate rendering of notes in bibliographies</a:documentati
1812
1819
  <a:documentation>Abstract of bibliographic item</a:documentation>
1813
1820
  <element name="abstract">
1814
1821
  <ref name="LocalizedStringAttributes"/>
1822
+ <optional>
1823
+ <attribute name="format">
1824
+ <a:documentation>What format the formatted abstract is in. In Metanorma, assumed to be Metanorma XML</a:documentation>
1825
+ </attribute>
1826
+ </optional>
1815
1827
  <choice>
1816
1828
  <oneOrMore>
1817
1829
  <ref name="BasicBlockNoId">
@@ -9,19 +9,8 @@ module Metanorma
9
9
 
10
10
  register_for "iho"
11
11
 
12
- def clause_parse(attrs, xml, node)
13
- node.option? "appendix" and
14
- return appendix_parse(attrs, xml, node)
15
- super
16
- end
17
-
18
- def appendix_parse(attrs, xml, node)
19
- attrs[:"inline-header"] = node.option? "inline-header"
20
- set_obligation(attrs, node)
21
- xml.appendix **attr_code(attrs) do |xml_section|
22
- xml_section.title { |name| name << node.title }
23
- xml_section << node.content
24
- end
12
+ def support_appendix?(_node)
13
+ true
25
14
  end
26
15
 
27
16
  SERIESNAME = {
@@ -1,37 +1,10 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <grammar ns='https://www.metanorma.org/ns/standoc' xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <!--
4
- VERSION v1.2.1
5
- Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
6
- we cannot have a new default namespace: we will end up with a grammar with two different
7
- namespaces, one for isostandard and one for csand additions. And we do not want that.
8
- -->
2
+ <grammar ns='https://www.metanorma.org/ns/standoc' xmlns="http://relaxng.org/ns/structure/1.0">
9
3
  <include href="relaton-iho.rng"/>
10
4
  <include href="isodoc.rng">
11
5
  <define name="annex">
12
6
  <element name="annex">
13
- <optional>
14
- <attribute name="id">
15
- <data type="ID"/>
16
- </attribute>
17
- </optional>
18
- <optional>
19
- <attribute name="language"/>
20
- </optional>
21
- <optional>
22
- <attribute name="script"/>
23
- </optional>
24
- <optional>
25
- <attribute name="inline-header">
26
- <data type="boolean"/>
27
- </attribute>
28
- </optional>
29
- <attribute name="obligation">
30
- <choice>
31
- <value>normative</value>
32
- <value>informative</value>
33
- </choice>
34
- </attribute>
7
+ <ref name="Annex-Section-Attributes"/>
35
8
  <optional>
36
9
  <ref name="section-title"/>
37
10
  </optional>
@@ -53,36 +26,5 @@
53
26
  </zeroOrMore>
54
27
  </element>
55
28
  </define>
56
- <define name="standard-document">
57
- <element name="metanorma">
58
- <ref name="Root-Attributes"/>
59
- <ref name="bibdata"/>
60
- <zeroOrMore>
61
- <ref name="termdocsource"/>
62
- </zeroOrMore>
63
- <optional>
64
- <ref name="misccontainer"/>
65
- </optional>
66
- <optional>
67
- <ref name="boilerplate"/>
68
- </optional>
69
- <ref name="preface"/>
70
- <oneOrMore>
71
- <ref name="sections"/>
72
- </oneOrMore>
73
- <zeroOrMore>
74
- <ref name="annex"/>
75
- </zeroOrMore>
76
- <ref name="bibliography"/>
77
- <zeroOrMore>
78
- <ref name="indexsect"/>
79
- </zeroOrMore>
80
- </element>
81
- </define>
82
29
  </include>
83
- <define name="annex-appendix">
84
- <element name="appendix">
85
- <ref name="Clause-Section"/>
86
- </element>
87
- </define>
88
30
  </grammar>