metanorma-generic 1.6.0 → 1.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e817f19db29a3edb02be3d16087975c2fbacc77e210288cce9389c8f988687c
4
- data.tar.gz: 2f3aaa80cc738cb89e1465a769b98716de796fb33235d9e76867d91d3581310e
3
+ metadata.gz: 2e39cd0bf72f4464ca05b5e8b31964ca9c4394fece3c6bb40cb503fd587ee158
4
+ data.tar.gz: 74b2cb557b05f508b7a6260ba6b0343a8841f660b6adca537ded5584e015a8f1
5
5
  SHA512:
6
- metadata.gz: 9c3aa01d6ed22902d8d5f45166a9fa7c8bf1fe341ab4237cae173c2ee332e25c8bf4117ca0ee5f287ec1d84c2317d4e68196fa1794331b36ee1cd64a5459c182
7
- data.tar.gz: d545baf6c6822b5ff93baf8db5b23f22817214f556029ff1e531eca1762429440fb95f4ce3f849e2f2ba13a7cfe7aeb5dbabbdfac040fe5f409aa9a7a91b8219
6
+ metadata.gz: 378e9b3795ffad13435bd584ec35c0d1bdfb25f9be58f9436dc19257066f4d8a0698f8e30456bf8a5be87bcfb232ad0f7978194ce794c9d01998888bf1973116
7
+ data.tar.gz: 3a054e05fcc4dc3875935ffc39858ad77568861a8517d450171376bcb02155a697af73493edc42257e15a632cdc629be8723857417d35f0c72d54eb809bb1786
@@ -402,6 +402,16 @@
402
402
  </choice>
403
403
  </attribute>
404
404
  </optional>
405
+ <optional>
406
+ <attribute name="valign">
407
+ <choice>
408
+ <value>top</value>
409
+ <value>middle</value>
410
+ <value>bottom</value>
411
+ <value>baseline</value>
412
+ </choice>
413
+ </attribute>
414
+ </optional>
405
415
  <choice>
406
416
  <zeroOrMore>
407
417
  <ref name="TextElement"/>
@@ -429,6 +439,16 @@
429
439
  </choice>
430
440
  </attribute>
431
441
  </optional>
442
+ <optional>
443
+ <attribute name="valign">
444
+ <choice>
445
+ <value>top</value>
446
+ <value>middle</value>
447
+ <value>bottom</value>
448
+ <value>baseline</value>
449
+ </choice>
450
+ </attribute>
451
+ </optional>
432
452
  <choice>
433
453
  <zeroOrMore>
434
454
  <ref name="TextElement"/>
@@ -998,6 +1018,9 @@
998
1018
  <value>alphabet_upper</value>
999
1019
  </choice>
1000
1020
  </attribute>
1021
+ <optional>
1022
+ <attribute name="start"/>
1023
+ </optional>
1001
1024
  <oneOrMore>
1002
1025
  <ref name="li"/>
1003
1026
  </oneOrMore>
@@ -1,13 +1,10 @@
1
1
  require "asciidoctor"
2
2
  require "asciidoctor/standoc/converter"
3
3
  require "fileutils"
4
+ require_relative "front"
4
5
 
5
6
  module Asciidoctor
6
7
  module Generic
7
-
8
- # A {Converter} implementation that generates RSD output, and a document
9
- # schema encapsulation of the document for validation
10
- #
11
8
  class Converter < Standoc::Converter
12
9
  XML_ROOT_TAG = "generic-standard".freeze
13
10
  XML_NAMESPACE = "https://www.metanorma.org/ns/generic".freeze
@@ -28,48 +25,6 @@ module Asciidoctor
28
25
  self.class::_file || __FILE__), "..", "..", "..", loc))
29
26
  end
30
27
 
31
- def metadata_author(node, xml)
32
- xml.contributor do |c|
33
- c.role **{ type: "author" }
34
- c.organization do |a|
35
- a.name configuration.organization_name_long
36
- end
37
- end
38
- personal_author(node, xml)
39
- end
40
-
41
- def metadata_publisher(node, xml)
42
- xml.contributor do |c|
43
- c.role **{ type: "publisher" }
44
- c.organization do |a|
45
- a.name configuration.organization_name_long
46
- end
47
- end
48
- end
49
-
50
- def metadata_committee(node, xml)
51
- return unless node.attr("committee")
52
- xml.editorialgroup do |a|
53
- a.committee node.attr("committee"),
54
- **attr_code(type: node.attr("committee-type"))
55
- i = 2
56
- while node.attr("committee_#{i}") do
57
- a.committee node.attr("committee_#{i}"),
58
- **attr_code(type: node.attr("committee-type_#{i}"))
59
- i += 1
60
- end
61
- end
62
- end
63
-
64
- def metadata_status(node, xml)
65
- xml.status do |s|
66
- s.stage ( node.attr("status") || node.attr("docstage") ||
67
- configuration.default_stage || "published" )
68
- x = node.attr("substage") and s.substage x
69
- x = node.attr("iteration") and s.iteration x
70
- end
71
- end
72
-
73
28
  def docidentifier_cleanup(xmldoc)
