metanorma-bsi 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of metanorma-bsi might be problematic. Click here for more details.

Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +43 -0
  3. data/.github/workflows/release_github_packages.yml +49 -0
  4. data/.hound.yml +3 -1
  5. data/.rubocop.yml +4 -8
  6. data/README.adoc +95 -11
  7. data/lib/asciidoctor/bsi/biblio.rng +1 -0
  8. data/lib/asciidoctor/bsi/bsi.rng +32 -4
  9. data/lib/asciidoctor/bsi/bsi_intro_en.xml +87 -61
  10. data/lib/asciidoctor/bsi/cleanup.rb +15 -8
  11. data/lib/asciidoctor/bsi/cleanup_ref.rb +10 -21
  12. data/lib/asciidoctor/bsi/converter.rb +7 -5
  13. data/lib/asciidoctor/bsi/front.rb +26 -5
  14. data/lib/asciidoctor/bsi/isodoc.rng +191 -3
  15. data/lib/asciidoctor/bsi/isostandard.rng +12 -0
  16. data/lib/asciidoctor/bsi/validate.rb +5 -6
  17. data/lib/asciidoctor/bsi/validate_list.rb +2 -2
  18. data/lib/isodoc/bsi/base_convert.rb +2 -1
  19. data/lib/isodoc/bsi/bsi.international-standard.xsl +3380 -2349
  20. data/lib/isodoc/bsi/html/htmlstyle.css +43 -22
  21. data/lib/isodoc/bsi/html/htmlstyle.scss +46 -22
  22. data/lib/isodoc/bsi/html_convert.rb +2 -2
  23. data/lib/isodoc/bsi/i18n-en.yaml +4 -4
  24. data/lib/isodoc/bsi/metadata.rb +2 -2
  25. data/lib/isodoc/bsi/presentation_xml_convert.rb +26 -5
  26. data/lib/isodoc/bsi/xref.rb +11 -4
  27. data/lib/metanorma/bsi/version.rb +1 -1
  28. data/metanorma-bsi.gemspec +2 -2
  29. data/spec/asciidoctor/base_spec.rb +564 -494
  30. data/spec/asciidoctor/blocks_spec.rb +192 -195
  31. data/spec/asciidoctor/cleanup_spec.rb +361 -361
  32. data/spec/asciidoctor/refs_spec.rb +8 -78
  33. data/spec/asciidoctor/section_spec.rb +227 -227
  34. data/spec/asciidoctor/validate_spec.rb +26 -1
  35. data/spec/isodoc/blocks_spec.rb +56 -21
  36. data/spec/isodoc/i18n_spec.rb +156 -234
  37. data/spec/isodoc/inline_spec.rb +7 -7
  38. data/spec/isodoc/iso_spec.rb +4 -4
  39. data/spec/isodoc/metadata_spec.rb +0 -1
  40. data/spec/isodoc/ref_spec.rb +7 -7
  41. data/spec/isodoc/section_spec.rb +400 -343
  42. data/spec/isodoc/terms_spec.rb +224 -225
  43. data/spec/isodoc/xref_spec.rb +1347 -1360
  44. data/spec/metanorma/processor_spec.rb +37 -40
  45. data/spec/spec_helper.rb +6 -4
  46. data/spec/vcr_cassettes/iso-639.yml +19 -19
  47. data/spec/vcr_cassettes/isobib_get_639_1967.yml +17 -17
  48. data/spec/vcr_cassettes/multistandard.yml +15 -193
  49. metadata +7 -5
@@ -22,16 +22,18 @@ module Asciidoctor
22
22
 
23
23
  def note(node)
24
24
  return commentary(node) if node.attr("type") == "commentary"
25
+
25
26
  super
26
27
  end
27
28
 
28
29
  def commentary_attrs(node)
30
+ b = node.attr("beforeclauses") == "true" ? "true" : nil
29
31
  attr_code(keep_attrs(node).merge(
30
- id: Metanorma::Utils::anchor_or_uuid(node),
31
- type: "commentary",
32
- target: node.attr("target"),
33
- beforeclauses: node.attr("beforeclauses") == "true" ? "true" : nil
34
- ))
32
+ id: Metanorma::Utils::anchor_or_uuid(node),
33
+ type: "commentary",
34
+ target: node.attr("target"),
35
+ beforeclauses: b,
36
+ ))
35
37
  end
36
38
 
37
39
  def commentary(node)
@@ -2,7 +2,7 @@ module Asciidoctor
2
2
  module BSI
