metanorma-bipm 2.4.0 → 2.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,89 @@
1
+ module Metanorma
2
+ module BIPM
3
+ class Converter < Metanorma::Generic::Converter
4
+ def boilerplate_file(_xmldoc)
5
+ if @jcgm
6
+ File.join(File.dirname(__FILE__), "boilerplate-jcgm-en.adoc")
7
+ else
8
+ File.join(File.dirname(__FILE__), "boilerplate-#{@lang}.adoc")
9
+ end
10
+ end
11
+
12
+ def sections_cleanup(xml)
13
+ super
14
+ jcgm_untitled_sections_cleanup(xml) if @jcgm
15
+ end
16
+
17
+ def jcgm_untitled_sections_cleanup(xml)
18
+ xml.xpath("//clause//clause | //annex//clause | //introduction/clause")
19
+ .each do |c|
20
+ next if !c&.at("./title")&.text&.empty?
21
+
22
+ c["inline-header"] = true
23
+ end
24
+ end
25
+
26
+ def section_names_terms_cleanup(xml); end
27
+
28
+ def section_names_refs_cleanup(xml); end
29
+
30
+ def mathml_mi_italics
31
+ { uppergreek: false, upperroman: false,
32
+ lowergreek: false, lowerroman: true }
33
+ end
34
+
35
+ def xref_to_eref(elem, name)
36
+ if elem.at("//bibitem[@id = '#{elem['target']}']/" \
37
+ "docidentifier[@type = 'BIPM-long']")
38
+ elem["style"] = "BIPM-long"
39
+ end
40
+ super
41
+ end
42
+
43
+ ID_LABELS = {
44
+ "en" => {
45
+ "appendix" => "Appendix",
46
+ "annexid" => "Annex",
47
+ "part" => "Part",
48
+ },
49
+ "fr" => {
50
+ "appendix" => "Annexe",
51
+ "annexid" => "Appendice",
52
+ "part" => "Partie",
53
+ },
54
+ }.freeze
55
+
56
+ def bibdata_docidentifier_cleanup(isoxml)
57
+ bibdata_docidentifier_i18n(isoxml)
58
+ super
59
+ end
60
+
61
+ def bibdata_docidentifier_i18n(isoxml)
62
+ id, parts = bibdata_docidentifier_i18n_prep(isoxml)
63
+ parts.empty? and return
64
+ id_alt = id.dup
65
+ id.next = id_alt
66
+ bibdata_docidentifier_enhance(id, @lang, parts)
67
+ bibdata_docidentifier_enhance(id_alt, @lang == "en" ? "fr" : "en",
68
+ parts)
69
+ end
70
+
71
+ def bibdata_docidentifier_i18n_prep(isoxml)
72
+ id = isoxml.at("//bibdata/docidentifier[@type = 'BIPM']")
73
+ parts = %w(appendix annexid part).each_with_object({}) do |w, m|
74
+ dn = isoxml.at("//bibdata/ext/structuredidentifier/#{w}") and
75
+ m[w] = dn.text
76
+ end
77
+ [id, parts]
78
+ end
79
+
80
+ def bibdata_docidentifier_enhance(id, lang, parts)
81
+ id["language"] = lang
82
+ ret = %w(appendix annexid part).each_with_object([]) do |w, m|
83
+ p = parts[w] and m << "#{ID_LABELS[lang][w]} #{p}"
84
+ end
85
+ id.children = "#{id.text} #{ret.join(' ')}"
86
+ end
87
+ end
88
+ end
89
+ end
@@ -1,6 +1,7 @@
1
1
  require "metanorma/standoc/converter"
2
2
  require "metanorma/generic/converter"
3
3
  require_relative "front"
4
+ require_relative "cleanup"
4
5
 
5
6
  module Metanorma
6
7
  module BIPM
@@ -96,45 +97,6 @@ module Metanorma
96
97
  end
97
98
  end
98
99
 
