metanorma-cc 1.4.3 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aaec6353b69892d4cb11ddb871e78f40deac9fd7211abc4ca8453d7a90cc2e4e
4
- data.tar.gz: bc3a24bd8da38ee1f601fd4537bb2f2eaa3f64b9b65ce59d7c4e05f0a55d1034
3
+ metadata.gz: a6d45f32ac56da049460224a7b9a264fc302db06a9023abdda10b53ab8df4e18
4
+ data.tar.gz: ac4e8e88813d02bca6a2fdbec491435cedd0f50de19d4de7e5cf67748341b0b5
5
5
  SHA512:
6
- metadata.gz: 8c8783aee29ff7c0424e9757d5abacf9a8c723b0e542d93999cf0c2095854de9d2a3a51b21259b6646cd5a9a18158cbe030c1357fd73c2d385b73010919c576f
7
- data.tar.gz: b9b58534885d70c030e184e8e1f80f2b32939407aec4b22295a4c00665e6a1d8d683dc753291e6a1042b9a73f78f295cb9e9e466a017e7e468d881d0f9ea3953
6
+ metadata.gz: 67cbd5fcc368c00e569451d9842db371be1ad415a4bb74a318edee209bb8fbb982263b3879613cf957f9a13f006f90d638c57ca6e236b11b6c24fe5e026b853a
7
+ data.tar.gz: 934db04e842a3a686d2bd30bf671e61f71456adc98605f48ad420e410197b2ee56fbfc575c207aac59ec1f25364990a56332977508a44ee1a8fa116a5e48b178
@@ -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>
@@ -96,6 +96,13 @@
96
96
  </include>
97
97
  <define name="csd-standard">
98
98
  <element name="csd-standard">
99
+ <attribute name="version"/>
100
+ <attribute name="type">
101
+ <choice>
102
+ <value>semantic</value>
103
+ <value>presentation</value>
104
+ </choice>
105
+ </attribute>
99
106
  <ref name="bibdata"/>
100
107
  <zeroOrMore>
101
108
  <ref name="termdocsource"/>
@@ -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">
@@ -61,6 +64,11 @@
61
64
  </choice>
62
65
  </attribute>
63
66
  </optional>
67
+ <optional>
68
+ <attribute name="droploc">
69
+ <data type="boolean"/>
70
+ </attribute>
71
+ </optional>
64
72
  <text/>
65
73
  </element>
66
74
  </define>
@@ -578,6 +586,8 @@
578
586
  <ref name="ol"/>
579
587
  <ref name="dl"/>
580
588
  <ref name="formula"/>
589
+ <ref name="quote"/>
590
+ <ref name="sourcecode"/>
581
591
  </choice>
582
592
  </oneOrMore>
583
593
  </element>
@@ -661,6 +671,16 @@
661
671
  </choice>
662
672
  </attribute>
663
673
  </optional>
674
+ <optional>
675
+ <attribute name="valign">
676
+ <choice>
677
+ <value>top</value>
678
+ <value>middle</value>
679
+ <value>bottom</value>
680
+ <value>baseline</value>
681
+ </choice>
682
+ </attribute>
683
+ </optional>
664
684
  <choice>
665
685
  <zeroOrMore>
666
686
  <choice>
@@ -697,6 +717,16 @@
697
717
  </choice>
698
718
  </attribute>
699
719
  </optional>
720
+ <optional>
721
+ <attribute name="valign">
722
+ <choice>
723
+ <value>top</value>
724
+ <value>middle</value>
725
+ <value>bottom</value>
726
+ <value>baseline</value>
727
+ </choice>
728
+ </attribute>
729
+ </optional>
700
730
  <choice>
701
731
  <zeroOrMore>
702
732
  <choice>
@@ -834,6 +864,13 @@
834
864
  </define>
835
865
  <define name="standard-document">
836
866
  <element name="standard-document">
867
+ <attribute name="version"/>
868
+ <attribute name="type">
869
+ <choice>
870
+ <value>semantic</value>
871
+ <value>presentation</value>
872
+ </choice>
873
+ </attribute>
837
874
  <ref name="bibdata"/>
838
875
  <optional>
839
876
  <ref name="boilerplate"/>
@@ -855,7 +892,7 @@
855
892
  <oneOrMore>
856
893
  <choice>
857
894
  <ref name="content"/>
858
- <ref name="preface_abstract"/>
895
+ <ref name="abstract"/>
859
896
  <ref name="foreword"/>
860
897
  <ref name="introduction"/>
861
898
  <ref name="acknowledgements"/>
@@ -922,6 +959,9 @@
922
959
  <optional>
923
960
  <attribute name="script"/>
924
961
  </optional>
962
+ <optional>
963
+ <attribute name="type"/>
964
+ </optional>
925
965
  <optional>
926
966
  <attribute name="obligation">
927
967
  <choice>
@@ -961,9 +1001,6 @@
961
1001
  </define>
962
1002
  <define name="content-subsection">
963
1003
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
1004
  <ref name="Content-Section"/>
968
1005
  </element>
