metanorma-plateau 0.2.2 → 1.0.1

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.
@@ -79,6 +79,88 @@ module IsoDoc
79
79
  @iso.ol_depth(node)
80
80
  end
81
81
 
82
+ # how many columns in the table?
83
+ def table_col_count(table)
84
+ cols = 0
85
+ table&.at(ns(".//tr"))&.xpath(ns("./td | ./th"))&.each do |td|
86
+ cols += (td["colspan"] ? td["colspan"].to_i : 1)
87
+ end
88
+ cols
89
+ end
90
+
91
+ # if there is already a full-row cell at the start of tfoot, use that to move content into
92
+ # else create a full-row cell at the start of tfoot
93
+ def initial_tfoot_cell(node)
94
+ colspan = table_col_count(node)
95
+ tfoot_start = node.at(ns("./tfoot/tr/td"))
96
+ if !tfoot_start
97
+ node.at(ns("./tbody")).after("<tfoot><tr><td colspan='#{colspan}'> </td></tr></tfoot>").first
98
+ tfoot_start = node.at(ns("./tfoot/tr/td"))
99
+ end
100
+ if tfoot_start["colspan"] != colspan.to_s
101
+ tfoot_start.parent.previous = "<tr><td colspan='#{colspan}'> </td></tr>"
102
+ tfoot_start = node.at(ns("./tfoot/tr/td"))
103
+ end
104
+ tfoot_start
105
+ end
106
+
107
+ # if there is already a full-row cell at the end of tfoot, use that to move content into
108
+ # else create a full-row cell at the end of tfoot
109
+ def final_tfoot_cell(node)
110
+ colspan = table_col_count(node)
111
+ tfoot_start = node.at(ns("./tfoot/tr[last()]/td"))
112
+ if !tfoot_start
113
+ node.at(ns("./tbody")).after("<tfoot><tr><td colspan='#{colspan}'> </td></tr></tfoot>").first
114
+ tfoot_start = node.at(ns("./tfoot/tr[last()]/td"))
115
+ end
116
+ if tfoot_start["colspan"] != colspan.to_s
117
+ tfoot_start.parent.next = "<tr><td colspan='#{colspan}'> </td></tr>"
118
+ tfoot_start = node.at(ns("./tfoot/tr[last()]/td"))
119
+ end
120
+ tfoot_start
121
+ end
122
+
123
+ def table1(node)
124
+ super
125
+ # move dl, notes, footnotes, source, fmt-footnote-container inside tfoot
126
+ if node.at(ns("./dl"))
127
+ tf = initial_tfoot_cell(node)
128
+ node.xpath(ns("./dl")).reverse_each do |x|
129
+ tf.children.first.previous = x.remove
130
+ end
131
+ end
132
+ if node.at(ns("./note | ./source | ./example | ./fmt-footnote-container"))
133
+ tf = final_tfoot_cell(node)
134
+ node.xpath(ns("./example")).each { |x| tf.children.last.next = x.remove }
135
+ node.xpath(ns("./note")).each { |x| tf.children.last.next = x.remove }
136
+ node.xpath(ns("./fmt-footnote-container")).each { |x| tf.children.last.next = x.remove }
137
+ node.xpath(ns("./source")).each do |x|
138
+ tf.children.last.next = x.remove
139
+ end
140
+ end
141
+ end
142
+
143
+ # Undo JIS encoding of figure and table dl as paragraphs
144
+ def dl(docxml)
145
+ docxml.xpath(ns("//dl")).each { |f| dl1(f) }
146
+ docxml.xpath(ns("//table//dl | //figure//dl")).each do |l|
147
+ l.at(ns("./dl")) || l.at("./ancestor::xmlns:dl") and next
148
+ table_key(l)
149
+ end
150
+ end
151
+
152
+ # Insert localised colon at start of dd in table and figure key,
153
+ # replacing JIS Word <p class='dl' id='#{dt['id']}'>#{term}: #{bkmk}#{defn}</p>
154
+ # with <dt>{term}</dt> <dd>: {defn}<dd>; the space should be stripped and
155
+ # the colon double-width for Japanese text
156
+ def table_key(node)
157
+ node.xpath(ns(".//dd")).each do |dd|
158
+ text_node = dd.xpath(".//text()[normalize-space()]").first or next
159
+ colon = %w(zh ja ko).include?(@lang) ? ":": ": "
160
+ text_node.previous = "<span class='fmt-dt-delim'>#{colon}</span>"
161
+ end
162
+ end
163
+
82
164
  include Init
