metanorma-cc 1.4.2 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ccd3c862d1d967d0782115e2319f5d9c41a1346a06b85fa1cbd25626101b939
4
- data.tar.gz: 10076bc4151a870b5f219461fa29ffd062bfe6888800daf923ecf4475b1c887a
3
+ metadata.gz: 7e7ea8aa4a98c9025bee7fe799d5fceef2e3509ecc5418805f66feae05184edd
4
+ data.tar.gz: 9d4d96365f854898f09da7b73593991aa8c0a8b8b4c6dad051fc94b9b05a6873
5
5
  SHA512:
6
- metadata.gz: 27ebb897618ae5d5bc58ea3e0e9831435268f509c6dc0cc3920c17e6f66c84b79decb38f57d27b70ef4835fd7c5715224cd488c2d200391e6dd365f417191b31
7
- data.tar.gz: 0c4646dd8aaaf21ff10b0f7becf143973566c801dec65bb6b5fa3b8d0f04e6a8a836f7e74ce6116e0467e93abad9ac7a4b2e753310ee96858d44d2a9c449febd
6
+ metadata.gz: 8c473d1ed5976283580bf9f5569aff23d1f545d9f5ea4b093ef990fe94db6cf7900e13e1060cbcf30d00c7fd7241060ccc212d9e3e027589003d562efe7fe23f
7
+ data.tar.gz: 9643f9dbbafe84104aaaa774bbc21bd708a39c9509526da74851978b7447a87ed414433bf77d35f0446336b04ccc0bfe18b94c8158a49dd5fb43929ce0039f8d
@@ -158,7 +158,17 @@
158
158
  <data type="ID"/>
159
159
  </attribute>
160
160
  <oneOrMore>
161
- <ref name="paragraph"/>
161
+ <choice>
162
+ <ref name="formula"/>
163
+ <ref name="ul"/>
164
+ <ref name="ol"/>
165
+ <ref name="dl"/>
166
+ <ref name="quote"/>
167
+ <ref name="sourcecode"/>
168
+ <ref name="paragraph"/>
169
+ <ref name="table"/>
170
+ <ref name="figure"/>
171
+ </choice>
162
172
  </oneOrMore>
163
173
  </element>
164
174
  </define>
@@ -402,6 +412,16 @@
402
412
  </choice>
403
413
  </attribute>
404
414
  </optional>
415
+ <optional>
416
+ <attribute name="valign">
417
+ <choice>
418
+ <value>top</value>
419
+ <value>middle</value>
420
+ <value>bottom</value>
421
+ <value>baseline</value>
422
+ </choice>
423
+ </attribute>
424
+ </optional>
405
425
  <choice>
406
426
  <zeroOrMore>
407
427
  <ref name="TextElement"/>
@@ -429,6 +449,16 @@
429
449
  </choice>
430
450
  </attribute>
431
451
  </optional>
452
+ <optional>
453
+ <attribute name="valign">
454
+ <choice>
455
+ <value>top</value>
456
+ <value>middle</value>
457
+ <value>bottom</value>
458
+ <value>baseline</value>
459
+ </choice>
460
+ </attribute>
461
+ </optional>
432
462
  <choice>
433
463
  <zeroOrMore>
434
464
  <ref name="TextElement"/>
@@ -27,9 +27,12 @@ module Asciidoctor
27
27
  def outputs(node, ret)
28
28
  File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
29
29
  presentation_xml_converter(node).convert(@filename + ".xml")
30
- html_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.html")
31
- doc_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.doc")
32
- pdf_converter(node)&.convert(@filename + ".presentation.xml", nil, false, "#{@filename}.pdf")
30
+ html_converter(node).convert(@filename + ".presentation.xml",
31
+ nil, false, "#{@filename}.html")
32
+ doc_converter(node).convert(@filename + ".presentation.xml",
33
+ nil, false, "#{@filename}.doc")
34
+ pdf_converter(node)&.convert(@filename + ".presentation.xml",
35
+ nil, false, "#{@filename}.pdf")
33
36
  end
34
37
 
35
38
  def validate(doc)
@@ -4,26 +4,9 @@ require "fileutils"
4
4
 
5
5
  module Asciidoctor
6
6
  module CC
7
-
8
7
  class Converter < Standoc::Converter
9
-
10
- def metadata_author(node, xml)
11
- xml.contributor do |c|
12
- c.role **{ type: "author" }
13
- c.organization do |a|
14
- a.name "CalConnect"
15
- end
16
- end
17
- personal_author(node, xml)
18
- end
19
-
20
- def metadata_publisher(node, xml)
21
- xml.contributor do |c|
22
- c.role **{ type: "publisher" }
23
- c.organization do |a|
24
- a.name "CalConnect"
25
- end
26
- end
8
+ def default_publisher
9
+ "CalConnect"
27
10
  end
