metanorma-jis 0.5.1 → 0.5.3

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.
@@ -42,12 +42,12 @@ module IsoDoc
42
42
  end
43
43
 
44
44
  def admits(elem)
45
- #elem.children.first.previous = @i18n.l10n("#{@i18n.admitted}: ")
46
45
  elem.xpath(ns(".//semx[@element = 'admitted']")).each do |t|
47
- t.previous = @i18n.l10n("#{@i18n.admitted}: ")
48
- end
46
+ t.previous = @i18n.l10n("#{@i18n.admitted}: ")
47
+ end
49
48
  end
50
49
 
50
+ # TODO: move the table/figure key processing to Word, not Presentation XML
51
51
  def dl(docxml)
52
52
  super
53
53
  docxml.xpath(ns("//table//dl | //figure//dl")).each do |l|
@@ -130,30 +130,18 @@ module IsoDoc
130
130
  "<tr><td border='0' colspan='#{cols}'>#{elem}</td></tr>"
131
131
  end
132
132
 
133
- # KILL
133
+ # TODO preserve original Semantic XML source
134
134
  def tablesource(elem)
135
+ ret = [semx_fmt_dup(elem)]
135
136
  while elem&.next_element&.name == "source"
136
- elem << "; #{to_xml(elem.next_element.remove.children)}"
137
+ ret << semx_fmt_dup(elem.next_element.remove)
137
138
  end
138
- elem.children = l10n("#{@i18n.source}: #{to_xml(elem.children).strip}")
139
- end
140
-
141
- # TODO preserve original Semantic XML source
142
- def tablesource(elem)
143
- ret = [semx_fmt_dup(elem)]
144
- while elem&.next_element&.name == "source"
145
- ret << semx_fmt_dup(elem.next_element.remove)
139
+ s = ret.map { |x| to_xml(x) }.map(&:strip).join("; ")
140
+ tablesource_label(elem, s)
146
141
  end
147
- s = ret.map { |x| to_xml(x) }.map(&:strip).join("; ")
148
- tablesource_label(elem, s)
149
- end
150
-
151
- def tablesource_label(elem, sources)
152
- elem.children = l10n("#{@i18n.source}: #{sources}")
153
- end
154
142
 
155
- def table_fn1(_table, fnote, _idx)
156
- fnote["reference"] += ")"
143
+ def tablesource_label(elem, sources)
144
+ elem.children = l10n("#{@i18n.source}: #{sources}")
157
145
  end
158
146
 
159
147
  def bibdata_i18n(bibdata)
@@ -204,10 +192,15 @@ module IsoDoc
204
192
  end
205
193
 
206
194
  def figure_fn(elem)
207
- (elem.xpath(ns(".//fn")) - elem.xpath(ns("./name//fn")))
208
- .each do |f|
209
- table_fn1(elem, f, nil)
210
- end
195
+ fnotes = elem.xpath(ns(".//fn")) - elem.xpath(ns("./name//fn"))
196
+ ret = footnote_collect(fnotes)
197
+ f = footnote_container(fnotes, ret) and elem << f
198
+ end
199
+
200
+ def table_fn(elem)
201
+ fnotes = elem.xpath(ns(".//fn"))
202
+ ret = footnote_collect(fnotes)
203
+ f = footnote_container(fnotes, ret) and elem << f
211
204
  end
212
205
 
213
206
  def omit_docid_prefix(prefix)
@@ -215,6 +208,36 @@ module IsoDoc
215
208
  super || %w(JIS).include?(prefix)
216
209
  end
217
210
 