74
29
  template = configuration.docid_template ||
75
30
  "{{ organization_name_short }} {{ docnumeric }}"
@@ -78,42 +33,15 @@ module Asciidoctor
78
33
  id.empty? and docid.remove or docid.children = id
79
34
  end
80
35
 
81
- def metadata_id(node, xml)
82
- xml.docidentifier **{ type:
83
- configuration.organization_name_short } do |i|
84
- i << "DUMMY"
85
- end
86
- xml.docnumber { |i| i << node.attr("docnumber") }
87
- end
88
-
89
- def metadata_copyright(node, xml)
90
- from = node.attr("copyright-year") || Date.today.year
91
- xml.copyright do |c|
92
- c.from from
93
- c.owner do |owner|
94
- owner.organization do |o|
95
- o.name configuration.organization_name_long
96
- end
97
- end
98
- end
99
- end
100
-
101
- def metadata_ext(node, ext)
102
- super
103
- Array(configuration.metadata_extensions).each do |e|
104
- a = node.attr(e) and ext.send e, a
105
- end
106
- end
107
-
108
36
  def doctype(node)
109
- d = node.attr("doctype")
37
+ d = super
110
38
  configuration.doctypes or return d == "article" ? "standard" : d
111
- default = configuration.default_doctype || Array(configuration.doctypes).dig(0) ||
112
- "standard"
39
+ type = configuration.default_doctype ||
40
+ Array(configuration.doctypes).dig(0) || "standard"
113
41
  unless Array(configuration.doctypes).include? d
114
42
  @log.add("Document Attributes", nil,
115
- "#{d} is not a legal document type: reverting to '#{default}'")
116
- d = default
43
+ "#{d} is not a legal document type: reverting to '#{type}'")
44
+ d = type
117
45
  end
118
46
  d
119
47
  end
@@ -124,13 +52,13 @@ module Asciidoctor
124
52
  end
125
53
 
126
54
  def sectiontype_streamline(ret)
127
- if configuration.termsdefs_titles.map(&:downcase).include? (ret)
55
+ if configuration&.termsdefs_titles&.map(&:downcase)&.include? (ret)
128
56
  "terms and definitions"
129
- elsif configuration.symbols_titles.map(&:downcase).include? (ret)
57
+ elsif configuration&.symbols_titles&.map(&:downcase)&.include? (ret)
130
58
  "symbols and abbreviated terms"
131
- elsif configuration.normref_titles.map(&:downcase).include? (ret)
59
+ elsif configuration&.normref_titles&.map(&:downcase)&.include? (ret)
132
60
  "normative references"
133
- elsif configuration.bibliography_titles.map(&:downcase).include? (ret)
61
+ elsif configuration&.bibliography_titles&.map(&:downcase)&.include? (ret)
134
62
  "bibliography"
135
63
  else
136
64
  ret
@@ -144,11 +72,11 @@ module Asciidoctor
144
72
 
145
73
  def outputs(node, ret)
146
74
  File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
147
- presentation_xml_converter(node).convert(@filename + ".xml")
148
- html_converter(node).convert(@filename + ".presentation.xml",
149
- nil, false, "#{@filename}.html")
150
- doc_converter(node).convert(@filename + ".presentation.xml",
151
- nil, false, "#{@filename}.doc")
75
+ presentation_xml_converter(node)&.convert(@filename + ".xml")
76
+ html_converter(node)&.convert(@filename + ".presentation.xml",
77
+ nil, false, "#{@filename}.html")
78
+ doc_converter(node)&.convert(@filename + ".presentation.xml",
79
+ nil, false, "#{@filename}.doc")
152
80
  pdf_converter(node)&.convert(@filename + ".presentation.xml",
153
81
  nil, false, "#{@filename}.pdf")
154
82
 
@@ -168,6 +96,7 @@ module Asciidoctor
168
96
 
169
97
  def bibdata_validate(doc)
170
98
  stage_validate(doc)
99
+ committee_validate(doc)
171
100
  end
172
101
 
173
102
  def stage_validate(xmldoc)
@@ -178,6 +107,15 @@ module Asciidoctor
178
107
  @log.add("Document Attributes", nil, "#{stage} is not a recognised status")
179
108
  end
180
109
 