3
3
  class Converter < ISO::Converter
4
4
  def org_abbrev
5
- super.merge("British Standards Institute" => "BSI")
5
+ super.merge("British Standards Institution" => "BSI")
6
6
  end
7
7
 
8
8
  def metadata_author(node, xml)
@@ -11,7 +11,7 @@ module Asciidoctor
11
11
  xml.contributor do |c|
12
12
  c.role **{ type: "author" }
13
13
  c.organization do |a|
14
- organization(a, p, node, !node.attr("publisher"))
14
+ organization(a, p, false, node, !node.attr("publisher"))
15
15
  end
16
16
  end
17
17
  end
@@ -23,7 +23,7 @@ module Asciidoctor
23
23
  xml.contributor do |c|
24
24
  c.role **{ type: "publisher" }
25
25
  c.organization do |a|
26
- organization(a, p, node, !node.attr("publisher"))
26
+ organization(a, p, true, node, !node.attr("publisher"))
27
27
  end
28
28
  end
29
29
  end
@@ -36,7 +36,7 @@ module Asciidoctor
36
36
  c.from (node.attr("copyright-year") || Date.today.year)
37
37
  c.owner do |owner|
38
38
  owner.organization do |o|
39
- organization(o, p, node, !node.attr("copyright-holder") ||
39
+ organization(o, p, true, node, !node.attr("copyright-holder") ||
40
40
  node.attr("publisher"))
41
41
  end
42
42
  end
@@ -58,7 +58,28 @@ module Asciidoctor
58
58
  end
59
59
 
60
60
  def relaton_relations
61
- super + %w(obsoletes adopted-from)
61
+ super + %w(obsoletes adopted-from bsi-related)
62
+ end
63
+
64
+ def get_typeabbr(node, amd = false)
65
+ case doctype(node)
66
+ when "publicly-available-specification" then "PAS "
67
+ when "british-standard" then "BS "
68
+ when "draft-for-development" then "DD "
69
+ when "privately-subscribed-standard" then "PSS "
70
+ when "flex-standard" then "Flex "
71
+ else
72
+ super
73
+ end
74
+ end
75
+
76
+ def id_stage_abbr(stage, substage, node, bare = false)
77
+ ret = super
78
+ if %w(publicly-available-specification).include?(doctype(node)) &&
79
+ !%w(D FD).include?(ret)
80
+ ret = "#{ret} "
81
+ end
82
+ ret
62
83
  end
63
84
 
64
85
  # TODO: not yet implemented prefixes for subsectors explicitly, Rules for Structure Annex F
@@ -45,6 +45,11 @@
45
45
  <optional>
46
46
  <attribute name="alt"/>
47
47
  </optional>
48
+ <optional>
49
+ <attribute name="updatetype">
50
+ <data type="boolean"/>
51
+ </attribute>
52
+ </optional>
48
53
  <text/>
49
54
  </element>
50
55
  </define>
@@ -543,6 +548,9 @@
543
548
  </define>
544
549
  <define name="BibDataExtensionType">
545
550
  <ref name="doctype"/>
551
+ <optional>
552
+ <ref name="docsubtype"/>
553
+ </optional>
546
554
  <optional>
547
555
  <ref name="editorialgroup"/>
548
556
  </optional>
@@ -876,8 +884,28 @@
876
884
  </zeroOrMore>
877
885
  </element>
878
886
  </define>
887
+ <define name="pagebreak">
888
+ <element name="pagebreak">
889
+ <optional>
890
+ <attribute name="orientation">
891
+ <choice>
892
+ <value>landscape</value>
893
+ <value>portrait</value>
894
+ </choice>
895
+ </attribute>
896
+ </optional>
897
+ </element>
898
+ </define>
879
899
  </include>
880
900
  <!-- end overrides -->
901
+ <define name="docsubtype">
902
+ <element name="docsubtype">
903
+ <ref name="DocumentSubtype"/>
904
+ </element>
905
+ </define>
906
+ <define name="DocumentSubtype">
907
+ <text/>
908
+ </define>
881
909
  <define name="colgroup">
882
910
  <element name="colgroup">
883
911
  <oneOrMore>
@@ -943,8 +971,170 @@
943
971
  <ref name="permission"/>
944
972
  <ref name="imagemap"/>
945
973
  <ref name="svgmap"/>
974
+ <ref name="inputform"/>
975
+ </choice>
976
+ </define>
977
+ <define name="inputform">
978
+ <element name="form">
979
+ <attribute name="id">
980
+ <data type="ID"/>
981
+ </attribute>
982
+ <attribute name="name"/>
983
+ <attribute name="action"/>
984
+ <zeroOrMore>
985
+ <choice>
986
+ <ref name="TextElement"/>
987
+ <ref name="FormInput"/>
988
+ </choice>
989
+ </zeroOrMore>
990
+ </element>
991
+ </define>
992
+ <define name="FormInput">
993
+ <choice>
994
+ <ref name="input"/>
995
+ <ref name="formlabel"/>
996
+ <ref name="select"/>
997
+ <ref name="textarea"/>
998
+ </choice>
999
+ </define>
1000
+ <define name="InputType">
1001
+ <choice>
1002
+ <value>button</value>
1003
+ <value>checkbox</value>
1004
+ <value>date</value>
1005
+ <value>file</value>
1006
+ <value>password</value>
1007
+ <value>radio</value>
1008
+ <value>submit</value>
1009
+ <value>text</value>
946
1010
  </choice>
947
1011
  </define>
1012
+ <define name="input">
1013
+ <element name="input">
1014
+ <attribute name="type">
1015
+ <ref name="InputType"/>
1016
+ </attribute>
1017
+ <optional>
1018
+ <attribute name="checked">
1019
+ <data type="boolean"/>
1020
+ </attribute>
1021
+ </optional>
1022
+ <optional>
1023
+ <attribute name="disabled">
1024
+ <data type="boolean"/>
1025
+ </attribute>
1026
+ </optional>
1027
+ <optional>
1028
+ <attribute name="readonly">
1029
+ <data type="boolean"/>
1030
+ </attribute>
1031
+ </optional>
1032
+ <optional>
1033
+ <attribute name="maxlength">
1034
+ <data type="int"/>
1035
+ </attribute>
1036
+ </optional>
1037
+ <optional>
1038
+ <attribute name="minlength">
1039
+ <data type="int"/>
1040
+ </attribute>
1041
+ </optional>
1042
+ <optional>
1043
+ <attribute name="name"/>
1044
+ </optional>
1045
+ <optional>
1046
+ <attribute name="value"/>
1047
+ </optional>
1048
+ <optional>
1049
+ <attribute name="id">
1050
+ <data type="ID"/>
1051
+ </attribute>
1052
+ </optional>
1053
+ </element>
1054
+ </define>
1055
+ <define name="formlabel">
1056
+ <element name="label">
1057
+ <attribute name="for">
1058
+ <data type="IDREF"/>
1059
+ </attribute>
1060
+ <zeroOrMore>
1061
+ <ref name="PureTextElement"/>
1062
+ </zeroOrMore>
1063
+ </element>
1064
+ </define>
1065
+ <define name="select">
1066
+ <element name="select">
1067
+ <optional>
1068
+ <attribute name="name"/>
1069
+ </optional>
1070
+ <optional>
1071
+ <attribute name="value"/>
1072
+ </optional>
1073
+ <optional>
1074
+ <attribute name="id">
1075
+ <data type="ID"/>
1076
+ </attribute>
1077
+ </optional>
1078
+ <optional>
1079
+ <attribute name="disabled">
1080
+ <data type="boolean"/>
1081
+ </attribute>
1082
+ </optional>
1083
+ <optional>
1084
+ <attribute name="multiple">
1085
+ <data type="boolean"/>
1086
+ </attribute>
1087
+ </optional>
1088
+ <optional>
1089
+ <attribute name="size">
1090
+ <data type="int"/>
1091
+ </attribute>
1092
+ </optional>
1093
+ <oneOrMore>
1094
+ <ref name="option"/>
1095
+ </oneOrMore>
1096
+ </element>
1097
+ </define>
1098
+ <define name="option">
1099
+ <element name="option">
1100
+ <optional>
1101
+ <attribute name="disabled">
1102
+ <data type="boolean"/>
1103
+ </attribute>
1104
+ </optional>
1105
+ <optional>
1106
+ <attribute name="value"/>
1107
+ </optional>
1108
+ <zeroOrMore>
1109
+ <ref name="PureTextElement"/>
1110
+ </zeroOrMore>
1111
+ </element>
1112
+ </define>
1113
+ <define name="textarea">
1114
+ <element name="textarea">
1115
+ <optional>
1116
+ <attribute name="name"/>
1117
+ </optional>
1118
+ <optional>
1119
+ <attribute name="value"/>
1120
+ </optional>
1121
+ <optional>
1122
+ <attribute name="id">
1123
+ <data type="ID"/>
1124
+ </attribute>
1125
+ </optional>
1126
+ <optional>
1127
+ <attribute name="rows">
1128
+ <data type="int"/>
1129
+ </attribute>
1130
+ </optional>
1131
+ <optional>
1132
+ <attribute name="cols">
1133
+ <data type="int"/>
1134
+ </attribute>
1135
+ </optional>
1136
+ </element>
1137
+ </define>
948
1138
  <define name="bibliography">
949
1139
  <element name="bibliography">
950
1140
  <oneOrMore>
@@ -1017,9 +1207,7 @@
1017
1207
  </define>
1018
1208
  <define name="IsoWorkgroup">
1019
1209
  <optional>
1020
- <attribute name="number">
1021
- <data type="int"/>
1022
- </attribute>
1210
+ <attribute name="number"/>
1023
1211
  </optional>
1024
1212
  <optional>
1025
1213
  <attribute name="type"/>
@@ -38,6 +38,9 @@
38
38
  </define>
39
39
  <define name="BibDataExtensionType">
40
40
  <ref name="doctype"/>
41
+ <optional>
42
+ <ref name="docsubtype"/>
43
+ </optional>
41
44
  <optional>
42
45
  <ref name="horizontal"/>
43
46
  </optional>
@@ -256,6 +259,15 @@
256
259
  <value>guide</value>
257
260
  <value>amendment</value>
258
261
  <value>technical-corrigendum</value>
262
+ <value>directive</value>
263
+ </choice>
264
+ </define>
265
+ <define name="DocumentSubtype">
266
+ <choice>
267
+ <value>specification</value>
268
+ <value>method-of-test</value>
269
+ <value>vocabulary</value>
270
+ <value>code-of-practice</value>
259
271
  </choice>
260
272
  </define>
261
273
  <define name="structuredidentifier">
@@ -105,10 +105,10 @@ module Asciidoctor
105
105
  # Rules for Structure 20.4
106
106
  def annex_ordering_validate(root)
107
107
  ids = citation_order(root.xpath("//annex"))
108
- cite_order = ids.keys.sort { |a, b| ids[a] <=> ids[b] }
108
+ cite_order = ids.keys.sort_by { |a| ids[a] || 999999 }
109
109
  annex_order = root.xpath("//annex").map { |x| x["id"] }
110
110
  cite_order.each_with_index do |a, i|
111
- next if annex_order[i] == a
111
+ next if annex_order[i] == a || ids[a].nil?
112
112
 
113
113
  annex = root.at("//annex[@id = '#{a}']")
114
114
  title = annex&.at("./title")&.text || "Annex #{a}"
@@ -134,10 +134,9 @@ module Asciidoctor
134
134
  /^9.$/.match?(status) and
135
135
  @log.add("Style", b,
136
136
  "Do not cite withdrawn standards as normative: #{b.text}")
137
- /^[0-5].$/.match?(status) and @log.add(
138
- "Style", b,
139
- "Do not cite unpublished standards as normative: #{b.text}"
140
- )
137
+ /^[0-5].$/.match?(status) and
138
+ @log.add("Style", b, "Do not cite unpublished standards "\
139
+ "as normative: #{b.text}")
141
140
  end
142
141
  end
143
142
 
@@ -25,13 +25,13 @@ module Asciidoctor
25
25
  prec&.name == "p" or
26
26
  style_warning(list, "All lists must be preceded by "\
27
27
  "introductory phrase", nil)
28
- list_punctuation1(list, prec.text)
28
+ list_punctuation1(list, prec&.text)
29
29
  end
30
30
  end
31
31
 
32
32
  def list_punctuation1(list, prectext)
33
33
  entries = list.xpath(".//li")
34
- case prectext.sub(/^.*?(\S)\s*$/, "\\1")
34
+ case prectext&.sub(/^.*?(\S)\s*$/, "\\1")
35
35
  when ":"
36
36
  list.xpath(".//li").each_with_index do |li, i|
37
37
  list_semicolon_phrase(li, i == entries.size - 1)
@@ -66,7 +66,8 @@ module IsoDoc
66
66
  end
67
67
 
68
68
  def admonition_parse(node, div)
69
- commentary_parse(node, div) if node["type"] == "commentary"
69
+ return commentary_parse(node, div) if node["type"] == "commentary"
70
+
70
71
  super
71
72
  end
72
73