211
+ def fn_ref_label(fnote)
212
+ if fnote.ancestors("table, figure").empty? ||
213
+ !fnote.ancestors("figure").empty? &&
214
+ !fnote.ancestors("name, fmt-name").empty?
215
+ "<sup>#{fn_label(fnote)}</sup>"
216
+ else
217
+ "<sup>#{fn_label(fnote)}" \
218
+ "<span class='fmt-label-delim'>)</span></sup>"
219
+ end
220
+ end
221
+
222
+ def fn_body_label(fnote)
223
+ if fnote.ancestors("table, figure").empty? ||
224
+ !fnote.ancestors("figure").empty? &&
225
+ !fnote.ancestors("name, fmt-name").empty?
226
+ "<sup>#{fn_label(fnote)}</sup>"
227
+ else
228
+ spc = %w(zh ja ko).include?(@lang) ? "" : " "
229
+ "#{@i18n.table_footnote}#{spc}<sup>#{fn_label(fnote)}" \
230
+ "<span class='fmt-label-delim'>)</span></sup>"
231
+ end
232
+ end
233
+
234
+ def non_document_footnotes(docxml)
235
+ table_fns = docxml.xpath(ns("//table//fn"))
236
+ fig_fns = docxml.xpath(ns("//figure//fn")) -
237
+ docxml.xpath(ns("//figure/name//fn"))
238
+ table_fns + fig_fns
239
+ end
240
+
218
241
  include Init
219
242
  end
220
243
  end
@@ -1,7 +1,8 @@
1
1
  module IsoDoc
2
2
  module Jis
3
3
  class WordConvert < IsoDoc::Iso::WordConvert
4
- def make_table_footnote_target(out, fnid, fnref)
4
+ # KILL
5
+ def make_table_footnote_targetx(out, fnid, fnref)
5
6
  attrs = { id: fnid, class: "TableFootnoteRef" }
6
7
  out.span do |s|
7
8
  s << @i18n.table_footnote
@@ -109,11 +109,10 @@ module IsoDoc
109
109
  end
110
110
  end
111
111
 
112
- def footnote_parse(node, out)
112
+ # KILL
113
+ def footnote_parsex(node, out)
113
114
  return table_footnote_parse(node, out) if @in_table || @in_figure # &&
114
115
 
115
- # !node.ancestors.map(&:name).include?("name")
116
-
117
116
  fn = node["reference"] || UUIDTools::UUID.random_create.to_s
118
117
  return seen_footnote_parse(node, out, fn) if @seen_footnote.include?(fn)
119
118
 
@@ -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">
@@ -599,17 +602,9 @@ It is included for convenience, in case processing the citation to extract the a
599
602
  <a:documentation>The caption of the block</a:documentation>
600
603
  </ref>
601
604
  </optional>
602
- <oneOrMore>
603
- <choice>
604
- <text>
605
- <a:documentation>The computer code or other such text presented in the block, as a single unformatted string.
606
- (The string should be treated as pre-formatted text, with whitespace treated as significant)</a:documentation>
607
- </text>
608
- <ref name="callout">
609
- <a:documentation>Zero or more cross-references; these are intended to be embedded within the content string, and link to annotations</a:documentation>
610
- </ref>
611
- </choice>
612
- </oneOrMore>
605
+ <ref name="sourcecodebody">
606
+ <a:documentation>The sourcecode content</a:documentation>
607
+ </ref>
613
608
  <zeroOrMore>
614
609
  <ref name="annotation">
615
610
  <a:documentation>Annotations to the source code; each annotation consists of zero or more paragraphs,
@@ -628,17 +623,9 @@ and is intended to be referenced by a callout within the source code</a:document
628
623
  <a:documentation>The caption of the block</a:documentation>
629
624
  </ref>
630
625
  </optional>
631
- <oneOrMore>
632
- <choice>
633
- <text>
634
- <a:documentation>The computer code or other such text presented in the block, as a single unformatted string.
635
- (The string should be treated as pre-formatted text, with whitespace treated as significant)</a:documentation>
636
- </text>
637
- <ref name="callout">
638
- <a:documentation>Zero or more cross-references; these are intended to be embedded within the content string, and link to annotations</a:documentation>
639
- </ref>
640
- </choice>
641
- </oneOrMore>
626
+ <ref name="sourcecodebody">
627
+ <a:documentation>The sourcecode content</a:documentation>
628
+ </ref>
642
629
  <zeroOrMore>