99
- def boilerplate_file(_xmldoc)
100
- if @jcgm
101
- File.join(File.dirname(__FILE__), "boilerplate-jcgm-en.adoc")
102
- else
103
- File.join(File.dirname(__FILE__), "boilerplate-#{@lang}.adoc")
104
- end
105
- end
106
-
107
- def sections_cleanup(xml)
108
- super
109
- jcgm_untitled_sections_cleanup(xml) if @jcgm
110
- end
111
-
112
- def jcgm_untitled_sections_cleanup(xml)
113
- xml.xpath("//clause//clause | //annex//clause | //introduction/clause")
114
- .each do |c|
115
- next if !c&.at("./title")&.text&.empty?
116
-
117
- c["inline-header"] = true
118
- end
119
- end
120
-
121
- def section_names_terms_cleanup(xml); end
122
-
123
- def section_names_refs_cleanup(xml); end
124
-
125
- def mathml_mi_italics
126
- { uppergreek: false, upperroman: false,
127
- lowergreek: false, lowerroman: true }
128
- end
129
-
130
- def xref_to_eref(elem, name)
131
- if elem.at("//bibitem[@id = '#{elem['target']}']/" \
132
- "docidentifier[@type = 'BIPM-long']")
133
- elem["style"] = "BIPM-long"
134
- end
135
- super
136
- end
137
-
138
100
  def document(node)
139
101
  @jcgm = node.attr("committee-acronym") == "JCGM"
140
102
  super
@@ -156,12 +118,12 @@ module Metanorma
156
118
  def presentation_xml_converter(node)
157
119
  IsoDoc::BIPM::PresentationXMLConvert
158
120
  .new(html_extract_attributes(node)
159
- .merge(output_formats: ::Metanorma::BIPM::Processor.new.output_formats))
121
+ .merge(output_formats: ::Metanorma::BIPM::Processor.new
122
+ .output_formats))
160
123
  end
161
124
 
162
125
  def pdf_converter(node)
163
- return nil if node.attr("no-pdf")
164
-
126
+ node.attr("no-pdf") and return nil
165
127
  IsoDoc::BIPM::PdfConvert.new(pdf_extract_attributes(node))
166
128
  end
167
129
  end
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.2.12 -->
20
+ <!-- VERSION v1.3.0 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -146,6 +146,9 @@
146
146
  <data type="boolean"/>
147
147
  </attribute>
148
148
  </optional>
149
+ <optional>
150
+ <attribute name="style"/>
151
+ </optional>
149
152
  <oneOrMore>
150
153
  <ref name="PureTextElement"/>
151
154
  </oneOrMore>
@@ -14,6 +14,7 @@
14
14
  <value>strategy</value>
15
15
  <value>cipm-mra</value>
16
16
  <value>resolution</value>
17
+ <value>policy</value>
17
18
  </choice>
18
19
  </define>
19
20
  <define name="editorialgroup">
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module BIPM
3
- VERSION = "2.4.0".freeze
3
+ VERSION = "2.4.3".freeze
4
4
  end
5
5
  end
@@ -27,8 +27,8 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
29
29
 
30
- spec.add_dependency "metanorma-generic", "~> 2.6.0"
31
- spec.add_dependency "metanorma-iso", "~> 2.7.0"
30
+ spec.add_dependency "metanorma-generic", "~> 2.6.2"
31
+ spec.add_dependency "metanorma-iso", "~> 2.7.3"
32
32
 
33
33
  spec.add_development_dependency "debug"
34
34
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
data/metanorma.yml CHANGED
@@ -43,6 +43,7 @@ doctypes:
43
43
  - strategy
44
44
  - cipm-mra
45
45
  - resolution
46
+ - policy
46
47
  default_doctype: brochure
47
48
  committees:
48
49
  - CGPM
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-bipm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-09 00:00:00.000000000 Z
11
+ date: 2024-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.6.0
19
+ version: 2.6.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.6.0
26
+ version: 2.6.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: metanorma-iso
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.7.0
33
+ version: 2.7.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.7.0
40
+ version: 2.7.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: debug
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -270,6 +270,7 @@ files:
270
270
  - lib/metanorma/bipm/boilerplate-en.adoc
271
271
  - lib/metanorma/bipm/boilerplate-fr.adoc
272
272
  - lib/metanorma/bipm/boilerplate-jcgm-en.adoc
273
+ - lib/metanorma/bipm/cleanup.rb
273
274
  - lib/metanorma/bipm/converter.rb
274
275
  - lib/metanorma/bipm/front.rb
275
276
  - lib/metanorma/bipm/isodoc.rng