28
11
 
29
12
  def metadata_committee(node, xml)
@@ -50,7 +33,7 @@ module Asciidoctor
50
33
 
51
34
  def prefix_id(node)
52
35
  prefix = "CC"
53
- typesuffix = ::Metanorma::CC::DOCSUFFIX[node.attr("doctype")] || ""
36
+ typesuffix = ::Metanorma::CC::DOCSUFFIX[doctype(node)] || ""
54
37
  prefix += "/#{typesuffix}" unless typesuffix.empty?
55
38
  status = ::Metanorma::CC::DOCSTATUS[node.attr("status")] || ""
56
39
  prefix += "/#{status}" unless status.empty?
@@ -67,27 +50,18 @@ module Asciidoctor
67
50
  xml.docnumber node.attr("docnumber")
68
51
  end
69
52
 
53
+ @log_doctype = false
54
+
70
55
  def doctype(node)
71
- d = node.attr("doctype")
72
- unless ::Metanorma::CC::DOCSUFFIX.keys.include?(d)
56
+ d = super
57
+ unless ::Metanorma::CC::DOCSUFFIX.keys.include?(d) && !@log_doctype
73
58
  @log.add("Document Attributes", nil,
74
59
  "#{d} is not a legal document type: reverting to 'standard'")
60
+ @log_doctype = true
75
61
  d = "standard"
76
62
  end
77
63
  d
78
64
  end
79
-
80
- def metadata_copyright(node, xml)
81
- from = node.attr("copyright-year") || Date.today.year
82
- xml.copyright do |c|
83
- c.from from
84
- c.owner do |owner|
85
- owner.organization do |o|
86
- o.name "CalConnect"
87
- end
88
- end
89
- end
90
- end
91
65
  end
92
66
  end
93
67
  end
@@ -42,8 +42,11 @@
42
42
  </define>
43
43
  <define name="xref">
44
44
  <element name="xref">
45
+ <!-- attribute target { xsd:IDREF }, -->
45
46
  <attribute name="target">
46
- <data type="IDREF"/>
47
+ <data type="string">
48
+ <param name="pattern">\i\c*|\c+#\c+</param>
49
+ </data>
47
50
  </attribute>
48
51
  <optional>
49
52
  <attribute name="type">
@@ -578,6 +581,8 @@
578
581
  <ref name="ol"/>
579
582
  <ref name="dl"/>
580
583
  <ref name="formula"/>
584
+ <ref name="quote"/>
585
+ <ref name="sourcecode"/>
581
586
  </choice>
582
587
  </oneOrMore>
583
588
  </element>
@@ -661,6 +666,16 @@
661
666
  </choice>
662
667
  </attribute>
663
668
  </optional>
669
+ <optional>
670
+ <attribute name="valign">
671
+ <choice>
672
+ <value>top</value>
673
+ <value>middle</value>
674
+ <value>bottom</value>
675
+ <value>baseline</value>
676
+ </choice>
677
+ </attribute>
678
+ </optional>
664
679
  <choice>
665
680
  <zeroOrMore>
666
681
  <choice>
@@ -697,6 +712,16 @@
697
712
  </choice>
698
713
  </attribute>
699
714
  </optional>
715
+ <optional>
716
+ <attribute name="valign">
717
+ <choice>
718
+ <value>top</value>
719
+ <value>middle</value>
720
+ <value>bottom</value>
721
+ <value>baseline</value>
722
+ </choice>
723
+ </attribute>
724
+ </optional>
700
725
  <choice>
701
726
  <zeroOrMore>
702
727
  <choice>
@@ -922,6 +947,9 @@
922
947
  <optional>
923
948
  <attribute name="script"/>
924
949
  </optional>
950
+ <optional>
951
+ <attribute name="type"/>
952
+ </optional>
925
953
  <optional>
926
954
  <attribute name="obligation">
927
955
  <choice>
@@ -961,9 +989,6 @@
961
989
  </define>
962
990
  <define name="content-subsection">
963
991
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
992
  <ref name="Content-Section"/>
968
993
  </element>
969
994
  </define>
@@ -992,6 +1017,9 @@
992
1017
  </choice>
993
1018
  </attribute>
994
1019
  </optional>
1020
+ <optional>
1021
+ <attribute name="type"/>
1022
+ </optional>
995
1023
  <optional>
996
1024
  <ref name="section-title"/>
997
1025
  </optional>
@@ -1011,9 +1039,6 @@
1011
1039
  </define>
1012
1040
  <define name="clause">
1013
1041
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1042
  <ref name="Clause-Section"/>
1018
1043
  </element>
1019
1044
  </define>
@@ -1042,18 +1067,24 @@
1042
1067
  </choice>