110
+ def committee_validate(xmldoc)
111
+ committees = Array(configuration&.committees) || return
112
+ committees.empty? and return
113
+ xmldoc.xpath("//bibdata/ext/editorialgroup/committee").each do |c|
114
+ committees.include? c.text or
115
+ @log.add("Document Attributes", nil, "#{c.text} is not a recognised committee")
116
+ end
117
+ end
118
+
181
119
  def sections_cleanup(x)
182
120
  super
183
121
  x.xpath("//*[@inline-header]").each do |h|
@@ -214,6 +152,26 @@ module Asciidoctor
214
152
  end
215
153
  conv
216
154
  end
155
+
156
+ def boilerplate_file(xmldoc)
157
+ f = configuration.boilerplate
158
+ f.nil? and return super
159
+ f.is_a? String and return baselocation(f)
160
+ f.is_a? Hash and f[@lang] and return baselocation(f[@lang])
161
+ super
162
+ end
163
+
164
+ def cleanup(xmldoc)
165
+ super
166
+ empty_metadata_cleanup(xmldoc)
167
+ xmldoc
168
+ end
169
+
170
+ def empty_metadata_cleanup(xmldoc)
171
+ xmldoc.xpath("//bibdata/ext//*").each do |x|
172
+ x.remove if x.children.empty?
173
+ end
174
+ end
217
175
  end
218
176
  end
219
177
  end
@@ -0,0 +1,103 @@
1
+ module Asciidoctor
2
+ module Generic
3
+ class Converter < Standoc::Converter
4
+ def default_publisher
5
+ configuration.organization_name_long
6
+ end
7
+
8
+ def org_abbrev
9
+ if !configuration.organization_name_long.empty? &&
10
+ !configuration.organization_name_short.empty? &&
11
+ configuration.organization_name_long !=
12
+ configuration.organization_name_short
13
+ { configuration.organization_name_long =>
14
+ configuration.organization_name_short }
15
+ else
16
+ super
17
+ end
18
+ end
19
+
20
+ def relaton_relations
21
+ Array(configuration.relations) || []
22
+ end
23
+
24
+ def metadata_committee(node, xml)
25
+ return unless node.attr("committee")
26
+ xml.editorialgroup do |a|
27
+ a.committee node.attr("committee"),
28
+ **attr_code(type: node.attr("committee-type"))
29
+ i = 2
30
+ while node.attr("committee_#{i}") do
31
+ a.committee node.attr("committee_#{i}"),
32
+ **attr_code(type: node.attr("committee-type_#{i}"))
33
+ i += 1
34
+ end
35
+ end
36
+ end
37
+
38
+ def metadata_status(node, xml)
39
+ xml.status do |s|
40
+ s.stage ( node.attr("status") || node.attr("docstage") ||
41
+ configuration.default_stage || "published" )
42
+ x = node.attr("substage") and s.substage x
43
+ x = node.attr("iteration") and s.iteration x
44
+ end
45
+ end
46
+
47
+ def metadata_id(node, xml)
48
+ xml.docidentifier **{ type:
49
+ configuration.organization_name_short } do |i|
50
+ i << "DUMMY"
51
+ end
52
+ xml.docnumber { |i| i << node.attr("docnumber") }
53
+ end
54
+
55
+ def metadata_ext(node, ext)
56
+ super
57
+ if configuration.metadata_extensions.is_a? Hash
58
+ metadata_ext_hash(node, ext, configuration.metadata_extensions)
59
+ else
60
+ Array(configuration.metadata_extensions).each do |e|
61
+ a = node.attr(e) and ext.send e, a
62
+ end
63
+ end
64
+ end
65
+
66
+ EXT_STRUCT = %w(_output _attribute _list).freeze
67
+
68
+ def metadata_ext_hash(node, ext, hash)
69
+ hash.each do |k, v|
70
+ next if EXT_STRUCT.include?(k) || !v&.is_a?(Hash) && !node.attr(k)
71
+ if v&.is_a?(Hash) && v["_list"]
72
+ csv_split(node.attr(k)).each do |val|
73
+ metadata_ext_hash1(k, val, ext, v, node)
74
+ end
75
+ else
76
+ metadata_ext_hash1(k, node.attr(k), ext, v, node)
77
+ end
78
+ end
79
+ end
80
+
81
+ def metadata_ext_hash1(key, value, ext, hash, node)
82
+ return if hash&.is_a?(Hash) && hash["_attribute"]
83
+ is_hash = hash&.is_a?(Hash) &&
84
+ !hash.keys.reject { |n| EXT_STRUCT.include?(n) }.empty?
85
+ return if !is_hash && (value.nil? || value.empty?)
86
+ name = hash&.is_a?(Hash) ? (hash["_output"] || key) : key
87
+ ext.send name, **attr_code(metadata_ext_attrs(hash, node)) do |e|
88
+ is_hash ? metadata_ext_hash(node, e, hash) : (e << value)
89
+ end
90
+ end
91
+
92
+ def metadata_ext_attrs(hash, node)
93
+ return {} unless hash.is_a?(Hash)
94
+ ret = {}
95
+ hash.each do |k, v|
96
+ next unless v.is_a?(Hash) && v["_attribute"]
97
+ ret[(v["_output"] || k).to_sym] = node.attr(k)
98
+ end
99
+ ret
100
+ end
101
+ end
102
+ end
103
+ end
@@ -59,6 +59,13 @@
59
59
  </define>
