metanorma-jis 0.5.10 → 0.6.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.
- checksums.yaml +4 -4
- data/lib/isodoc/jis/base_convert.rb +1 -17
- data/lib/isodoc/jis/jis.international-standard.xsl +807 -696
- data/lib/isodoc/jis/presentation_list.rb +4 -1
- data/lib/isodoc/jis/presentation_table.rb +97 -0
- data/lib/isodoc/jis/presentation_xml_convert.rb +1 -34
- data/lib/isodoc/jis/table.rb +6 -5
- data/lib/metanorma/jis/converter.rb +6 -0
- data/lib/metanorma/jis/isodoc.rng +51 -6
- data/lib/metanorma/jis/version.rb +1 -1
- data/metanorma-jis.gemspec +1 -1
- metadata +5 -4
@@ -48,8 +48,11 @@ module IsoDoc
|
|
48
48
|
|
49
49
|
def dl_to_para_name(node)
|
50
50
|
e = node.at(ns("./fmt-name")) or return ""
|
51
|
-
node.parent.parent["type"] == "participants"
|
51
|
+
if node.parent.parent.parent.parent.parent["type"] == "participants"
|
52
|
+
""
|
53
|
+
else
|
52
54
|
"<p class='ListTitle'>#{e.children.to_xml}</p>"
|
55
|
+
end
|
53
56
|
end
|
54
57
|
|
55
58
|
def dl_to_para_terms(node)
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module Jis
|
3
|
+
class PresentationXMLConvert < IsoDoc::Iso::PresentationXMLConvert
|
4
|
+
def table1(node)
|
5
|
+
super
|
6
|
+
cols = table_cols_count(node)
|
7
|
+
ins = node.at(ns("./fmt-xref-label")) ||
|
8
|
+
node.at(ns("./fmt-name"))
|
9
|
+
thead = table_thead_pt(node, ins)
|
10
|
+
table_unit_notes(node, thead, cols)
|
11
|
+
table_dl_to_tfoot(node)
|
12
|
+
table_content_to_tfoot(node)
|
13
|
+
end
|
14
|
+
|
15
|
+
def table_dl_to_tfoot(node)
|
16
|
+
node.at(ns("./dl")) or return
|
17
|
+
tf = initial_tfoot_cell(node)
|
18
|
+
node.xpath(ns("./dl")).reverse_each do |x|
|
19
|
+
tf.children.first.previous = x.remove
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def table_content_to_tfoot(node)
|
24
|
+
node.at(ns("./note | ./fmt-source | ./example | " \
|
25
|
+
"./fmt-footnote-container")) or return
|
26
|
+
tf = final_tfoot_cell(node)
|
27
|
+
%w(example note fmt-footnote-container
|
28
|
+
fmt-source).each do |n|
|
29
|
+
node.xpath(ns("./#{n}")).each do |x|
|
30
|
+
tf.children.last.next = x.remove
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# how many columns in the table?
|
36
|
+
def table_col_count(table)
|
37
|
+
cols = 0
|
38
|
+
table&.at(ns(".//tr"))&.xpath(ns("./td | ./th"))&.each do |td|
|
39
|
+
cols += (td["colspan"] ? td["colspan"].to_i : 1)
|
40
|
+
end
|
41
|
+
cols
|
42
|
+
end
|
43
|
+
|
44
|
+
# if there is already a full-row cell at the start of tfoot,
|
45
|
+
# use that to move content into
|
46
|
+
# else create a full-row cell at the start of tfoot
|
47
|
+
def initial_tfoot_cell(node)
|
48
|
+
colspan = table_col_count(node)
|
49
|
+
empty_row = full_row(colspan, " ", border: true)
|
50
|
+
node.at(ns("./tfoot/tr/td")) or
|
51
|
+
node.at(ns("./tbody")).after("<tfoot>#{empty_row}</tfoot>").first
|
52
|
+
tfoot_start = node.at(ns("./tfoot/tr/td"))
|
53
|
+
tfoot_start["colspan"] != colspan.to_s and
|
54
|
+
tfoot_start.parent.previous = empty_row
|
55
|
+
node.at(ns("./tfoot/tr/td"))
|
56
|
+
end
|
57
|
+
|
58
|
+
def final_tfoot_cell(node)
|
59
|
+
colspan = table_col_count(node)
|
60
|
+
empty_row = full_row(colspan, " ", border: true)
|
61
|
+
node.at(ns("./tfoot/tr[last()]/td")) or
|
62
|
+
node.at(ns("./tbody")).after("<tfoot>#{empty_row}</tfoot>").first
|
63
|
+
tfoot_start = node.at(ns("./tfoot/tr[last()]/td"))
|
64
|
+
tfoot_start["colspan"] != colspan.to_s and
|
65
|
+
tfoot_start.parent.next = empty_row
|
66
|
+
node.at(ns("./tfoot/tr[last()]/td"))
|
67
|
+
end
|
68
|
+
|
69
|
+
def table_thead_pt(node, name)
|
70
|
+
node.at(ns("./thead")) ||
|
71
|
+
name&.after("<thead> </thead>")&.next ||
|
72
|
+
node.elements.first.before("<thead> </thead>").previous
|
73
|
+
end
|
74
|
+
|
75
|
+
def table_cols_count(node)
|
76
|
+
cols = 0
|
77
|
+
node.at(ns(".//tr")).xpath(ns("./td | ./th")).each do |x|
|
78
|
+
cols += x["colspan"]&.to_i || 1
|
79
|
+
end
|
80
|
+
cols
|
81
|
+
end
|
82
|
+
|
83
|
+
def table_unit_notes(node, thead, cols)
|
84
|
+
unit_notes = node.xpath(ns(".//note[@type = 'units']"))
|
85
|
+
unit_notes.empty? and return
|
86
|
+
thead.children.first.previous = full_row(cols, unit_notes.remove.to_xml)
|
87
|
+
end
|
88
|
+
|
89
|
+
def full_row(cols, elem, border: false)
|
90
|
+
b = border ? "" : " border='0'"
|
91
|
+
<<~XML
|
92
|
+
<tr #{add_id_text}><td #{add_id_text}#{b} colspan='#{cols}'>#{elem}</td></tr>
|
93
|
+
XML
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -2,6 +2,7 @@ require_relative "init"
|
|
2
2
|
require "isodoc"
|
3
3
|
require_relative "presentation_section"
|
4
4
|
require_relative "presentation_list"
|
5
|
+
require_relative "presentation_table"
|
5
6
|
require_relative "../../relaton/render-jis/general"
|
6
7
|
|
7
8
|
module IsoDoc
|
@@ -46,40 +47,6 @@ module IsoDoc
|
|
46
47
|
node.children.to_xml.gsub(%r{</?p( [^>]*)?>}, "")
|
47
48
|
end
|
48
49
|
|
49
|
-
def table1(node)
|
50
|
-
super
|
51
|
-
cols = table_cols_count(node)
|
52
|
-
ins = node.at(ns("./fmt-xref-label")) ||
|
53
|
-
node.at(ns("./fmt-name"))
|
54
|
-
thead = table_thead_pt(node, ins)
|
55
|
-
table_unit_note(node, thead, cols)
|
56
|
-
end
|
57
|
-
|
58
|
-
def table_thead_pt(node, name)
|
59
|
-
node.at(ns("./thead")) ||
|
60
|
-
name&.after("<thead> </thead>")&.next ||
|
61
|
-
node.elements.first.before("<thead> </thead>").previous
|
62
|
-
end
|
63
|
-
|
64
|
-
def table_cols_count(node)
|
65
|
-
cols = 0
|
66
|
-
node.at(ns(".//tr")).xpath(ns("./td | ./th")).each do |x|
|
67
|
-
cols += x["colspan"]&.to_i || 1
|
68
|
-
end
|
69
|
-
cols
|
70
|
-
end
|
71
|
-
|
72
|
-
def table_unit_note(node, thead, cols)
|
73
|
-
unit_note = node.at(ns(".//note[@type = 'units']")) or return
|
74
|
-
thead.children.first.previous = full_row(cols, unit_note.remove.to_xml)
|
75
|
-
end
|
76
|
-
|
77
|
-
def full_row(cols, elem)
|
78
|
-
<<~XML
|
79
|
-
<tr #{add_id_text}><td #{add_id_text} border='0' colspan='#{cols}'>#{elem}</td></tr>
|
80
|
-
XML
|
81
|
-
end
|
82
|
-
|
83
50
|
def source1_label(elem, sources, ancestor)
|
84
51
|
case ancestor
|
85
52
|
when :table
|
data/lib/isodoc/jis/table.rb
CHANGED
@@ -4,14 +4,15 @@ module IsoDoc
|
|
4
4
|
def table_title_parse(node, out); end
|
5
5
|
|
6
6
|
def table_attrs(node)
|
7
|
-
|
8
|
-
summary: node["summary"], width: node["width"],
|
9
|
-
class: (node.text.length > 4000 ? "MsoTableGridBig" : "MsoTableGrid"),
|
10
|
-
style: "border-collapse:collapse;" \
|
7
|
+
style = node["style"] || "border-collapse:collapse;" \
|
11
8
|
"mso-table-anchor-horizontal:column;mso-table-overlap:never;" \
|
12
9
|
"border:none;mso-padding-alt: " \
|
13
10
|
"0cm 5.4pt 0cm 5.4pt;mso-border-insideh:none;" \
|
14
|
-
"mso-border-insidev:none
|
11
|
+
"mso-border-insidev:none;"
|
12
|
+
{ id: node["id"], title: node["alt"],
|
13
|
+
summary: node["summary"], width: node["width"],
|
14
|
+
class: (node.text.length > 4000 ? "MsoTableGridBig" : "MsoTableGrid"),
|
15
|
+
style: style,
|
15
16
|
border: 0, cellspacing: 0, cellpadding: 0 }
|
16
17
|
end
|
17
18
|
|
@@ -23,6 +23,12 @@ module Metanorma
|
|
23
23
|
@default_doctype = "japanese-industrial-standard"
|
24
24
|
end
|
25
25
|
|
26
|
+
def ol_attrs(node)
|
27
|
+
ret = super
|
28
|
+
ret.delete(:type)
|
29
|
+
ret
|
30
|
+
end
|
31
|
+
|
26
32
|
def section_attributes(node)
|
27
33
|
ret = super
|
28
34
|
if node.attr("style") == "appendix" && node.level == 1 &&
|
@@ -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.
|
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="
|
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="
|
1465
|
-
<element name="
|
1509
|
+
<define name="annotation-container">
|
1510
|
+
<element name="annotation-container">
|
1466
1511
|
<oneOrMore>
|
1467
1512
|
<ref name="review"/>
|
1468
1513
|
</oneOrMore>
|
data/metanorma-jis.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
|
32
32
|
|
33
33
|
spec.add_dependency "japanese_calendar", "~> 0"
|
34
|
-
spec.add_dependency "metanorma-iso", "~> 3.0
|
34
|
+
spec.add_dependency "metanorma-iso", "~> 3.1.0"
|
35
35
|
spec.add_dependency "pubid"
|
36
36
|
|
37
37
|
spec.add_development_dependency "debug"
|
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.
|
4
|
+
version: 0.6.0
|
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-
|
11
|
+
date: 2025-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: japanese_calendar
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.0
|
33
|
+
version: 3.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.0
|
40
|
+
version: 3.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pubid
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -292,6 +292,7 @@ files:
|
|
292
292
|
- lib/isodoc/jis/pdf_convert.rb
|
293
293
|
- lib/isodoc/jis/presentation_list.rb
|
294
294
|
- lib/isodoc/jis/presentation_section.rb
|
295
|
+
- lib/isodoc/jis/presentation_table.rb
|
295
296
|
- lib/isodoc/jis/presentation_xml_convert.rb
|
296
297
|
- lib/isodoc/jis/table.rb
|
297
298
|
- lib/isodoc/jis/word_cleanup.rb
|