1043
1068
  </attribute>
1044
1069
  </optional>
1070
+ <optional>
1071
+ <attribute name="type"/>
1072
+ </optional>
1045
1073
  <optional>
1046
1074
  <ref name="section-title"/>
1047
1075
  </optional>
1048
1076
  <group>
1049
- <group>
1050
- <zeroOrMore>
1051
- <ref name="BasicBlock"/>
1052
- </zeroOrMore>
1053
- <zeroOrMore>
1054
- <ref name="note"/>
1055
- </zeroOrMore>
1056
- </group>
1077
+ <choice>
1078
+ <group>
1079
+ <zeroOrMore>
1080
+ <ref name="BasicBlock"/>
1081
+ </zeroOrMore>
1082
+ <zeroOrMore>
1083
+ <ref name="note"/>
1084
+ </zeroOrMore>
1085
+ </group>
1086
+ <ref name="amend"/>
1087
+ </choice>
1057
1088
  <zeroOrMore>
1058
1089
  <choice>
1059
1090
  <ref name="clause-subsection"/>
@@ -1180,6 +1211,9 @@
1180
1211
  <optional>
1181
1212
  <attribute name="script"/>
1182
1213
  </optional>
1214
+ <optional>
1215
+ <attribute name="type"/>
1216
+ </optional>
1183
1217
  <optional>
1184
1218
  <attribute name="obligation">
1185
1219
  <choice>
@@ -1501,4 +1535,79 @@
1501
1535
  <ref name="CitationType"/>
1502
1536
  </element>
1503
1537
  </define>
1538
+ <define name="amend">
1539
+ <element name="amend">
1540
+ <optional>
1541
+ <attribute name="id">
1542
+ <data type="ID"/>
1543
+ </attribute>
1544
+ </optional>
1545
+ <attribute name="change">
1546
+ <choice>
1547
+ <value>add</value>
1548
+ <value>modify</value>
1549
+ <value>delete</value>
1550
+ </choice>
1551
+ </attribute>
1552
+ <optional>
1553
+ <attribute name="path"/>
1554
+ </optional>
1555
+ <optional>
1556
+ <attribute name="path_end"/>
1557
+ </optional>
1558
+ <optional>
1559
+ <attribute name="title"/>
1560
+ </optional>
1561
+ <optional>
1562
+ <element name="location">
1563
+ <zeroOrMore>
1564
+ <ref name="locality"/>
1565
+ </zeroOrMore>
1566
+ </element>
1567
+ </optional>
1568
+ <zeroOrMore>
1569
+ <ref name="autonumber"/>
1570
+ </zeroOrMore>
1571
+ <optional>
1572
+ <element name="description">
1573
+ <zeroOrMore>
1574
+ <ref name="BasicBlock"/>
1575
+ </zeroOrMore>
1576
+ </element>
1577
+ </optional>
1578
+ <optional>
1579
+ <element name="newcontent">
1580
+ <zeroOrMore>
1581
+ <ref name="BasicBlock"/>
1582
+ </zeroOrMore>
1583
+ </element>
1584
+ </optional>
1585
+ <optional>
1586
+ <element name="description">
1587
+ <zeroOrMore>
1588
+ <ref name="BasicBlock"/>
1589
+ </zeroOrMore>
1590
+ </element>
1591
+ </optional>
1592
+ </element>
1593
+ </define>
1594
+ <define name="autonumber">
1595
+ <element name="autonumber">
1596
+ <attribute name="type">
1597
+ <choice>
1598
+ <value>requirement</value>
1599
+ <value>recommendation</value>
1600
+ <value>permission</value>
1601
+ <value>table</value>
1602
+ <value>figure</value>
1603
+ <value>admonition</value>
1604
+ <value>formula</value>
1605
+ <value>sourcecode</value>
1606
+ <value>example</value>
1607
+ <value>note</value>
1608
+ </choice>
1609
+ </attribute>
1610
+ <text/>
1611
+ </element>
1612
+ </define>
1504
1613
  </grammar>
@@ -30,9 +30,10 @@ module Asciidoctor
30
30
 
31
31
  def seqcheck(names, msg, accepted)
32
32
  n = names.shift
33
- unless accepted.include? n
33
+ return [] if n.nil?
34
+ test = accepted.map { |a| n.at(a) }
35
+ if test.all? { |a| a.nil? }
34
36
  @log.add("Style", nil, msg)
35
- names = []
36
37
  end
37
38
  names
38
39
  end