60
60
  <define name="generic-standard">
61
61
  <element name="generic-standard">
62
+ <attribute name="version"/>
63
+ <attribute name="type">
64
+ <choice>
65
+ <value>semantic</value>
66
+ <value>presentation</value>
67
+ </choice>
68
+ </attribute>
62
69
  <ref name="bibdata"/>
63
70
  <zeroOrMore>
64
71
  <ref name="termdocsource"/>
@@ -43,7 +43,9 @@
43
43
  <define name="xref">
44
44
  <element name="xref">
45
45
  <attribute name="target">
46
- <data type="IDREF"/>
46
+ <data type="string">
47
+ <param name="pattern">\i\c*|\c+#\c+</param>
48
+ </data>
47
49
  </attribute>
48
50
  <optional>
49
51
  <attribute name="type">
@@ -61,6 +63,11 @@
61
63
  </choice>
62
64
  </attribute>
63
65
  </optional>
66
+ <optional>
67
+ <attribute name="droploc">
68
+ <data type="boolean"/>
69
+ </attribute>
70
+ </optional>
64
71
  <text/>
65
72
  </element>
66
73
  </define>
@@ -578,6 +585,8 @@
578
585
  <ref name="ol"/>
579
586
  <ref name="dl"/>
580
587
  <ref name="formula"/>
588
+ <ref name="quote"/>
589
+ <ref name="sourcecode"/>
581
590
  </choice>
582
591
  </oneOrMore>
583
592
  </element>
@@ -661,6 +670,16 @@
661
670
  </choice>
662
671
  </attribute>
663
672
  </optional>
673
+ <optional>
674
+ <attribute name="valign">
675
+ <choice>
676
+ <value>top</value>
677
+ <value>middle</value>
678
+ <value>bottom</value>
679
+ <value>baseline</value>
680
+ </choice>
681
+ </attribute>
682
+ </optional>
664
683
  <choice>
665
684
  <zeroOrMore>
666
685
  <choice>
@@ -697,6 +716,16 @@
697
716
  </choice>
698
717
  </attribute>
699
718
  </optional>
719
+ <optional>
720
+ <attribute name="valign">
721
+ <choice>
722
+ <value>top</value>
723
+ <value>middle</value>
724
+ <value>bottom</value>
725
+ <value>baseline</value>
726
+ </choice>
727
+ </attribute>
728
+ </optional>
700
729
  <choice>
701
730
  <zeroOrMore>
702
731
  <choice>
@@ -834,6 +863,13 @@
834
863
  </define>
835
864
  <define name="standard-document">
836
865
  <element name="standard-document">
866
+ <attribute name="version"/>
867
+ <attribute name="type">
868
+ <choice>
869
+ <value>semantic</value>
870
+ <value>presentation</value>
871
+ </choice>
872
+ </attribute>
837
873
  <ref name="bibdata"/>
838
874
  <optional>
839
875
  <ref name="boilerplate"/>
@@ -855,7 +891,7 @@
855
891
  <oneOrMore>
856
892
  <choice>
857
893
  <ref name="content"/>
858
- <ref name="preface_abstract"/>
894
+ <ref name="abstract"/>
859
895
  <ref name="foreword"/>
860
896
  <ref name="introduction"/>
861
897
  <ref name="acknowledgements"/>
@@ -1049,14 +1085,17 @@
1049
1085
  <ref name="section-title"/>
1050
1086
  </optional>
1051
1087
  <group>
1052
- <group>
1053
- <zeroOrMore>
1054
- <ref name="BasicBlock"/>
1055
- </zeroOrMore>
1056
- <zeroOrMore>
1057
- <ref name="note"/>
1058
- </zeroOrMore>
1059
- </group>
1088
+ <choice>
1089
+ <group>
1090
+ <zeroOrMore>
1091
+ <ref name="BasicBlock"/>
1092
+ </zeroOrMore>
1093
+ <zeroOrMore>
1094
+ <ref name="note"/>
1095
+ </zeroOrMore>
1096
+ </group>
1097
+ <ref name="amend"/>
1098
+ </choice>
1060
1099
  <zeroOrMore>
1061
1100
  <choice>
1062
1101
  <ref name="clause-subsection"/>
@@ -1453,11 +1492,6 @@
1453
1492
  </optional>
