metanorma-mpfa 0.4.3 → 0.5.4

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: abb98fbac9c5a7d876d28998843e605d2a89c60028506ebea161b7d753b36df7
4
- data.tar.gz: 26b7e35bfa14f05b62347a094f6098e3ecab134ae54c9a935cc3f22fcdec536a
3
+ metadata.gz: 8dcb7661da4f2fcbfb39f502092f2bf7ebb0600931d4af01b4afc47f6ba07cda
4
+ data.tar.gz: cc08933866ff4413dbe87680e7663eb68a17d31c9ae9c334d285a0255de738d9
5
5
  SHA512:
6
- metadata.gz: ff249a97cd6c2998204cc99cc35a290292971c7b146c7d3e25bc090b6851cbe07e91b999f80e824a4c662225b85de2f5231fea36f23563670e35bcef0435716d
7
- data.tar.gz: 8d9750fb688092b1934068e4afa8b73c584b904f57f5a9e6f0d3b95fe25d6d9a0177b590921d50c1bb5cfec76c8ed73bd0d6503139c396ce56c2053211d954e0
6
+ metadata.gz: e4dae79748378fc5be7e487e49bd398b3a0cf6fed4ffb8f1942adfb904c3e95ba8b73224fe66eb1505a753ab56b46c1fd00deafe20ec137e9b29f43be907e465
7
+ data.tar.gz: 99c560df54d0530e2a11f3ef9a2156aea1a1d10e06abd7183e174b40cc845b67cd4bb55c7835cc364328b83b211bafa7cf5eb0ca670fdc7bc297c7b6593ef488
@@ -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>
@@ -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">
@@ -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>
@@ -59,6 +59,13 @@
59
59
  </define>
60
60
  <define name="mpfd-standard">
61
61
  <element name="mpfd-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"/>
@@ -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)