@@ -43,32 +44,20 @@ module Asciidoctor
43
44
  [
44
45
  {
45
46
  msg: "Initial section must be (content) Foreword",
46
- val: [{ tag: "foreword", title: "Foreword" }],
47
+ val: ["./self::foreword"]
47
48
  },
48
49
  {
49
50
  msg: "Prefatory material must be followed by (clause) Scope",
50
- val: [{ tag: "introduction", title: "Introduction" },
51
- { tag: "clause", title: "Scope" }],
51
+ val: ["./self::introduction", "./self::clause[@type = 'scope']" ]
52
52
  },
53
53
  {
54
54
  msg: "Prefatory material must be followed by (clause) Scope",
55
- val: [{ tag: "clause", title: "Scope" }],
55
+ val: ["./self::clause[@type = 'scope']" ]
56
56
  },
57
57
  {
58
58
  msg: "Normative References must be followed by "\
59
59
  "Terms and Definitions",
60
- val: [
61
- { tag: "terms", title: "Terms and definitions" },
62
- { tag: "clause", title: "Terms and definitions" },
63
- {
64
- tag: "terms",
65
- title: "Terms, definitions, symbols and abbreviated terms",
66
- },
67
- {
68
- tag: "clause",
69
- title: "Terms, definitions, symbols and abbreviated terms",
70
- },
71
- ],
60
+ val: ["./self::terms | .//terms"]
72
61
  },
73
62
  ].freeze
74
63
 
@@ -78,50 +67,47 @@ module Asciidoctor
78
67
  "//clause[descendant::references][not(parent::clause)]".freeze
79
68
 
80
69
  def sections_sequence_validate(root)
81
- f = root.xpath(SECTIONS_XPATH)
82
- names = f.map { |s| { tag: s.name, title: s&.at("./title")&.text } }
83
- names = seqcheck(names, SEQ[0][:msg], SEQ[0][:val]) || return
70
+ names = root.xpath(SECTIONS_XPATH)
71
+ names = seqcheck(names, SEQ[0][:msg], SEQ[0][:val])
84
72
  n = names[0]
85
- names = seqcheck(names, SEQ[1][:msg], SEQ[1][:val]) || return
86
- if n == { tag: "introduction", title: "Introduction" }
87
- names = seqcheck(names, SEQ[2][:msg], SEQ[2][:val]) || return
73
+ names = seqcheck(names, SEQ[1][:msg], SEQ[1][:val])
74
+ if n&.at("./self::introduction")
75
+ names = seqcheck(names, SEQ[2][:msg], SEQ[2][:val])
88
76
  end
89
- names = seqcheck(names, SEQ[3][:msg], SEQ[3][:val]) || return
77
+ names = seqcheck(names, SEQ[3][:msg], SEQ[3][:val])
90
78
  n = names.shift
91
- if n == { tag: "definitions", title: nil }
92
- n = names.shift || return
79
+ if n&.at("./self::definitions")
80
+ n = names.shift
93
81
  end
94
- unless n
82
+ if n.nil? || n.name != "clause"
95
83
  @log.add("Style", nil, "Document must contain at least one clause")
96
- return
97
84
  end
98
- n[:tag] == "clause" ||
85
+ n&.at("./self::clause") ||
99
86
  @log.add("Style", nil, "Document must contain clause after "\
100
87
  "Terms and Definitions")
101
- n == { tag: "clause", title: "Scope" } &&
88
+ n&.at("./self::clause[@type = 'scope']") &&
102
89
  @log.add("Style", nil, "Scope must occur before Terms and Definitions")
103
- n = names.shift || return
104
- while n[:tag] == "clause"
105
- n[:title] == "Scope" &&
90
+ n = names.shift
91
+ while n&.name == "clause"
92
+ n&.at("./self::clause[@type = 'scope']")
106
93
  @log.add("Style", nil, "Scope must occur before Terms and Definitions")
107
- n = names.shift || return
94
+ n = names.shift
108
95
  end
109
- unless n[:tag] == "annex" || n[:tag] == "references"
96
+ unless %w(annex references).include? n&.name
110
97
  @log.add("Style", nil, "Only annexes and references can follow clauses")
111
98
  end
112
- while n[:tag] == "annex"
99
+ while n&.name == "annex"
113
100
  n = names.shift
114
101
  if n.nil?
115
102
  @log.add("Style", nil, "Document must include (references) "\
116
103
  "Normative References")
117
- return
118
104
  end
119
105
  end
120
- n == { tag: "references", title: "Normative References" } ||
106
+ n&.at("./self::references[@normative = 'true']") ||
121
107
  @log.add("Style", nil, "Document must include (references) "\
122
108
  "Normative References")
123
- n = names.shift
124
- n == { tag: "references", title: "Bibliography" } ||
109
+ n = names&.shift
110
+ n&.at("./self::references[@normative = 'false']") ||
125
111
  @log.add("Style", nil, "Final section must be (references) Bibliography")
126
112
  names.empty? ||
127
113
  @log.add("Style", nil, "There are sections after the final Bibliography")