1454
1493
  </element>
1455
1494
  </define>
1456
- <define name="preface_abstract">
1457
- <element name="abstract">
1458
- <ref name="Basic-Section"/>
1459
- </element>
1460
- </define>
1461
1495
  <define name="term-clause">
1462
1496
  <element name="clause">
1463
1497
  <optional>
@@ -1507,4 +1541,79 @@
1507
1541
  <ref name="CitationType"/>
1508
1542
  </element>
1509
1543
  </define>
1544
+ <define name="amend">
1545
+ <element name="amend">
1546
+ <optional>
1547
+ <attribute name="id">
1548
+ <data type="ID"/>
1549
+ </attribute>
1550
+ </optional>
1551
+ <attribute name="change">
1552
+ <choice>
1553
+ <value>add</value>
1554
+ <value>modify</value>
1555
+ <value>delete</value>
1556
+ </choice>
1557
+ </attribute>
1558
+ <optional>
1559
+ <attribute name="path"/>
1560
+ </optional>
1561
+ <optional>
1562
+ <attribute name="path_end"/>
1563
+ </optional>
1564
+ <optional>
1565
+ <attribute name="title"/>
1566
+ </optional>
1567
+ <optional>
1568
+ <element name="location">
1569
+ <zeroOrMore>
1570
+ <ref name="locality"/>
1571
+ </zeroOrMore>
1572
+ </element>
1573
+ </optional>
1574
+ <zeroOrMore>
1575
+ <ref name="autonumber"/>
1576
+ </zeroOrMore>
1577
+ <optional>
1578
+ <element name="description">
1579
+ <zeroOrMore>
1580
+ <ref name="BasicBlock"/>
1581
+ </zeroOrMore>
1582
+ </element>
1583
+ </optional>
1584
+ <optional>
1585
+ <element name="newcontent">
1586
+ <zeroOrMore>
1587
+ <ref name="BasicBlock"/>
1588
+ </zeroOrMore>
1589
+ </element>
1590
+ </optional>
1591
+ <optional>
1592
+ <element name="description">
1593
+ <zeroOrMore>
1594
+ <ref name="BasicBlock"/>
1595
+ </zeroOrMore>
1596
+ </element>
1597
+ </optional>
1598
+ </element>
1599
+ </define>
1600
+ <define name="autonumber">
1601
+ <element name="autonumber">
1602
+ <attribute name="type">
1603
+ <choice>
1604
+ <value>requirement</value>
1605
+ <value>recommendation</value>
1606
+ <value>permission</value>
1607
+ <value>table</value>
1608
+ <value>figure</value>
1609
+ <value>admonition</value>
1610
+ <value>formula</value>
1611
+ <value>sourcecode</value>
1612
+ <value>example</value>
1613
+ <value>note</value>
1614
+ </choice>
1615
+ </attribute>
1616
+ <text/>
1617
+ </element>
1618
+ </define>
1510
1619
  </grammar>
@@ -4,11 +4,13 @@ require "fileutils"
4
4
  module IsoDoc
5
5
  module Generic
6
6
  module BaseConvert
7
+ =begin
7
8
  def baselocation(loc)
8
9
  return nil if loc.nil?
9
10
  File.expand_path(File.join(
10
11
  File.dirname(self.class::_file || __FILE__), "..", "..", "..", loc))
11
12
  end
13
+ =end
12
14
 
13
15
  def cleanup(docxml)
14
16
  super
@@ -636,7 +636,7 @@ div.WordSection2
636
636
 
637
637
  div.WordSection3
638
638
  {page:WordSection3;}
639
- table.MsoISOTable
639
+ table.MsoISOTable, table.MsoISOTableBig
640
640
  {mso-style-name:"Table ISO";
641
641
  mso-tstyle-rowband-size:0;
642
642
  mso-tstyle-colband-size:0;
@@ -656,15 +656,15 @@ table.MsoISOTable
656
656
  mso-border-insidev:.75pt solid windowtext;
657
657
  font-size:10.0pt;
658
658
  font-family:$bodyfont;}
659
- table.MsoISOTable th
659
+ table.MsoISOTable th, table.MsoISOTableBig th
660
660
  {border:solid windowtext 1pt;
661
661
  mso-border-alt:solid windowtext 1pt;
662
662
  padding:0cm 2.85pt 0cm 2.85pt;}
663
- table.MsoISOTable td
663
+ table.MsoISOTable td, table.MsoISOTableBig td
664
664
  {border:solid windowtext 1pt;
665
665
  mso-border-alt:solid windowtext 1pt;
666
666
  padding:0cm 2.85pt 0cm 2.85pt;}
667
- table.MsoISOTable p
667
+ table.MsoISOTable p, table.MsoISOTableBig p
668
668
  {font-size:10.0pt; }