643
630
  <ref name="annotation">
644
631
  <a:documentation>Annotations to the source code; each annotation consists of zero or more paragraphs,
@@ -651,6 +638,20 @@ and is intended to be referenced by a callout within the source code</a:document
651
638
  </ref>
652
639
  </zeroOrMore>
653
640
  </define>
641
+ <define name="sourcecodebody">
642
+ <a:documentation>The computer code or other such text presented in the block, as a single unformatted string.
643
+ (The string should be treated as pre-formatted text, with whitespace treated as significant)</a:documentation>
644
+ <element name="body">
645
+ <oneOrMore>
646
+ <choice>
647
+ <text/>
648
+ <ref name="callout">
649
+ <a:documentation>Zero or more cross-references; these are intended to be embedded within the content string, and link to annotations</a:documentation>
650
+ </ref>
651
+ </choice>
652
+ </oneOrMore>
653
+ </element>
654
+ </define>
654
655
  <define name="pre">
655
656
  <a:documentation>Pre-formatted block. Wrapper for text to be rendered with fixed-width typeface, and preserving spaces including line breaks.
656
657
  They are intended for a restricted number of functions, most typically ASCII Art (which is still in prominent use in some
@@ -859,6 +860,7 @@ in case the table cannot be rendered accessibly (HTML 5)</a:documentation>
859
860
  <define name="tr">
860
861
  <a:documentation>Sequence of cells to be displayed as a row in a table</a:documentation>
861
862
  <element name="tr">
863
+ <ref name="TrAttributes"/>
862
864
  <oneOrMore>
863
865
  <choice>
864
866
  <ref name="td">
@@ -871,6 +873,9 @@ in case the table cannot be rendered accessibly (HTML 5)</a:documentation>
871
873
  </oneOrMore>
872
874
  </element>
873
875
  </define>
876
+ <define name="TrAttributes">
877
+ <empty/>
878
+ </define>
874
879
  <define name="tr-no-id">
875
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>
876
881
  <element name="tr">
@@ -1672,18 +1677,25 @@ which can be bookmarks as well as block or section references</a:documentation>
1672
1677
  </optional>
1673
1678
  </define>
1674
1679
  <define name="XrefBody">
1675
- <oneOrMore>
1676
- <ref name="PureTextElement">
1677
- <a:documentation>The textual content of the element. The `text` is what we wish to show the link as (e.g., the "content" of `&lt;xx&gt;my link text&lt;/xx&gt;`)</a:documentation>
1678
- </ref>
1679
- </oneOrMore>
1680
+ <a:documentation>The textual content of the element. The `text` is what we wish to show the link as (e.g., the "content" of `&lt;xx&gt;my link text&lt;/xx&gt;`)</a:documentation>
1681
+ <optional>
1682
+ <element name="display-text">
1683
+ <oneOrMore>
1684
+ <ref name="PureTextElement"/>
1685
+ </oneOrMore>
1686
+ </element>
1687
+ </optional>
1680
1688
  </define>
1681
1689
  <define name="ErefBody">
1682
- <oneOrMore>
1683
- <ref name="PureTextElement">
1684
- <a:documentation>The textual content of the element. The `text` is what we wish to show the link as (e.g., the "content" of `&lt;xx&gt;my link text&lt;/xx&gt;`)</a:documentation>
1685
- </ref>
1686
- </oneOrMore>
1690
+ <optional>
1691
+ <element name="display-text">
1692
+ <oneOrMore>
1693
+ <ref name="PureTextElement">
1694
+ <a:documentation>The textual content of the element. The `text` is what we wish to show the link as (e.g., the "content" of `&lt;xx&gt;my link text&lt;/xx&gt;`)</a:documentation>
1695
+ </ref>
1696
+ </oneOrMore>
1697
+ </element>
1698
+ </optional>
1687
1699
  </define>
1688
1700
  <define name="fn">
1689
1701
  <a:documentation>Inline reference to a paragraph or paragraphs, appearing as a footnote.
@@ -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>
@@ -245,23 +254,9 @@
245
254
  <a:documentation>The caption of the block</a:documentation>
246
255
  </ref>
247
256
  </optional>
248
- <oneOrMore>
249
- <choice>
250
- <text>
251
- <a:documentation>The computer code or other such text presented in the block, as a single unformatted string.
252
- (The string should be treated as pre-formatted text, with whitespace treated as significant)</a:documentation>
253
- </text>
254
- <ref name="callout">
255
- <a:documentation>Zero or more cross-references; these are intended to be embedded within the content string, and link to annotations</a:documentation>
256
- </ref>
257
- <ref name="xref">
258
- <a:documentation>Hyperlink of code segment to another part of the document</a:documentation>
259
- </ref>
260
- <ref name="eref">
261
- <a:documentation>Hyperlink of code segment to external bibliographic resource</a:documentation>
262
- </ref>
263
- </choice>
264
- </oneOrMore>
257
+ <ref name="sourcecodebody">
258
+ <a:documentation>The sourcecode content</a:documentation>
259
+ </ref>
265
260
  <zeroOrMore>
266
261
  <ref name="annotation">
267
262
  <a:documentation>Annotations to the source code; each annotation consists of zero or more paragraphs,
@@ -277,6 +272,26 @@ and is intended to be referenced by a callout within the source code</a:document
277
272
  <a:documentation>A source for the block</a:documentation>
278
273
  </ref>
279
274
  </define>
275
+ <define name="sourcecodebody">
276
+ <a:documentation>The computer code or other such text presented in the block, as a single unformatted string.
277
+ (The string should be treated as pre-formatted text, with whitespace treated as significant)</a:documentation>
278
+ <element name="body">
279
+ <oneOrMore>
280
+ <choice>
281
+ <text/>
282
+ <ref name="callout">
283
+ <a:documentation>Zero or more cross-references; these are intended to be embedded within the content string, and link to annotations</a:documentation>
284
+ </ref>
285
+ <ref name="xref">
286
+ <a:documentation>Hyperlink of code segment to another part of the document</a:documentation>
287
+ </ref>
288
+ <ref name="eref">
289
+ <a:documentation>Hyperlink of code segment to external bibliographic resource</a:documentation>
290
+ </ref>
291
+ </choice>
292
+ </oneOrMore>
293
+ </element>
294
+ </define>
280
295
  <define name="sections">
281
296
  <element name="sections">
282
297
  <oneOrMore>
@@ -408,6 +423,21 @@ normative or informative references, some split references into sections organiz
408
423
  </oneOrMore>
409
424
  </choice>
410
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>
411
441
  <define name="table-note">
412
442
  <element name="note">
413
443
  <ref name="OptionalId"/>
@@ -1257,6 +1287,11 @@ numbers</a:documentation>
1257
1287
  <a:documentation>Colophon or postface material</a:documentation>
1258
1288
  </ref>
1259
1289
  </optional>
1290
+ <optional>
1291
+ <ref name="review-container">
1292
+ <a:documentation>Annotations to the document</a:documentation>
1293
+ </ref>
1294
+ </optional>
1260
1295
  </element>
1261
1296
  </define>
1262
1297
  <define name="misccontainer">
@@ -1267,6 +1302,13 @@ numbers</a:documentation>
1267
1302
  </oneOrMore>
1268
1303
  </element>
1269
1304
  </define>
1305
+ <define name="review-container">
1306
+ <element name="review-container">
1307
+ <oneOrMore>
1308
+ <ref name="review"/>
1309
+ </oneOrMore>
1310
+ </element>
1311
+ </define>
1270
1312
  <define name="preface">
1271
1313
  <element name="preface">
1272
1314
  <oneOrMore>
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Jis
3
- VERSION = "0.5.1".freeze
3
+ VERSION = "0.5.3".freeze
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-jis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
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: japanese_calendar