metanorma-mpfa 0.4.2 → 0.5.3

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: 1f5b3ae953cf84b4ba03366b96d6860178314c9b211c5abeffcafc0c9fb64045
4
- data.tar.gz: 993f3b9dc13726cd5f5de441a7566227350a62982b5f0cca07b342398972c956
3
+ metadata.gz: ae4dfa96623980717b0d0aa5cab95bb85b8e2783cc3f2f7d150bfbd935fc9f34
4
+ data.tar.gz: 8821d201deb2309b37fa71a1dd11201fe40e4341302750209d22cd1972f6f081
5
5
  SHA512:
6
- metadata.gz: e830fa528259968685e92f3995de5ef147f94db7a6fd2f5f12ea9bcd6b00bdf7efb5fe3c93781e75caf676db03cb3e02d1cb9485db58e9e838e64238f2fd693a
7
- data.tar.gz: f89dd9ec2351bf1faf272c684294a3242beaa26c53a2e31da6e2583b8f554537c1215cacb9d35c76fa80c90f4be3a65d2cf4a2060f9d0bb941872ae7b8333d54
6
+ metadata.gz: 360c28eb4430f1decbf67e28afa792958ae2bb191757efc1e11259e64000e86d926c35c082313357c65d120e27d2ac3e1c2224b522b9275c5572310e3b39aec3
7
+ data.tar.gz: 2d6839910d73e8da3b1b7549cc4baffbddb347695acff7619f361f4c4660848bfa3389d4c23da945ac6567097130bcba959752db0b1570cdd0dfd867bbaa4148
@@ -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"/>
@@ -19,24 +19,8 @@ module Asciidoctor
19
19
 
20
20
  register_for "mpfa"
21
21
 
22
- def metadata_author(node, xml)
23
- xml.contributor do |c|
24
- c.role **{ type: "author" }
25
- c.organization do |a|
26
- a.name "Mandatory Provident Fund Schemes Authority"
27
- a.abbreviation "MPFA"
28
- end
29
- end
30
- end
31
-
32
- def metadata_publisher(node, xml)
33
- xml.contributor do |c|
34
- c.role **{ type: "publisher" }
35
- c.organization do |a|
36
- a.name "Mandatory Provident Fund Schemes Authority"
37
- a.abbreviation "MPFA"
38
- end
39
- end
22
+ def default_publisher
23
+ "Mandatory Provident Fund Schemes Authority"
40
24
  end
41
25
 
42
26
  def metadata_committee(node, xml)
@@ -58,19 +42,6 @@ module Asciidoctor
58
42
  xml.docnumber { |i| i << node.attr("docnumber") }
59
43
  end
60
44
 
61
- def metadata_copyright(node, xml)
62
- from = node.attr("copyright-year") || Date.today.year
63
- xml.copyright do |c|
64
- c.from from
65
- c.owner do |owner|
66
- owner.organization do |o|
67
- o.name "Mandatory Provident Fund Schemes Authority"
68
- o.abbreviation "MPFA"
69
- end
70
- end
71
- end
72
- end
73
-
74
45
  def title_validate(root)
75
46
  nil
76
47
  end
@@ -85,6 +56,7 @@ module Asciidoctor
85
56
  presentation_xml_converter(node).convert(@filename + ".xml")
86
57
  html_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.html")
87
58
  doc_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.doc")
59
+ pdf_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.doc")
88
60
  end
89
61
 
90
62
  def validate(doc)
@@ -108,6 +80,10 @@ module Asciidoctor
108
80
  def doc_converter(node)
109
81
  IsoDoc::MPFA::WordConvert.new(doc_extract_attributes(node))
110
82
  end
83
+
84
+ def pdf_converter(node)
85
+ IsoDoc::MPFA::PdfConvert.new(doc_extract_attributes(node))
86
+ end
111
87
  end
112
88
  end
113
89
  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>
@@ -58,7 +58,6 @@ module Asciidoctor
58
58
  attrs[:container] = true if node.role == "container"
59
59
  super
60
60
  end
61
-
62
61
  end
63
62
  end
64
63
  end
@@ -1,51 +1,9 @@
1
1
  require "isodoc"
2
- require_relative "metadata"
3
- require_relative "xref"
4
2
  require "fileutils"
5
3
 
6
4
  module IsoDoc
7
5
  module MPFA
8
6
  module BaseConvert