669
669
  table.MsoTableGrid
670
670
  {mso-style-name:"Table Grid";
@@ -750,6 +750,20 @@ div.example p.MsoListParagraph {
750
750
 
751
751
  div.Note p.MsoListParagraph {
752
752
  font-size: 10.0pt;
753
+ margin-left: 1.0cm;
754
+ }
755
+
756
+ div.Note span.stem {
757
+ font-size: 10.0pt; }
758
+
759
+ div.Note p.Sourcecode, div.Note pre.Sourcecode {
760
+ font-size: 8.0pt;
761
+ margin-left: 1.0cm;
762
+ }
763
+
764
+ div.Note table.dl {
765
+ font-size: 10.0pt;
766
+ margin-left: 1.0cm;
753
767
  }
754
768
 
755
769
  span.note_label, span.example_label, td.example_label, td.note_label
@@ -24,10 +24,14 @@ module IsoDoc
24
24
 
25
25
  def default_fonts(options)
26
26
  {
27
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif'
28
- : configuration.html_bodyfont || '"Overpass",sans-serif'),
29
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
30
- configuration.html_headerfont || '"Overpass",sans-serif'),
27
+ bodyfont: (
28
+ options[:script] == "Hans" ? '"SimSun",serif' :
29
+ configuration.html_bodyfont || '"Overpass",sans-serif'
30
+ ),
31
+ headerfont: (
32
+ options[:script] == "Hans" ? '"SimHei",sans-serif' :
33
+ configuration.html_headerfont || '"Overpass",sans-serif'
34
+ ),
31
35
  monospacefont: configuration.html_monospacefont || '"Space Mono",monospace'
32
36
  }
33
37
  end
@@ -35,20 +39,23 @@ module IsoDoc
35
39
  def default_file_locations(_options)
36
40
  {
37
41
  htmlstylesheet: baselocation(configuration.htmlstylesheet) ||
38
- html_doc_path("htmlstyle.scss"),
42
+ html_doc_path("htmlstyle.scss"),
39
43
  htmlcoverpage: baselocation(configuration.htmlcoverpage) ||
40
- html_doc_path("html_generic_titlepage.html"),
44
+ html_doc_path("html_generic_titlepage.html"),
41
45
  htmlintropage: baselocation(configuration.htmlintropage) ||
42
- html_doc_path("html_generic_intro.html"),
46
+ html_doc_path("html_generic_intro.html"),
43
47
  scripts: baselocation(configuration.scripts) ||
44
- html_doc_path("scripts.html"),
45
- i18nyaml: baselocation(configuration.i18nyaml)
48
+ html_doc_path("scripts.html"),
49
+ i18nyaml: (configuration.i18nyaml.is_a?(String) ?
50
+ baselocation(configuration.i18nyaml) : nil)
46
51
  }
47
52
  end
48
53
 
54
+ =begin
49
55
  def configuration
50
56
  Metanorma::Generic.configuration
51
57
  end
58
+ =end
52
59
 
53
60
  def googlefonts
54
61
  return unless configuration.webfont
@@ -0,0 +1,26 @@
1
+ require_relative "utils"
2
+
3
+ module IsoDoc
4
+ module Generic
5
+ class I18n < IsoDoc::I18n
6
+ class << self
7
+ attr_accessor :_file
8
+ end
9
+
10
+ def self.inherited( k )
11
+ k._file = caller_locations.first.absolute_path
12
+ end
13
+
14
+ def load_yaml1(lang, script)
15
+ return super unless configuration.i18nyaml
16
+ file = configuration.i18nyaml.is_a?(Hash) ?
17
+ configuration.i18nyaml[lang] : configuration.i18nyaml
18
+ return super if file.nil?
19
+ y = YAML.load_file(baselocation(file))
20
+ super.merge(y)
21
+ end
22
+
23
+ include Utils
24
+ end
25
+ end
26
+ end
@@ -1,6 +1,8 @@
1
1
  require "isodoc"
2
2
  require_relative "metadata"
3
3
  require_relative "xref"
4
+ require_relative "i18n"
5
+ require_relative "utils"
4
6
 
5
7
  module IsoDoc
6
8
  module Generic
@@ -15,12 +17,13 @@ module IsoDoc
15
17
  end
16
18
 
17
19
  def i18n_init(lang, script, i18nyaml = nil)
18
- @i18n = I18n.new(lang, script, i18nyaml || @i18nyaml)
20
+ f = Metanorma::Generic.configuration.i18nyaml
21
+ f = nil unless f.is_a? String
22
+ @i18n = I18n.new(
23
+ lang, script, i18nyaml || f || @i18nyaml)
19
24
  end
20
25
 