969
1006
  </define>
@@ -992,6 +1029,9 @@
992
1029
  </choice>
993
1030
  </attribute>
994
1031
  </optional>
1032
+ <optional>
1033
+ <attribute name="type"/>
1034
+ </optional>
995
1035
  <optional>
996
1036
  <ref name="section-title"/>
997
1037
  </optional>
@@ -1011,9 +1051,6 @@
1011
1051
  </define>
1012
1052
  <define name="clause">
1013
1053
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1054
  <ref name="Clause-Section"/>
1018
1055
  </element>
1019
1056
  </define>
@@ -1042,18 +1079,24 @@
1042
1079
  </choice>
1043
1080
  </attribute>
1044
1081
  </optional>
1082
+ <optional>
1083
+ <attribute name="type"/>
1084
+ </optional>
1045
1085
  <optional>
1046
1086
  <ref name="section-title"/>
1047
1087
  </optional>
1048
1088
  <group>
1049
- <group>
1050
- <zeroOrMore>
1051
- <ref name="BasicBlock"/>
1052
- </zeroOrMore>
1053
- <zeroOrMore>
1054
- <ref name="note"/>
1055
- </zeroOrMore>
1056
- </group>
1089
+ <choice>
1090
+ <group>
1091
+ <zeroOrMore>
1092
+ <ref name="BasicBlock"/>
1093
+ </zeroOrMore>
1094
+ <zeroOrMore>
1095
+ <ref name="note"/>
1096
+ </zeroOrMore>
1097
+ </group>
1098
+ <ref name="amend"/>
1099
+ </choice>
1057
1100
  <zeroOrMore>
1058
1101
  <choice>
1059
1102
  <ref name="clause-subsection"/>
@@ -1180,6 +1223,9 @@
1180
1223
  <optional>
1181
1224
  <attribute name="script"/>
1182
1225
  </optional>
1226
+ <optional>
1227
+ <attribute name="type"/>
1228
+ </optional>
1183
1229
  <optional>
1184
1230
  <attribute name="obligation">
1185
1231
  <choice>
@@ -1447,11 +1493,6 @@
1447
1493
  </optional>
1448
1494
  </element>
1449
1495
  </define>
1450
- <define name="preface_abstract">
1451
- <element name="abstract">
1452
- <ref name="Basic-Section"/>
1453
- </element>
1454
- </define>
1455
1496
  <define name="term-clause">
1456
1497
  <element name="clause">
1457
1498
  <optional>
@@ -1501,4 +1542,79 @@
1501
1542
  <ref name="CitationType"/>
1502
1543
  </element>
1503
1544
  </define>
1545
+ <define name="amend">
1546
+ <element name="amend">
1547
+ <optional>
1548
+ <attribute name="id">
1549
+ <data type="ID"/>
1550
+ </attribute>
1551
+ </optional>
1552
+ <attribute name="change">
1553
+ <choice>
1554
+ <value>add</value>
1555
+ <value>modify</value>
1556
+ <value>delete</value>
1557
+ </choice>
1558
+ </attribute>
1559
+ <optional>
1560
+ <attribute name="path"/>
1561
+ </optional>
1562
+ <optional>
1563
+ <attribute name="path_end"/>
1564
+ </optional>
1565
+ <optional>
1566
+ <attribute name="title"/>
1567
+ </optional>
1568
+ <optional>
1569
+ <element name="location">
1570
+ <zeroOrMore>
1571
+ <ref name="locality"/>
1572
+ </zeroOrMore>
1573
+ </element>
1574
+ </optional>
1575
+ <zeroOrMore>
1576
+ <ref name="autonumber"/>
1577
+ </zeroOrMore>
1578
+ <optional>
1579
+ <element name="description">
1580
+ <zeroOrMore>
1581
+ <ref name="BasicBlock"/>
1582
+ </zeroOrMore>
1583
+ </element>
1584
+ </optional>
1585
+ <optional>
1586
+ <element name="newcontent">
1587
+ <zeroOrMore>
1588
+ <ref name="BasicBlock"/>
1589
+ </zeroOrMore>
1590
+ </element>
1591
+ </optional>
1592
+ <optional>
1593
+ <element name="description">
1594
+ <zeroOrMore>
1595
+ <ref name="BasicBlock"/>
1596
+ </zeroOrMore>
1597
+ </element>
1598
+ </optional>
1599
+ </element>
1600
+ </define>
1601
+ <define name="autonumber">
1602
+ <element name="autonumber">
1603
+ <attribute name="type">
1604
+ <choice>
1605
+ <value>requirement</value>
1606
+ <value>recommendation</value>
1607
+ <value>permission</value>
1608
+ <value>table</value>
1609
+ <value>figure</value>
1610
+ <value>admonition</value>
1611
+ <value>formula</value>
1612
+ <value>sourcecode</value>
1613
+ <value>example</value>
1614
+ <value>note</value>
1615
+ </choice>
1616
+ </attribute>
1617
+ <text/>
1618
+ </element>
1619
+ </define>
1504
1620
  </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")