metanorma-bipm 1.0.7 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asciidoctor/bipm/converter.rb +64 -33
- data/lib/asciidoctor/bipm/isodoc.rng +130 -1
- data/lib/isodoc/bipm/bipm.brochure.xsl +44 -18
- data/lib/isodoc/bipm/bipm.guide.xsl +44 -18
- data/lib/isodoc/bipm/bipm.mise-en-pratique.xsl +44 -18
- data/lib/isodoc/bipm/bipm.rapport.xsl +44 -18
- data/lib/isodoc/bipm/html/html_bipm_titlepage.html +2 -0
- data/lib/isodoc/bipm/html/htmlstyle.css +7 -0
- data/lib/isodoc/bipm/i18n-en.yaml +9 -0
- data/lib/isodoc/bipm/i18n-fr.yaml +6 -0
- data/lib/isodoc/bipm/jcgm.standard.xsl +157 -59
- data/lib/isodoc/bipm/metadata.rb +15 -7
- data/lib/isodoc/bipm/pdf_convert.rb +12 -9
- data/lib/isodoc/bipm/presentation_xml_convert.rb +42 -14
- data/lib/isodoc/bipm/xref.rb +86 -51
- data/lib/metanorma/bipm/version.rb +1 -1
- data/metanorma-bipm.gemspec +4 -4
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a53880abd1573a497cf5de514c78f002e9ad698fb7f9899babde3840132af5ee
|
4
|
+
data.tar.gz: 47c1fbccab81b1614f8692c7605d77c25d16d7324a5113b2d615b560f3e2a136
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 525c38fd4e67b10703a2811fd0f5b45958bd00eff0675b23ccc427d7a03d4755c059ace2209dd60c78823666cbf8af6cbf6015d16029dc6f68a088634fbac470
|
7
|
+
data.tar.gz: 9598204d734b04605900681eaf3da059e8f2a70002858156e9bfb23694e91b4114786d22824cf182696b3b53366bf92f7df97edefae21035c30d31427246fa72
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require "asciidoctor/standoc/converter"
|
2
|
-
require
|
2
|
+
require "asciidoctor/generic/converter"
|
3
3
|
|
4
4
|
module Asciidoctor
|
5
5
|
module BIPM
|
@@ -19,20 +19,26 @@ module Asciidoctor
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def org_abbrev
|
22
|
-
|
22
|
+
{ org_name_long => configuration.organization_name_short }
|
23
23
|
end
|
24
24
|
|
25
25
|
def metadata_committee(node, xml)
|
26
26
|
return unless node.attr("committee-en") || node.attr("committee-fr")
|
27
|
+
|
27
28
|
xml.editorialgroup do |a|
|
28
29
|
metadata_committee1(node, a)
|
29
|
-
|
30
|
+
i = 2
|
31
|
+
while node.attr("committee-en_#{i}") || node.attr("committee-fr_#{i}")
|
32
|
+
metadata_committee2(node, a, i)
|
33
|
+
i += 1
|
34
|
+
end
|
30
35
|
metadata_workgroup(node, a)
|
31
36
|
end
|
32
37
|
end
|
33
38
|
|
34
|
-
def metadata_committee1(node,
|
35
|
-
|
39
|
+
def metadata_committee1(node, xml)
|
40
|
+
xml.committee **attr_code(acronym:
|
41
|
+
node.attr("committee-acronym")) do |c|
|
36
42
|
e = node.attr("committee-en") and
|
37
43
|
c.variant e, language: "en", script: "Latn"
|
38
44
|
e = node.attr("committee-fr") and
|
@@ -40,24 +46,25 @@ module Asciidoctor
|
|
40
46
|
end
|
41
47
|
end
|
42
48
|
|
43
|
-
def metadata_committee2(node,
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
e = node.attr("committee
|
48
|
-
|
49
|
+
def metadata_committee2(node, xml, num)
|
50
|
+
xml.committee **attr_code(acronym:
|
51
|
+
node.attr("committee-acronym_#{num}")) do |c|
|
52
|
+
%w(en fr).each do |lg|
|
53
|
+
e = node.attr("committee-#{lg}_#{num}") and
|
54
|
+
c.variant e, language: lg, script: "Latn"
|
49
55
|
end
|
50
|
-
i += 1
|
51
56
|
end
|
52
57
|
end
|
53
58
|
|
54
|
-
def metadata_workgroup(node,
|
55
|
-
|
56
|
-
|
59
|
+
def metadata_workgroup(node, xml)
|
60
|
+
xml.workgroup(node.attr("workgroup"),
|
61
|
+
**attr_code(acronym: node.attr("workgroup-acronym")))
|
57
62
|
i = 2
|
58
|
-
while node.attr("workgroup_#{i}")
|
59
|
-
|
63
|
+
while node.attr("workgroup_#{i}")
|
64
|
+
xml.workgroup(
|
65
|
+
node.attr("workgroup_#{i}"),
|
60
66
|
**attr_code(acronym: node.attr("workgroup-acronym_#{i}"))
|
67
|
+
)
|
61
68
|
i += 1
|
62
69
|
end
|
63
70
|
end
|
@@ -76,13 +83,15 @@ module Asciidoctor
|
|
76
83
|
draft = node.attr("supersedes-draft#{suffix}")
|
77
84
|
edition = node.attr("supersedes-edition#{suffix}")
|
78
85
|
return false unless d || draft || edition
|
86
|
+
|
79
87
|
relation_supersedes_self1(xml, d, edition, draft)
|
80
88
|
end
|
81
89
|
|
82
|
-
def relation_supersedes_self1(xml,
|
90
|
+
def relation_supersedes_self1(xml, date, edition, draft)
|
83
91
|
xml.relation **{ type: "supersedes" } do |r|
|
84
92
|
r.bibitem do |b|
|
85
|
-
|
93
|
+
date and b.date(date,
|
94
|
+
**{ type: edition ? "published" : "circulated" })
|
86
95
|
edition and b.edition edition
|
87
96
|
draft and b.version do |v|
|
88
97
|
v.draft draft
|
@@ -91,13 +100,13 @@ module Asciidoctor
|
|
91
100
|
end
|
92
101
|
end
|
93
102
|
|
94
|
-
def personal_role(node,
|
103
|
+
def personal_role(node, xml, suffix)
|
95
104
|
role = node.attr("role#{suffix}") || "author"
|
96
105
|
unless %w(author editor).include?(role.downcase)
|
97
106
|
desc = role
|
98
107
|
role = "editor"
|
99
108
|
end
|
100
|
-
|
109
|
+
xml.role desc, **{ type: role.downcase }
|
101
110
|
end
|
102
111
|
|
103
112
|
def title(node, xml)
|
@@ -106,7 +115,7 @@ module Asciidoctor
|
|
106
115
|
xml.title **attr_code(at.merge(type: "main")) do |t1|
|
107
116
|
t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-#{lang}"))
|
108
117
|
end
|
109
|
-
%w(cover appendix annex part subpart).each do |w|
|
118
|
+
%w(cover appendix annex part subpart provenance).each do |w|
|
110
119
|
typed_title(node, xml, lang, w)
|
111
120
|
end
|
112
121
|
end
|
@@ -115,6 +124,7 @@ module Asciidoctor
|
|
115
124
|
def typed_title(node, xml, lang, type)
|
116
125
|
at = { language: lang, format: "text/plain" }
|
117
126
|
return unless title = node.attr("title-#{type}-#{lang}")
|
127
|
+
|
118
128
|
xml.title **attr_code(at.merge(type: type)) do |t1|
|
119
129
|
t1 << Metanorma::Utils::asciidoc_sub(title)
|
120
130
|
end
|
@@ -122,7 +132,7 @@ module Asciidoctor
|
|
122
132
|
|
123
133
|
def sectiontype_streamline(ret)
|
124
134
|
case ret
|
125
|
-
when "introduction" then "clause"
|
135
|
+
when "introduction" then @jcgm ? "introduction" : "clause"
|
126
136
|
else
|
127
137
|
super
|
128
138
|
end
|
@@ -130,13 +140,13 @@ module Asciidoctor
|
|
130
140
|
|
131
141
|
def inline_anchor_xref_attrs(node)
|
132
142
|
flags = %w(pagenumber nosee nopage).each_with_object({}) do |w, m|
|
133
|
-
if /#{w}%/.match(node.text)
|
143
|
+
if /#{w}%/.match?(node.text)
|
134
144
|
node.text = node.text.sub(/#{w}%/, "")
|
135
145
|
m[w] = true
|
136
146
|
end
|
137
147
|
end
|
138
148
|
ret = super
|
139
|
-
flags.
|
149
|
+
flags.each_key { |k| ret[k.to_sym] = true }
|
140
150
|
ret
|
141
151
|
end
|
142
152
|
|
@@ -154,9 +164,6 @@ module Asciidoctor
|
|
154
164
|
super.merge(attr_code(start: node.attr("start")))
|
155
165
|
end
|
156
166
|
|
157
|
-
def section_names_terms_cleanup(x)
|
158
|
-
end
|
159
|
-
|
160
167
|
def committee_validate(xml)
|
161
168
|
committees = Array(configuration&.committees) || return
|
162
169
|
committees.empty? and return
|
@@ -173,21 +180,44 @@ module Asciidoctor
|
|
173
180
|
end
|
174
181
|
|
175
182
|
def boilerplate_file(xmldoc)
|
176
|
-
return super unless
|
183
|
+
return super unless @jcgm
|
184
|
+
|
177
185
|
File.join(File.dirname(__FILE__), "boilerplate-jcgm-en.xml")
|
178
186
|
end
|
179
187
|
|
188
|
+
def sections_cleanup(xml)
|
189
|
+
super
|
190
|
+
jcgm_untitled_sections_cleanup(xml) if @jcgm
|
191
|
+
end
|
192
|
+
|
193
|
+
def jcgm_untitled_sections_cleanup(xml)
|
194
|
+
xml.xpath("//clause//clause | //annex//clause").each do |c|
|
195
|
+
next if !c&.at("./title")&.text&.empty?
|
196
|
+
|
197
|
+
c["inline-header"] = true
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def section_names_terms_cleanup(xml); end
|
202
|
+
|
203
|
+
def section_names_refs_cleanup(xml); end
|
204
|
+
|
180
205
|
def mathml_mi_italics
|
181
206
|
{ uppergreek: false, upperroman: false,
|
182
207
|
lowergreek: false, lowerroman: true }
|
183
208
|
end
|
184
209
|
|
210
|
+
def document(node)
|
211
|
+
@jcgm = node.attr("committee-acronym") == "JCGM"
|
212
|
+
super
|
213
|
+
end
|
214
|
+
|
185
215
|
def outputs(node, ret)
|
186
|
-
File.open(@filename
|
187
|
-
presentation_xml_converter(node).convert(@filename
|
188
|
-
html_converter(node).convert(@filename
|
216
|
+
File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
|
217
|
+
presentation_xml_converter(node).convert("#{@filename}.xml")
|
218
|
+
html_converter(node).convert("#{@filename}.presentation.xml",
|
189
219
|
nil, false, "#{@filename}.html")
|
190
|
-
pdf_converter(node)&.convert(@filename
|
220
|
+
pdf_converter(node)&.convert("#{@filename}.presentation.xml",
|
191
221
|
nil, false, "#{@filename}.pdf")
|
192
222
|
end
|
193
223
|
|
@@ -201,6 +231,7 @@ module Asciidoctor
|
|
201
231
|
|
202
232
|
def pdf_converter(node)
|
203
233
|
return nil if node.attr("no-pdf")
|
234
|
+
|
204
235
|
IsoDoc::BIPM::PdfConvert.new(doc_extract_attributes(node))
|
205
236
|
end
|
206
237
|
end
|
@@ -86,6 +86,35 @@
|
|
86
86
|
<text/>
|
87
87
|
</element>
|
88
88
|
</define>
|
89
|
+
<define name="erefType">
|
90
|
+
<optional>
|
91
|
+
<attribute name="normative">
|
92
|
+
<data type="boolean"/>
|
93
|
+
</attribute>
|
94
|
+
</optional>
|
95
|
+
<attribute name="citeas"/>
|
96
|
+
<attribute name="type">
|
97
|
+
<ref name="ReferenceFormat"/>
|
98
|
+
</attribute>
|
99
|
+
<optional>
|
100
|
+
<attribute name="alt"/>
|
101
|
+
</optional>
|
102
|
+
<optional>
|
103
|
+
<attribute name="case">
|
104
|
+
<choice>
|
105
|
+
<value>capital</value>
|
106
|
+
<value>lowercase</value>
|
107
|
+
</choice>
|
108
|
+
</attribute>
|
109
|
+
</optional>
|
110
|
+
<optional>
|
111
|
+
<attribute name="droploc">
|
112
|
+
<data type="boolean"/>
|
113
|
+
</attribute>
|
114
|
+
</optional>
|
115
|
+
<ref name="CitationType"/>
|
116
|
+
<text/>
|
117
|
+
</define>
|
89
118
|
<define name="ul">
|
90
119
|
<element name="ul">
|
91
120
|
<attribute name="id">
|
@@ -775,6 +804,78 @@
|
|
775
804
|
<ref name="paragraph"/>
|
776
805
|
</element>
|
777
806
|
</define>
|
807
|
+
<define name="em">
|
808
|
+
<element name="em">
|
809
|
+
<zeroOrMore>
|
810
|
+
<choice>
|
811
|
+
<ref name="PureTextElement"/>
|
812
|
+
<ref name="stem"/>
|
813
|
+
<ref name="index"/>
|
814
|
+
</choice>
|
815
|
+
</zeroOrMore>
|
816
|
+
</element>
|
817
|
+
</define>
|
818
|
+
<define name="strong">
|
819
|
+
<element name="strong">
|
820
|
+
<zeroOrMore>
|
821
|
+
<choice>
|
822
|
+
<ref name="PureTextElement"/>
|
823
|
+
<ref name="stem"/>
|
824
|
+
<ref name="index"/>
|
825
|
+
</choice>
|
826
|
+
</zeroOrMore>
|
827
|
+
</element>
|
828
|
+
</define>
|
829
|
+
<define name="tt">
|
830
|
+
<element name="tt">
|
831
|
+
<zeroOrMore>
|
832
|
+
<choice>
|
833
|
+
<ref name="PureTextElement"/>
|
834
|
+
<ref name="index"/>
|
835
|
+
</choice>
|
836
|
+
</zeroOrMore>
|
837
|
+
</element>
|
838
|
+
</define>
|
839
|
+
<define name="keyword">
|
840
|
+
<element name="keyword">
|
841
|
+
<zeroOrMore>
|
842
|
+
<choice>
|
843
|
+
<ref name="PureTextElement"/>
|
844
|
+
<ref name="index"/>
|
845
|
+
</choice>
|
846
|
+
</zeroOrMore>
|
847
|
+
</element>
|
848
|
+
</define>
|
849
|
+
<define name="strike">
|
850
|
+
<element name="strike">
|
851
|
+
<zeroOrMore>
|
852
|
+
<choice>
|
853
|
+
<ref name="PureTextElement"/>
|
854
|
+
<ref name="index"/>
|
855
|
+
</choice>
|
856
|
+
</zeroOrMore>
|
857
|
+
</element>
|
858
|
+
</define>
|
859
|
+
<define name="underline">
|
860
|
+
<element name="underline">
|
861
|
+
<zeroOrMore>
|
862
|
+
<choice>
|
863
|
+
<ref name="PureTextElement"/>
|
864
|
+
<ref name="index"/>
|
865
|
+
</choice>
|
866
|
+
</zeroOrMore>
|
867
|
+
</element>
|
868
|
+
</define>
|
869
|
+
<define name="smallcap">
|
870
|
+
<element name="smallcap">
|
871
|
+
<zeroOrMore>
|
872
|
+
<choice>
|
873
|
+
<ref name="PureTextElement"/>
|
874
|
+
<ref name="index"/>
|
875
|
+
</choice>
|
876
|
+
</zeroOrMore>
|
877
|
+
</element>
|
878
|
+
</define>
|
778
879
|
</include>
|
779
880
|
<!-- end overrides -->
|
780
881
|
<define name="colgroup">
|
@@ -793,7 +894,35 @@
|
|
793
894
|
<value>internal</value>
|
794
895
|
</define>
|
795
896
|
<define name="TextElement" combine="choice">
|
796
|
-
<
|
897
|
+
<choice>
|
898
|
+
<ref name="concept"/>
|
899
|
+
<ref name="add"/>
|
900
|
+
<ref name="del"/>
|
901
|
+
</choice>
|
902
|
+
</define>
|
903
|
+
<define name="add">
|
904
|
+
<element name="add">
|
905
|
+
<choice>
|
906
|
+
<ref name="PureTextElement"/>
|
907
|
+
<ref name="eref"/>
|
908
|
+
<ref name="stem"/>
|
909
|
+
<ref name="keyword"/>
|
910
|
+
<ref name="xref"/>
|
911
|
+
<ref name="hyperlink"/>
|
912
|
+
</choice>
|
913
|
+
</element>
|
914
|
+
</define>
|
915
|
+
<define name="del">
|
916
|
+
<element name="del">
|
917
|
+
<choice>
|
918
|
+
<ref name="PureTextElement"/>
|
919
|
+
<ref name="eref"/>
|
920
|
+
<ref name="stem"/>
|
921
|
+
<ref name="keyword"/>
|
922
|
+
<ref name="xref"/>
|
923
|
+
<ref name="hyperlink"/>
|
924
|
+
</choice>
|
925
|
+
</element>
|
797
926
|
</define>
|
798
927
|
<define name="concept">
|
799
928
|
<element name="concept">
|
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
<xsl:param name="svg_images"/>
|
6
6
|
<xsl:variable name="images" select="document($svg_images)"/>
|
7
|
+
<xsl:param name="basepath"/>
|
7
8
|
|
8
9
|
<xsl:param name="initial_page_number"/>
|
9
10
|
<xsl:param name="doc_split_by_language"/>
|
@@ -4630,12 +4631,18 @@
|
|
4630
4631
|
|
4631
4632
|
</xsl:attribute-set><xsl:attribute-set name="admitted-style">
|
4632
4633
|
|
4633
|
-
|
4634
|
+
|
4634
4635
|
</xsl:attribute-set><xsl:attribute-set name="deprecates-style">
|
4635
4636
|
|
4636
4637
|
</xsl:attribute-set><xsl:attribute-set name="definition-style">
|
4637
4638
|
|
4638
4639
|
|
4640
|
+
</xsl:attribute-set><xsl:attribute-set name="add-style">
|
4641
|
+
<xsl:attribute name="color">red</xsl:attribute>
|
4642
|
+
<xsl:attribute name="text-decoration">underline</xsl:attribute>
|
4643
|
+
</xsl:attribute-set><xsl:attribute-set name="del-style">
|
4644
|
+
<xsl:attribute name="color">red</xsl:attribute>
|
4645
|
+
<xsl:attribute name="text-decoration">line-through</xsl:attribute>
|
4639
4646
|
</xsl:attribute-set><xsl:template name="processPrefaceSectionsDefault_Contents">
|
4640
4647
|
<xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
|
4641
4648
|
<xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
|
@@ -6101,8 +6108,12 @@
|
|
6101
6108
|
<fo:inline text-decoration="underline">
|
6102
6109
|
<xsl:apply-templates/>
|
6103
6110
|
</fo:inline>
|
6111
|
+
</xsl:template><xsl:template match="*[local-name()='add']">
|
6112
|
+
<fo:inline xsl:use-attribute-sets="add-style">
|
6113
|
+
<xsl:apply-templates/>
|
6114
|
+
</fo:inline>
|
6104
6115
|
</xsl:template><xsl:template match="*[local-name()='del']">
|
6105
|
-
<fo:inline
|
6116
|
+
<fo:inline xsl:use-attribute-sets="del-style">
|
6106
6117
|
<xsl:apply-templates/>
|
6107
6118
|
</fo:inline>
|
6108
6119
|
</xsl:template><xsl:template match="*[local-name()='hi']">
|
@@ -6740,22 +6751,37 @@
|
|
6740
6751
|
<xsl:apply-templates/>
|
6741
6752
|
</fo:block>
|
6742
6753
|
</xsl:template><xsl:template match="*[local-name() = 'image']">
|
6743
|
-
<
|
6744
|
-
|
6745
|
-
|
6746
|
-
|
6747
|
-
|
6748
|
-
|
6749
|
-
|
6750
|
-
|
6751
|
-
|
6752
|
-
|
6753
|
-
|
6754
|
-
|
6755
|
-
|
6756
|
-
|
6757
|
-
|
6758
|
-
|
6754
|
+
<xsl:choose>
|
6755
|
+
<xsl:when test="ancestor::*[local-name() = 'title']">
|
6756
|
+
<fo:inline padding-left="1mm" padding-right="1mm">
|
6757
|
+
<xsl:variable name="src">
|
6758
|
+
<xsl:call-template name="image_src"/>
|
6759
|
+
</xsl:variable>
|
6760
|
+
<fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle"/>
|
6761
|
+
</fo:inline>
|
6762
|
+
</xsl:when>
|
6763
|
+
<xsl:otherwise>
|
6764
|
+
<fo:block xsl:use-attribute-sets="image-style">
|
6765
|
+
|
6766
|
+
<xsl:variable name="src">
|
6767
|
+
<xsl:call-template name="image_src"/>
|
6768
|
+
</xsl:variable>
|
6769
|
+
<fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
|
6770
|
+
</fo:block>
|
6771
|
+
</xsl:otherwise>
|
6772
|
+
</xsl:choose>
|
6773
|
+
</xsl:template><xsl:template name="image_src">
|
6774
|
+
<xsl:choose>
|
6775
|
+
<xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
|
6776
|
+
<xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
|
6777
|
+
</xsl:when>
|
6778
|
+
<xsl:when test="not(starts-with(@src, 'data:'))">
|
6779
|
+
<xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/>
|
6780
|
+
</xsl:when>
|
6781
|
+
<xsl:otherwise>
|
6782
|
+
<xsl:value-of select="@src"/>
|
6783
|
+
</xsl:otherwise>
|
6784
|
+
</xsl:choose>
|
6759
6785
|
</xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="contents">
|
6760
6786
|
<xsl:apply-templates mode="contents"/>
|
6761
6787
|
<xsl:text> </xsl:text>
|