21
- def fileloc(loc)
22
- File.join(File.dirname(__FILE__), loc)
23
- end
26
+ include Utils
24
27
  end
25
28
  end
26
29
  end
@@ -1,4 +1,29 @@
1
1
  require "isodoc"
2
+ require "nokogiri"
3
+ require_relative "init"
4
+ require_relative "utils"
5
+
6
+ class Nokogiri::XML::Node
7
+ TYPENAMES = {1=>'element',2=>'attribute',3=>'text',4=>'cdata',8=>'comment'}
8
+ def to_hash
9
+ ret = {kind:TYPENAMES[node_type],name:name}.tap do |h|
10
+ h.merge! text:text&.strip
11
+ a = attribute_nodes.map(&:to_hash)
12
+ if element? && !a.empty?
13
+ h.merge! attr: a.inject({}) { |m, v| m[v[:name]] = v[:text]; m }
14
+ end
15
+ c = children.map(&:to_hash)
16
+ if element? && !(c&.size == 1 && c[0][:kind] == "text")
17
+ h.merge! kids: c.delete_if { |n| n[:kind] == "text" && n[:text].empty? }
18
+ end
19
+ end
20
+ ret
21
+ end
22
+ end
23
+
24
+ class Nokogiri::XML::Document
25
+ def to_hash; root.to_hash; end
26
+ end
2
27
 
3
28
  module IsoDoc
4
29
  module Generic
@@ -22,16 +47,6 @@ module IsoDoc
22
47
  k._file = caller_locations.first.absolute_path
23
48
  end
24
49
 
25
- def baselocation(loc)
26
- return nil if loc.nil?
27
- File.expand_path(File.join(
28
- File.dirname(self.class::_file || __FILE__), "..", "..", "..", loc))
29
- end
30
-
31
- def configuration
32
- Metanorma::Generic.configuration
33
- end
34
-
35
50
  def author(isoxml, _out)
36
51
  super
37
52
  tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee"))
@@ -48,12 +63,32 @@ module IsoDoc
48
63
  !(Array(stages).map { |m| m.downcase }.include? status.downcase)
49
64
  end
50
65
 
51
- def ext(isoxml, out)
52
- Array(configuration.metadata_extensions).each do |e|
53
- b = isoxml&.at(ns("//bibdata/ext/#{e}"))&.text or next
54
- set(e.to_sym, b)
66
+ def xmlhash2hash(h)
67
+ ret = {}
68
+ return ret if h.nil? || h[:kind] != "element"
69
+ h[:attr].nil? or h[:attr].each { |k, v| ret["#{h[:name]}_#{k}"] = v }
70
+ ret[h[:name]] = h[:kids] ? xmlhash2hash_kids(h) : h[:text]
71
+ ret
72
+ end
73
+
74
+ def xmlhash2hash_kids(h)
75
+ c = {}
76
+ h[:kids].each do |n|
77
+ xmlhash2hash(n).each do |k1, v1|
78
+ c[k1] = c[k1].nil? ? v1 :
79
+ c[k1].is_a?(Array) ? c[k1] << v1 :
80
+ [c[k1], v1]
81
+ end
55
82
  end
83
+ c
56
84
  end
85
+
86
+ def ext(isoxml, out)
87
+ b = isoxml&.at(ns("//bibdata/ext")) or return
88
+ set(:metadata_extensions, xmlhash2hash(b.to_hash)["ext"])
89
+ end
90
+
91
+ include Utils
57
92
  end
58
93
  end
59
94
  end
@@ -1,4 +1,5 @@
1
1
  require_relative "init"
2
+ require_relative "metadata"
2
3
  require "isodoc"
3
4
 
4
5
  module IsoDoc
@@ -0,0 +1,21 @@
1
+ module IsoDoc
2
+ module Generic
3
+ module Utils
4
+ def configuration
5
+ Metanorma::Generic.configuration
6
+ end
7
+
8
+ def fileloc(loc)
9
+ File.join(File.dirname(__FILE__), loc)
10
+ end
11
+
12
+ def baselocation(loc)
13
+ return nil if loc.nil?
14
+ f = defined?(self.class::_file) ? (self.class::_file || __FILE__) :
15
+ __FILE__
16
+ File.expand_path(File.join(
17
+ File.dirname(f), "..", "..", "..", loc))
18
+ end
19
+ end
20
+ end
21
+ end
@@ -23,10 +23,14 @@ module IsoDoc
23
23
 
24
24
  def default_fonts(options)
25
25
  {
26
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' :
27
- configuration.word_bodyfont || '"Arial",sans-serif'),
28
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
29
- configuration.word_headerfont || '"Arial",sans-serif'),
26
+ bodyfont: (
27
+ options[:script] == "Hans" ? '"SimSun",serif' :
28
+ configuration.word_bodyfont || '"Arial",sans-serif'
29
+ ),
30
+ headerfont: (
31
+ options[:script] == "Hans" ? '"SimHei",sans-serif' :
32
+ configuration.word_headerfont || '"Arial",sans-serif'
33
+ ),
30
34
  monospacefont: configuration.word_monospacefont || '"Courier New",monospace'