83
165
  end
84
166
  end
@@ -382,33 +382,7 @@ in a document (e.g. sourcecode annotations)</a:documentation>
382
382
  <a:documentation>Block intended to capture reviewer comments about some text in the document</a:documentation>
383
383
  <element name="review">
384
384
  <ref name="RequiredId"/>
385
- <attribute name="reviewer">
386
- <a:documentation>The party who has offered the comment</a:documentation>
387
- </attribute>
388
- <optional>
389
- <attribute name="type">
390
- <a:documentation>The type of reviewer comment</a:documentation>
391
- </attribute>
392
- </optional>
393
- <optional>
394
- <attribute name="date">
395
- <a:documentation>The date when the comment was made</a:documentation>
396
- <data type="dateTime"/>
397
- </attribute>
398
- </optional>
399
- <optional>
400
- <attribute name="from">
401
- <a:documentation>Identifier for the start of the text or point in the text to which the comment applies.
402
- If not provided, the comment applies in the vicinity of the place it has been inserted into the text</a:documentation>
403
- <data type="IDREF"/>
404
- </attribute>
405
- </optional>
406
- <optional>
407
- <attribute name="to">
408
- <a:documentation>Identifier for the end of the text to which the comment applies</a:documentation>
409
- <data type="IDREF"/>
410
- </attribute>
411
- </optional>
385
+ <ref name="ReviewAttributes"/>
412
386
  <oneOrMore>
413
387
  <ref name="paragraph">
414
388
  <a:documentation>Reviewer comments content</a:documentation>
@@ -416,6 +390,35 @@ If not provided, the comment applies in the vicinity of the place it has been in
416
390
  </oneOrMore>
417
391
  </element>
418
392
  </define>
393
+ <define name="ReviewAttributes">
394
+ <attribute name="reviewer">
395
+ <a:documentation>The party who has offered the comment</a:documentation>
396
+ </attribute>
397
+ <optional>
398
+ <attribute name="type">
399
+ <a:documentation>The type of reviewer comment</a:documentation>
400
+ </attribute>
401
+ </optional>
402
+ <optional>
403
+ <attribute name="date">
404
+ <a:documentation>The date when the comment was made</a:documentation>
405
+ <data type="dateTime"/>
406
+ </attribute>
407
+ </optional>
408
+ <optional>
409
+ <attribute name="from">
410
+ <a:documentation>Identifier for the start of the text or point in the text to which the comment applies.
411
+ If not provided, the comment applies in the vicinity of the place it has been inserted into the text</a:documentation>
412
+ <data type="IDREF"/>
413
+ </attribute>
414
+ </optional>
415
+ <optional>
416
+ <attribute name="to">
417
+ <a:documentation>Identifier for the end of the text to which the comment applies</a:documentation>
418
+ <data type="IDREF"/>
419
+ </attribute>
420
+ </optional>
421
+ </define>
419
422
  <define name="NumberingAttributes">
420
423
  <optional>
421
424
  <attribute name="unnumbered">
@@ -857,6 +860,7 @@ in case the table cannot be rendered accessibly (HTML 5)</a:documentation>
857
860
  <define name="tr">
858
861
  <a:documentation>Sequence of cells to be displayed as a row in a table</a:documentation>
859
862
  <element name="tr">
863
+ <ref name="TrAttributes"/>
860
864
  <oneOrMore>
861
865
  <choice>
862
866
  <ref name="td">
@@ -869,6 +873,9 @@ in case the table cannot be rendered accessibly (HTML 5)</a:documentation>
869
873
  </oneOrMore>
870
874
  </element>
871
875
  </define>
876
+ <define name="TrAttributes">
877
+ <empty/>
878
+ </define>
872
879
  <define name="tr-no-id">
873
880
  <a:documentation>Sequence of cells to be displayed as a row in a table: optional ID attributes recursively (for use in Relaton, metadata)</a:documentation>
874
881
  <element name="tr">
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v2.0.0 -->
20
+ <!-- VERSION v2.0.2 -->
21
21
  <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">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -33,6 +33,15 @@
33
33
  </zeroOrMore>
34
34
  </element>
35
35
  </define>
36
+ <define name="fn" combine="interleave">
37
+ <optional>
38
+ <attribute name="hiddenref">
39
+ <a:documentation>If true, number the footnote as normal, but suppress display of the footnote reference in the document body.
40
+ This is done if the footnote reference is already presented in some other form, e.g. within a figure image.</a:documentation>
41
+ <data type="boolean"/>
42
+ </attribute>
43
+ </optional>
44
+ </define>
36
45
  <define name="index-primary">