9
- def metadata_init(lang, script, labels)
10
- @meta = Metadata.new(lang, script, labels)
11
- end
12
-
13
- def xref_init(lang, script, klass, labels, options)
14
- @xrefs = Xref.new(lang, script, klass, labels, options)
15
- end
16
-
17
- def annex_name(annex, name, div)
18
- div.h1 **{ class: "Annex" } do |t|
19
- t << "#{@xrefs.anchor(annex['id'], :label)} "
20
- t.b do |b|
21
- name&.children&.each { |c2| parse(c2, b) }
22
- end
23
- end
24
- end
25
-
26
- def fileloc(loc)
27
- File.join(File.dirname(__FILE__), loc)
28
- end
29
-
30
- def i18n_init(lang, script)
31
- super
32
- y = if lang == "en"
33
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
34
- elsif lang == "zh" && script == "Hans"
35
- YAML.load_file(File.join(File.dirname(__FILE__),
36
- "i18n-zh-Hans.yaml"))
37
- else
38
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
39
- end
40
- @labels = @labels.merge(y)
41
- @annex_lbl = y["annex"]
42
- @clause_lbl = y["clause"]
43
- end
44
-
45
- def terms_defs_title(f)
46
- return f&.at(ns("./title"))&.content
47
- end
48
-
49
7
  TERM_CLAUSE = "//preface/terms | "\
50
8
  "//preface/clause[descendant::terms]".freeze
51
9
 
@@ -57,7 +15,7 @@ module IsoDoc
57
15
  def terms_defs(isoxml, out, num)
58
16
  f = isoxml.at(ns(self.class::TERM_CLAUSE)) or return num
59
17
  out.div **attr_code(id: f["id"]) do |div|
60
- clause_name(nil, terms_defs_title(f), div, nil)
18
+ clause_name(nil, f&.at(ns("./title")), div, nil)
61
19
  f.elements.each do |e|
62
20
  parse(e, div) unless %w{title source}.include? e.name
63
21
  end
@@ -70,10 +28,10 @@ module IsoDoc
70
28
  def preface(isoxml, out)
71
29
  isoxml.xpath(ns(self.class::FRONT_CLAUSE)).each do |c|
72
30
  if c.name == "terms" || c.at(ns(".//terms")) then terms_defs isoxml, out, 0
31
+ elsif !is_clause?(c.name) then parse(c, out)
73
32
  else
74
33
  out.div **attr_code(id: c["id"]) do |s|
75
- clause_name(@xrefs.anchor(c['id'], :label),
76
- c&.at(ns("./title"))&.content, s, nil)
34
+ clause_name(nil, c&.at(ns("./title")), s, nil)
77
35
  c.elements.reject { |c1| c1.name == "title" }.each do |c1|
78
36
  parse(c1, s)
79
37
  end
@@ -82,6 +40,10 @@ module IsoDoc
82
40
  end
83
41
  end
84
42
 
43
+ def middle_clause
44
+ "//clause[parent::sections][not(descendant::terms)]"
45
+ end
46
+
85
47
  def middle(isoxml, out)
86
48
  middle_title(out)
87
49
  middle_admonitions(isoxml, out)
@@ -91,6 +53,7 @@ module IsoDoc
91
53
  end
92
54
 
93
55
  def termdef_parse(node, out)
56
+ name = node&.at(ns("./name"))&.remove
94
57
  set_termdomain("")
95
58
  node.children.each { |n| parse(n, out) }
96
59
  end
@@ -98,8 +61,8 @@ module IsoDoc
98
61
  def clause(isoxml, out)
99
62
  isoxml.xpath(ns(middle_clause)).each do |c|
100
63
  out.div **attr_code(id: c["id"]) do |s|
101
- clause_name(@xrefs.anchor(c['id'], :label),
102
- c&.at(ns("./title"))&.content, s, class: c["container"] ? "containerhdr" : nil )
64
+ clause_name(nil, c&.at(ns("./title")), s,
65
+ class: c["container"] ? "containerhdr" : nil )
103
66
  c.elements.reject { |c1| c1.name == "title" }.each do |c1|
104
67
  parse(c1, s)
105
68
  end
@@ -107,17 +70,11 @@ module IsoDoc
107
70
  end
108
71
  end
109
72
 
110
- def clause_parse_title(node, div, c1, out)
111
- if node["inline-header"] == "true"
112
- inline_header_title(out, node, c1)
113
- else
114
- attrs = { class: node["container"] ? "containerhdr" : nil }
115
- div.send "h#{@xrefs.anchor(node['id'], :level, :false) || '1'}", **attr_code(attrs) do |h|
116
- lbl = @xrefs.anchor(node['id'], :label, false)
117
- h << "#{lbl}. " if lbl && !@suppressheadingnumbers
118
- c1&.children&.each { |c2| parse(c2, h) }
119
- end
120
- end
73
+ def clause_parse_title(node, div, c1, out, header_class = {})
74
+ attrs = {}
75
+ attrs = { class: "containerhdr" } if node["container"]
76
+ header_class = header_class.merge(attrs)
77
+ super
121
78
  end
122
79
 
123
80
  def ol_depth(node)