31
35
  }
32
36
  end
@@ -34,24 +38,27 @@ module IsoDoc
34
38
  def default_file_locations(options)
35
39
  {
36
40
  wordstylesheet: baselocation(configuration.wordstylesheet) ||
37
- html_doc_path("wordstyle.scss"),
41
+ html_doc_path("wordstyle.scss"),
38
42
  standardstylesheet: baselocation(configuration.standardstylesheet) ||
39
- html_doc_path("generic.scss"),
43
+ html_doc_path("generic.scss"),
40
44
  header: baselocation(configuration.header) ||
41
- html_doc_path("header.html"),
45
+ html_doc_path("header.html"),
42
46
  wordcoverpage: baselocation(configuration.wordcoverpage) ||
43
- html_doc_path("word_generic_titlepage.html"),
47
+ html_doc_path("word_generic_titlepage.html"),
44
48
  wordintropage: baselocation(configuration.wordintropage) ||
45
- html_doc_path("word_generic_intro.html"),
46
- i18nyaml: baselocation(configuration.i18nyaml),
47
- ulstyle: "l3",
48
- olstyle: "l2",
49
+ html_doc_path("word_generic_intro.html"),
50
+ i18nyaml: (configuration.i18nyaml.is_a?(String) ?
51
+ baselocation(configuration.i18nyaml) : nil),
52
+ ulstyle: "l3",
53
+ olstyle: "l2",
49
54
  }
50
55
  end
51
56
 
57
+ =begin
52
58
  def configuration
53
59
  Metanorma::Generic.configuration
54
60
  end
61
+ =end
55
62
 
56
63
  include BaseConvert
57
64
  include Init
@@ -15,6 +15,8 @@ module Metanorma
15
15
  organization_name_short
16
16
  organization_name_long
17
17
  bibliography_titles
18
+ boilerplate
19
+ committees
18
20
  document_namespace
19
21
  docid_template
20
22
  doctypes
@@ -33,6 +35,7 @@ module Metanorma
33
35
  metanorma_name
34
36
  normref_titles
35
37
  published_stages
38
+ relations
36
39
  default_stage
37
40
  stage_abbreviations
38
41
  scripts
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Generic
3
- VERSION = "1.6.0"
3
+ VERSION = "1.7.1"
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency "htmlentities", "~> 4.3.4"
30
30
  spec.add_dependency "ruby-jing"
31
- spec.add_dependency "metanorma-standoc", "~> 1.5.0"
31
+ spec.add_dependency "metanorma-standoc", "~> 1.6.0"
32
32
  spec.add_dependency "isodoc", "~> 1.2.0"
33
33
 
34
34
  spec.add_development_dependency "byebug", "~> 9.1"
@@ -29,6 +29,11 @@ metadata_extensions:
29
29
  - security
30
30
  published_stages:
31
31
  - published
32
+ committees:
33
+ - TC 1
34
+ relations:
35
+ - part-of
36
+ - translated-from
32
37
  stage_abbreviations:
33
38
  draft-proposal:
34
39
  draft-development:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-generic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2020-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.5.0
47
+ version: 1.6.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.5.0
54
+ version: 1.6.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: isodoc
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -236,6 +236,7 @@ files:
236
236
  - lib/asciidoctor/generic/basicdoc.rng
237
237
  - lib/asciidoctor/generic/biblio.rng
238
238
  - lib/asciidoctor/generic/converter.rb
239
+ - lib/asciidoctor/generic/front.rb
239
240
  - lib/asciidoctor/generic/generic.rng
240
241
  - lib/asciidoctor/generic/isodoc.rng
241
242
  - lib/asciidoctor/generic/reqt.rng
@@ -253,10 +254,12 @@ files:
253
254
  - lib/isodoc/generic/html/word_generic_titlepage.html
254
255
  - lib/isodoc/generic/html/wordstyle.scss
255
256
  - lib/isodoc/generic/html_convert.rb
257
+ - lib/isodoc/generic/i18n.rb
256
258
  - lib/isodoc/generic/init.rb
257
259
  - lib/isodoc/generic/metadata.rb
258
260
  - lib/isodoc/generic/pdf_convert.rb
259
261
  - lib/isodoc/generic/presentation_xml_convert.rb
262
+ - lib/isodoc/generic/utils.rb
260
263
  - lib/isodoc/generic/word_convert.rb
261
264
  - lib/isodoc/generic/xref.rb
262
265
  - lib/metanorma-generic.rb