37
46
  <element name="primary">
38
47
  <oneOrMore>
@@ -414,6 +423,21 @@ normative or informative references, some split references into sections organiz
414
423
  </oneOrMore>
415
424
  </choice>
416
425
  </define>
426
+ <define name="TdAttributes" combine="interleave">
427
+ <attribute name="style">
428
+ <a:documentation>CSS style: only background-color supported</a:documentation>
429
+ </attribute>
430
+ </define>
431
+ <define name="ThAttributes" combine="interleave">
432
+ <attribute name="style">
433
+ <a:documentation>CSS style: only background-color supported</a:documentation>
434
+ </attribute>
435
+ </define>
436
+ <define name="TrAttributes">
437
+ <attribute name="style">
438
+ <a:documentation>CSS style: only background-color supported</a:documentation>
439
+ </attribute>
440
+ </define>
417
441
  <define name="table-note">
418
442
  <element name="note">
419
443
  <ref name="OptionalId"/>
@@ -1263,6 +1287,11 @@ numbers</a:documentation>
1263
1287
  <a:documentation>Colophon or postface material</a:documentation>
1264
1288
  </ref>
1265
1289
  </optional>
1290
+ <optional>
1291
+ <ref name="review-container">
1292
+ <a:documentation>Annotations to the document</a:documentation>
1293
+ </ref>
1294
+ </optional>
1266
1295
  </element>
1267
1296
  </define>
1268
1297
  <define name="misccontainer">
@@ -1273,6 +1302,13 @@ numbers</a:documentation>
1273
1302
  </oneOrMore>
1274
1303
  </element>
1275
1304
  </define>
1305
+ <define name="review-container">
1306
+ <element name="review-container">
1307
+ <oneOrMore>
1308
+ <ref name="review"/>
1309
+ </oneOrMore>
1310
+ </element>
1311
+ </define>
1276
1312
  <define name="preface">
1277
1313
  <element name="preface">
1278
1314
  <oneOrMore>
@@ -1,5 +1,5 @@
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">
2
+ <grammar ns='https://www.metanorma.org/ns/standoc' xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
3
3
  <!--
4
4
  VERSION v1.2.1
5
5
  default namespace = "https://www.metanorma.com/ns/jis"
@@ -57,6 +57,49 @@
57
57
  <ref name="source"/>
58
58
  </zeroOrMore>
59
59
  </define>
60
+ <define name="TableBody">
61
+ <optional>
62
+ <ref name="colgroup">
63
+ <a:documentation>The widths of the columns in the table</a:documentation>
64
+ </ref>
65
+ </optional>
66
+ <optional>
67
+ <ref name="tname">
68
+ <a:documentation>Caption for the table</a:documentation>
69
+ </ref>
70
+ </optional>
71
+ <optional>
72
+ <ref name="thead">
73
+ <a:documentation>Table rows constituting the table header</a:documentation>
74
+ </ref>
75
+ </optional>
76
+ <ref name="tbody">
77
+ <a:documentation>Table rows constituting the table body</a:documentation>
78
+ </ref>
79
+ <optional>
80
+ <ref name="tfoot">
81
+ <a:documentation>Table rows constituting the table footer</a:documentation>
82
+ </ref>
83
+ </optional>
84
+ <optional>
85
+ <ref name="dl">
86
+ <a:documentation>Definitions list defining any symbols used in the table</a:documentation>
87
+ </ref>
88
+ </optional>
89
+ <zeroOrMore>
90
+ <ref name="table-note">
91
+ <a:documentation>Notes specific to this block</a:documentation>
92
+ </ref>
93
+ </zeroOrMore>
94
+ <zeroOrMore>
95
+ <ref name="example">
96
+ <a:documentation>Examples specific to this block</a:documentation>
97
+ </ref>
98
+ </zeroOrMore>
99
+ <ref name="TermSource">
100
+ <a:documentation>A source for the table</a:documentation>
101
+ </ref>
102
+ </define>
60
103
  <!--
61
104
  We display the Normative References between scope and terms; but to keep the
62
105
  grammar simple, we keep the references together
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Plateau
3
- VERSION = "0.2.2".freeze
3
+ VERSION = "1.0.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-plateau
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-04 00:00:00.000000000 Z
11
+ date: 2025-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-jis