metanorma-bipm 1.1.1 → 1.1.2

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: 623fbeeac6901c02be4e9d2b6f63fffd801ca05d3265b50044bfadd6cee89305
4
- data.tar.gz: 2541d290c848922b72be621bc9ebb4422bd77606ae40094006d0af38e378c7c0
3
+ metadata.gz: fc4887a20e51de45b5d3caaaf643031ae87fc6e1856a52dc686a419ef6927f44
4
+ data.tar.gz: 72c3c2058fd5f61dc26e7c3f911c595e095acd69bca7aea3a998073092c18d27
5
5
  SHA512:
6
- metadata.gz: 398c0d71ce26040dcc71453421b7a2af92470bb1e0f76b409bed57c4668e13681eeed2615069bf9de259520d22d1bb9a5ad7c251994d6e975dd4a0ea1051aaf9
7
- data.tar.gz: 62c7116d632363c56808f868dc001f4ea313f85f9b0b5116821394d2ed46fdc1bce56f3dc1b7e331454c01d1120762e5c4cd4d3722bbbe32db9a3bf314b62097
6
+ metadata.gz: b1030c749fb1377c3c187b910c00569f986060dfe61e76f76089d67b471a85127b1166a702dc8ea494a1b98d1e666031ac9fcc80b8e469ee796f9f81a425152e
7
+ data.tar.gz: 28478e4d92e1978c3e5f1ac86162ddeccfd581949bea1694fe5b82e9b368c74907841ddf81eaa9000a9f487a1fcdf80a53007ea63ef2d05e0038dfd7abbf2da0
data/.gitignore CHANGED
@@ -1 +1,4 @@
1
- .rubocop-https--*
1
+ /.rubocop-https--*
2
+ /.byebug_history
3
+ /.rspec_status
4
+ /coverage/
data/.rubocop.yml CHANGED
@@ -10,5 +10,3 @@ AllCops:
10
10
  DisplayCopNames: false
11
11
  StyleGuideCopsOnly: false
12
12
  TargetRubyVersion: 2.4
13
- Rails:
14
- Enabled: true
data/Gemfile CHANGED
@@ -6,6 +6,6 @@ git_source(:github) { |repo| "https://github.com/#{repo}" }
6
6
 
7
7
  gemspec
8
8
 
9
- if File.exist? 'Gemfile.devel'
10
- eval File.read('Gemfile.devel'), nil, 'Gemfile.devel' # rubocop:disable Security/Eval
9
+ if File.exist? "Gemfile.devel"
10
+ eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
11
11
  end
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
- require 'isodoc/gem_tasks'
3
+ require "isodoc/gem_tasks"
4
4
 
5
5
  IsoDoc::GemTasks.install
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- task :default => :spec
8
+ task default: :spec
@@ -138,6 +138,13 @@ module Asciidoctor
138
138
  end
139
139
  end
140
140
 
141
+ def sectiontype(node, level = true)
142
+ ret = sectiontype1(node)
143
+ return ret if ret == "terms and definitions"
144
+
145
+ super
146
+ end
147
+
141
148
  def inline_anchor_xref_attrs(node)
142
149
  flags = %w(pagenumber nosee nopage).each_with_object({}) do |w, m|
143
150
  if /#{w}%/.match?(node.text)
@@ -876,6 +876,18 @@
876
876
  </zeroOrMore>
877
877
  </element>
878
878
  </define>
879
+ <define name="pagebreak">
880
+ <element name="pagebreak">
881
+ <optional>
882
+ <attribute name="orientation">
883
+ <choice>
884
+ <value>landscape</value>
885
+ <value>portrait</value>
886
+ </choice>
887
+ </attribute>
888
+ </optional>
889
+ </element>
890
+ </define>
879
891
  </include>
880
892
  <!-- end overrides -->
881
893
  <define name="colgroup">
@@ -943,8 +955,170 @@
943
955
  <ref name="permission"/>
944
956
  <ref name="imagemap"/>
945
957
  <ref name="svgmap"/>
958
+ <ref name="inputform"/>
959
+ </choice>
960
+ </define>
961
+ <define name="inputform">
962
+ <element name="form">
963
+ <attribute name="id">
964
+ <data type="ID"/>
965
+ </attribute>
966
+ <attribute name="name"/>
967
+ <attribute name="action"/>
968
+ <zeroOrMore>
969
+ <choice>
970
+ <ref name="TextElement"/>
971
+ <ref name="FormInput"/>
972
+ </choice>
973
+ </zeroOrMore>
974
+ </element>
975
+ </define>
976
+ <define name="FormInput">
977
+ <choice>
978
+ <ref name="input"/>
979
+ <ref name="formlabel"/>
980
+ <ref name="select"/>
981
+ <ref name="textarea"/>
982
+ </choice>
983
+ </define>
984
+ <define name="InputType">
985
+ <choice>
986
+ <value>button</value>
987
+ <value>checkbox</value>
988
+ <value>date</value>
989
+ <value>file</value>
990
+ <value>password</value>
991
+ <value>radio</value>
992
+ <value>submit</value>
993
+ <value>text</value>
946
994
  </choice>
947
995
  </define>
996
+ <define name="input">
997
+ <element name="input">
998
+ <attribute name="type">
999
+ <ref name="InputType"/>
1000
+ </attribute>
1001
+ <optional>
1002
+ <attribute name="checked">
1003
+ <data type="boolean"/>
1004
+ </attribute>
1005
+ </optional>
1006
+ <optional>
1007
+ <attribute name="disabled">
1008
+ <data type="boolean"/>
1009
+ </attribute>
1010
+ </optional>
1011
+ <optional>
1012
+ <attribute name="readonly">
1013
+ <data type="boolean"/>
1014
+ </attribute>
1015
+ </optional>
1016
+ <optional>
1017
+ <attribute name="maxlength">
1018
+ <data type="int"/>
1019
+ </attribute>
1020
+ </optional>
1021
+ <optional>
1022
+ <attribute name="minlength">
1023
+ <data type="int"/>
1024
+ </attribute>
1025
+ </optional>
1026
+ <optional>
1027
+ <attribute name="name"/>
1028
+ </optional>
1029
+ <optional>
1030
+ <attribute name="value"/>
1031
+ </optional>
1032
+ <optional>
1033
+ <attribute name="id">
1034
+ <data type="ID"/>
1035
+ </attribute>
1036
+ </optional>
1037
+ </element>
1038
+ </define>
1039
+ <define name="formlabel">
1040
+ <element name="label">
1041
+ <attribute name="for">
1042
+ <data type="IDREF"/>
1043
+ </attribute>
1044
+ <zeroOrMore>
1045
+ <ref name="PureTextElement"/>
1046
+ </zeroOrMore>
1047
+ </element>
1048
+ </define>
1049
+ <define name="select">
1050
+ <element name="select">
1051
+ <optional>
1052
+ <attribute name="name"/>
1053
+ </optional>
1054
+ <optional>
1055
+ <attribute name="value"/>
1056
+ </optional>
1057
+ <optional>
1058
+ <attribute name="id">
1059
+ <data type="ID"/>
1060
+ </attribute>
1061
+ </optional>
1062
+ <optional>
1063
+ <attribute name="disabled">
1064
+ <data type="boolean"/>
1065
+ </attribute>
1066
+ </optional>
1067
+ <optional>
1068
+ <attribute name="multiple">
1069
+ <data type="boolean"/>
1070
+ </attribute>
1071
+ </optional>
1072
+ <optional>
1073
+ <attribute name="size">
1074
+ <data type="int"/>
1075
+ </attribute>
1076
+ </optional>
1077
+ <oneOrMore>
1078
+ <ref name="option"/>
1079
+ </oneOrMore>
1080
+ </element>
1081
+ </define>
1082
+ <define name="option">
1083
+ <element name="option">
1084
+ <optional>
1085
+ <attribute name="disabled">
1086
+ <data type="boolean"/>
1087
+ </attribute>
1088
+ </optional>
1089
+ <optional>
1090
+ <attribute name="value"/>
1091
+ </optional>
1092
+ <zeroOrMore>
1093
+ <ref name="PureTextElement"/>
1094
+ </zeroOrMore>
1095
+ </element>
1096
+ </define>
1097
+ <define name="textarea">
1098
+ <element name="textarea">
1099
+ <optional>
1100
+ <attribute name="name"/>
1101
+ </optional>
1102
+ <optional>
1103
+ <attribute name="value"/>
1104
+ </optional>
1105
+ <optional>
1106
+ <attribute name="id">
1107
+ <data type="ID"/>
1108
+ </attribute>
1109
+ </optional>
1110
+ <optional>
1111
+ <attribute name="rows">
1112
+ <data type="int"/>
1113
+ </attribute>
1114
+ </optional>
1115
+ <optional>
1116
+ <attribute name="cols">
1117
+ <data type="int"/>
1118
+ </attribute>
1119
+ </optional>
1120
+ </element>
1121
+ </define>
948
1122
  <define name="bibliography">
949
1123
  <element name="bibliography">
950
1124
  <oneOrMore>
@@ -39,33 +39,47 @@ module IsoDoc
39
39
  ret
40
40
  end
41
41
 
42
- def nonstd_bibitem(list, b, ordinal, biblio)
43
- list.p **attr_code(iso_bibitem_entry_attrs(b, biblio)) do |ref|
44
- ids = bibitem_ref_code(b)
42
+ def nonstd_bibitem(list, bibitem, ordinal, biblio)
43
+ list.p **attr_code(iso_bibitem_entry_attrs(bibitem, biblio)) do |ref|
44
+ ids = bibitem_ref_code(bibitem)
45
45
  identifiers = render_identifier(ids)
46
46
  if biblio then ref_entry_code(ref, ordinal, identifiers, ids)
47
47
  else
48
- ref << "#{identifiers[0] || identifiers[1]}"
48
+ ref << identifiers[0] || identifiers[1]
49
49
  ref << " #{identifiers[1]}" if identifiers[0] && identifiers[1]
50
50
  end
51
51
  ref << " " unless biblio && !identifiers[1]
52
- reference_format(b, ref)
52
+ reference_format(bibitem, ref)
53
53
  end
54
54
  end
55
55
 
56
- def std_bibitem_entry(list, b, ordinal, biblio)
57
- list.p **attr_code(iso_bibitem_entry_attrs(b, biblio)) do |ref|
58
- identifiers = render_identifier(bibitem_ref_code(b))
56
+ def std_bibitem_entry(list, bibitem, ordinal, biblio)
57
+ list.p **attr_code(iso_bibitem_entry_attrs(bibitem, biblio)) do |ref|
58
+ identifiers = render_identifier(bibitem_ref_code(bibitem))
59
59
  if biblio then ref_entry_code(ref, ordinal, identifiers, nil)
60
60
  else
61
- ref << "#{identifiers[0] || identifiers[1]}"
61
+ ref << identifiers[0] || identifiers[1]
62
62
  ref << " #{identifiers[1]}" if identifiers[0] && identifiers[1]
63
63
  end
64
- date_note_process(b, ref)
64
+ date_note_process(bibitem, ref)
65
65
  ref << " " unless biblio && !identifiers[1]
66
- reference_format(b, ref)
66
+ reference_format(bibitem, ref)
67
67
  end
68
68
  end
69
+
70
+ def term_cleanup(docxml)
71
+ @jcgm ? docxml : super
72
+ end
73
+
74
+ def termref_cleanup(docxml)
75
+ docxml
76
+ .gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/,
77
+ l10n(", #{@i18n.modified} [/TERMREF]"))
78
+ .gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, "; ")
79
+ .gsub(/\[TERMREF\]\s*/, l10n("[#{@i18n.source} "))
80
+ .gsub(%r{\s*\[/TERMREF\]\s*}, l10n("]"))
81
+ .gsub(/\s*\[MODIFICATION\]/, l10n(", #{@i18n.modified} &mdash; "))
82
+ end
69
83
  end
70
84
  end
71
85
  end
@@ -5485,6 +5485,7 @@
5485
5485
 
5486
5486
 
5487
5487
 
5488
+
5488
5489
  <xsl:attribute name="border">solid 0pt white</xsl:attribute>
5489
5490
  <xsl:variable name="rownum"><xsl:number count="*[local-name()='tr']"/></xsl:variable>
5490
5491
  <xsl:if test="$rownum = 1">
@@ -8178,6 +8179,70 @@
8178
8179
  <xsl:value-of select="substring(.,1,1)"/>
8179
8180
  </xsl:template><xsl:template match="*[local-name() = 'title']" mode="title">
8180
8181
  <fo:inline><xsl:apply-templates/></fo:inline>
8182
+ </xsl:template><xsl:template match="*[local-name() = 'form']">
8183
+ <fo:block>
8184
+ <xsl:apply-templates/>
8185
+ </fo:block>
8186
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'label']">
8187
+ <fo:inline><xsl:apply-templates/></fo:inline>
8188
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'text' or @type = 'date' or @type = 'file' or @type = 'password']">
8189
+ <fo:inline>
8190
+ <xsl:call-template name="text_input"/>
8191
+ </fo:inline>
8192
+ </xsl:template><xsl:template name="text_input">
8193
+ <xsl:variable name="count">
8194
+ <xsl:choose>
8195
+ <xsl:when test="normalize-space(@maxlength) != ''"><xsl:value-of select="@maxlength"/></xsl:when>
8196
+ <xsl:when test="normalize-space(@size) != ''"><xsl:value-of select="@size"/></xsl:when>
8197
+ <xsl:otherwise>10</xsl:otherwise>
8198
+ </xsl:choose>
8199
+ </xsl:variable>
8200
+ <xsl:call-template name="repeat">
8201
+ <xsl:with-param name="char" select="'_'"/>
8202
+ <xsl:with-param name="count" select="$count"/>
8203
+ </xsl:call-template>
8204
+ <xsl:text> </xsl:text>
8205
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'button']">
8206
+ <xsl:variable name="caption">
8207
+ <xsl:choose>
8208
+ <xsl:when test="normalize-space(@value) != ''"><xsl:value-of select="@value"/></xsl:when>
8209
+ <xsl:otherwise>BUTTON</xsl:otherwise>
8210
+ </xsl:choose>
8211
+ </xsl:variable>
8212
+ <fo:inline>[<xsl:value-of select="$caption"/>]</fo:inline>
8213
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'checkbox']">
8214
+ <fo:inline padding-right="1mm">
8215
+ <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%">
8216
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
8217
+ <xsl:attribute name="content-width">100%</xsl:attribute>
8218
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
8219
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
8220
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
8221
+ <polyline points="0,0 80,0 80,80 0,80 0,0" stroke="black" stroke-width="5" fill="white"/>
8222
+ </svg>
8223
+ </fo:instream-foreign-object>
8224
+ </fo:inline>
8225
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'radio']">
8226
+ <fo:inline padding-right="1mm">
8227
+ <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%">
8228
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
8229
+ <xsl:attribute name="content-width">100%</xsl:attribute>
8230
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
8231
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
8232
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
8233
+ <circle cx="40" cy="40" r="30" stroke="black" stroke-width="5" fill="white"/>
8234
+ <circle cx="40" cy="40" r="15" stroke="black" stroke-width="5" fill="white"/>
8235
+ </svg>
8236
+ </fo:instream-foreign-object>
8237
+ </fo:inline>
8238
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'select']">
8239
+ <fo:inline>
8240
+ <xsl:call-template name="text_input"/>
8241
+ </fo:inline>
8242
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'textarea']">
8243
+ <fo:block-container border="1pt solid black" width="50%">
8244
+ <fo:block> </fo:block>
8245
+ </fo:block-container>
8181
8246
  </xsl:template><xsl:template name="convertDate">
8182
8247
  <xsl:param name="date"/>
8183
8248
  <xsl:param name="format" select="'short'"/>
@@ -5485,6 +5485,7 @@
5485
5485
 
5486
5486
 
5487
5487
 
5488
+
5488
5489
  <xsl:attribute name="border">solid 0pt white</xsl:attribute>
5489
5490
  <xsl:variable name="rownum"><xsl:number count="*[local-name()='tr']"/></xsl:variable>
5490
5491
  <xsl:if test="$rownum = 1">
@@ -8178,6 +8179,70 @@
8178
8179
  <xsl:value-of select="substring(.,1,1)"/>
8179
8180
  </xsl:template><xsl:template match="*[local-name() = 'title']" mode="title">
8180
8181
  <fo:inline><xsl:apply-templates/></fo:inline>
8182
+ </xsl:template><xsl:template match="*[local-name() = 'form']">
8183
+ <fo:block>
8184
+ <xsl:apply-templates/>
8185
+ </fo:block>
8186
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'label']">
8187
+ <fo:inline><xsl:apply-templates/></fo:inline>
8188
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'text' or @type = 'date' or @type = 'file' or @type = 'password']">
8189
+ <fo:inline>
8190
+ <xsl:call-template name="text_input"/>
8191
+ </fo:inline>
8192
+ </xsl:template><xsl:template name="text_input">
8193
+ <xsl:variable name="count">
8194
+ <xsl:choose>
8195
+ <xsl:when test="normalize-space(@maxlength) != ''"><xsl:value-of select="@maxlength"/></xsl:when>
8196
+ <xsl:when test="normalize-space(@size) != ''"><xsl:value-of select="@size"/></xsl:when>
8197
+ <xsl:otherwise>10</xsl:otherwise>
8198
+ </xsl:choose>
8199
+ </xsl:variable>
8200
+ <xsl:call-template name="repeat">
8201
+ <xsl:with-param name="char" select="'_'"/>
8202
+ <xsl:with-param name="count" select="$count"/>
8203
+ </xsl:call-template>
8204
+ <xsl:text> </xsl:text>
8205
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'button']">
8206
+ <xsl:variable name="caption">
8207
+ <xsl:choose>
8208
+ <xsl:when test="normalize-space(@value) != ''"><xsl:value-of select="@value"/></xsl:when>
8209
+ <xsl:otherwise>BUTTON</xsl:otherwise>
8210
+ </xsl:choose>
8211
+ </xsl:variable>
8212
+ <fo:inline>[<xsl:value-of select="$caption"/>]</fo:inline>
8213
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'checkbox']">
8214
+ <fo:inline padding-right="1mm">
8215
+ <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%">
8216
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
8217
+ <xsl:attribute name="content-width">100%</xsl:attribute>
8218
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
8219
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
8220
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
8221
+ <polyline points="0,0 80,0 80,80 0,80 0,0" stroke="black" stroke-width="5" fill="white"/>
8222
+ </svg>
8223
+ </fo:instream-foreign-object>
8224
+ </fo:inline>
8225
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'radio']">
8226
+ <fo:inline padding-right="1mm">
8227
+ <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%">
8228
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
8229
+ <xsl:attribute name="content-width">100%</xsl:attribute>
8230
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
8231
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
8232
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
8233
+ <circle cx="40" cy="40" r="30" stroke="black" stroke-width="5" fill="white"/>
8234
+ <circle cx="40" cy="40" r="15" stroke="black" stroke-width="5" fill="white"/>
8235
+ </svg>
8236
+ </fo:instream-foreign-object>
8237
+ </fo:inline>
8238
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'select']">
8239
+ <fo:inline>
8240
+ <xsl:call-template name="text_input"/>
8241
+ </fo:inline>
8242
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'textarea']">
8243
+ <fo:block-container border="1pt solid black" width="50%">
8244
+ <fo:block> </fo:block>
8245
+ </fo:block-container>
8181
8246
  </xsl:template><xsl:template name="convertDate">
8182
8247
  <xsl:param name="date"/>
8183
8248
  <xsl:param name="format" select="'short'"/>
@@ -5485,6 +5485,7 @@
5485
5485
 
5486
5486
 
5487
5487
 
5488
+
5488
5489
  <xsl:attribute name="border">solid 0pt white</xsl:attribute>
5489
5490
  <xsl:variable name="rownum"><xsl:number count="*[local-name()='tr']"/></xsl:variable>
5490
5491
  <xsl:if test="$rownum = 1">
@@ -8178,6 +8179,70 @@
8178
8179
  <xsl:value-of select="substring(.,1,1)"/>
8179
8180
  </xsl:template><xsl:template match="*[local-name() = 'title']" mode="title">
8180
8181
  <fo:inline><xsl:apply-templates/></fo:inline>
8182
+ </xsl:template><xsl:template match="*[local-name() = 'form']">
8183
+ <fo:block>
8184
+ <xsl:apply-templates/>
8185
+ </fo:block>
8186
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'label']">
8187
+ <fo:inline><xsl:apply-templates/></fo:inline>
8188
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'text' or @type = 'date' or @type = 'file' or @type = 'password']">
8189
+ <fo:inline>
8190
+ <xsl:call-template name="text_input"/>
8191
+ </fo:inline>
8192
+ </xsl:template><xsl:template name="text_input">
8193
+ <xsl:variable name="count">
8194
+ <xsl:choose>
8195
+ <xsl:when test="normalize-space(@maxlength) != ''"><xsl:value-of select="@maxlength"/></xsl:when>
8196
+ <xsl:when test="normalize-space(@size) != ''"><xsl:value-of select="@size"/></xsl:when>
8197
+ <xsl:otherwise>10</xsl:otherwise>
8198
+ </xsl:choose>
8199
+ </xsl:variable>
8200
+ <xsl:call-template name="repeat">
8201
+ <xsl:with-param name="char" select="'_'"/>
8202
+ <xsl:with-param name="count" select="$count"/>
8203
+ </xsl:call-template>
8204
+ <xsl:text> </xsl:text>
8205
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'button']">
8206
+ <xsl:variable name="caption">
8207
+ <xsl:choose>
8208
+ <xsl:when test="normalize-space(@value) != ''"><xsl:value-of select="@value"/></xsl:when>
8209
+ <xsl:otherwise>BUTTON</xsl:otherwise>
8210
+ </xsl:choose>
8211
+ </xsl:variable>
8212
+ <fo:inline>[<xsl:value-of select="$caption"/>]</fo:inline>
8213
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'checkbox']">
8214
+ <fo:inline padding-right="1mm">
8215
+ <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%">
8216
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
8217
+ <xsl:attribute name="content-width">100%</xsl:attribute>
8218
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
8219
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
8220
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
8221
+ <polyline points="0,0 80,0 80,80 0,80 0,0" stroke="black" stroke-width="5" fill="white"/>
8222
+ </svg>
8223
+ </fo:instream-foreign-object>
8224
+ </fo:inline>
8225
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'radio']">
8226
+ <fo:inline padding-right="1mm">
8227
+ <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%">
8228
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
8229
+ <xsl:attribute name="content-width">100%</xsl:attribute>
8230
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
8231
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
8232
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
8233
+ <circle cx="40" cy="40" r="30" stroke="black" stroke-width="5" fill="white"/>
8234
+ <circle cx="40" cy="40" r="15" stroke="black" stroke-width="5" fill="white"/>
8235
+ </svg>
8236
+ </fo:instream-foreign-object>
8237
+ </fo:inline>
8238
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'select']">
8239
+ <fo:inline>
8240
+ <xsl:call-template name="text_input"/>
8241
+ </fo:inline>
8242
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'textarea']">
8243
+ <fo:block-container border="1pt solid black" width="50%">
8244
+ <fo:block> </fo:block>
8245
+ </fo:block-container>
8181
8246
  </xsl:template><xsl:template name="convertDate">
8182
8247
  <xsl:param name="date"/>
8183
8248
  <xsl:param name="format" select="'short'"/>
@@ -5485,6 +5485,7 @@
5485
5485
 
5486
5486
 
5487
5487
 
5488
+
5488
5489
  <xsl:attribute name="border">solid 0pt white</xsl:attribute>
5489
5490
  <xsl:variable name="rownum"><xsl:number count="*[local-name()='tr']"/></xsl:variable>
5490
5491
  <xsl:if test="$rownum = 1">
@@ -8178,6 +8179,70 @@
8178
8179
  <xsl:value-of select="substring(.,1,1)"/>
8179
8180
  </xsl:template><xsl:template match="*[local-name() = 'title']" mode="title">
8180
8181
  <fo:inline><xsl:apply-templates/></fo:inline>
8182
+ </xsl:template><xsl:template match="*[local-name() = 'form']">
8183
+ <fo:block>
8184
+ <xsl:apply-templates/>
8185
+ </fo:block>
8186
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'label']">
8187
+ <fo:inline><xsl:apply-templates/></fo:inline>
8188
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'text' or @type = 'date' or @type = 'file' or @type = 'password']">
8189
+ <fo:inline>
8190
+ <xsl:call-template name="text_input"/>
8191
+ </fo:inline>
8192
+ </xsl:template><xsl:template name="text_input">
8193
+ <xsl:variable name="count">
8194
+ <xsl:choose>
8195
+ <xsl:when test="normalize-space(@maxlength) != ''"><xsl:value-of select="@maxlength"/></xsl:when>
8196
+ <xsl:when test="normalize-space(@size) != ''"><xsl:value-of select="@size"/></xsl:when>
8197
+ <xsl:otherwise>10</xsl:otherwise>
8198
+ </xsl:choose>
8199
+ </xsl:variable>
8200
+ <xsl:call-template name="repeat">
8201
+ <xsl:with-param name="char" select="'_'"/>
8202
+ <xsl:with-param name="count" select="$count"/>
8203
+ </xsl:call-template>
8204
+ <xsl:text> </xsl:text>
8205
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'button']">
8206
+ <xsl:variable name="caption">
8207
+ <xsl:choose>
8208
+ <xsl:when test="normalize-space(@value) != ''"><xsl:value-of select="@value"/></xsl:when>
8209
+ <xsl:otherwise>BUTTON</xsl:otherwise>
8210
+ </xsl:choose>
8211
+ </xsl:variable>
8212
+ <fo:inline>[<xsl:value-of select="$caption"/>]</fo:inline>
8213
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'checkbox']">
8214
+ <fo:inline padding-right="1mm">
8215
+ <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%">
8216
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
8217
+ <xsl:attribute name="content-width">100%</xsl:attribute>
8218
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
8219
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
8220
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
8221
+ <polyline points="0,0 80,0 80,80 0,80 0,0" stroke="black" stroke-width="5" fill="white"/>
8222
+ </svg>
8223
+ </fo:instream-foreign-object>
8224
+ </fo:inline>
8225
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'radio']">
8226
+ <fo:inline padding-right="1mm">
8227
+ <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%">
8228
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
8229
+ <xsl:attribute name="content-width">100%</xsl:attribute>
8230
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
8231
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
8232
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
8233
+ <circle cx="40" cy="40" r="30" stroke="black" stroke-width="5" fill="white"/>
8234
+ <circle cx="40" cy="40" r="15" stroke="black" stroke-width="5" fill="white"/>
8235
+ </svg>
8236
+ </fo:instream-foreign-object>
8237
+ </fo:inline>
8238
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'select']">
8239
+ <fo:inline>
8240
+ <xsl:call-template name="text_input"/>
8241
+ </fo:inline>
8242
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'textarea']">
8243
+ <fo:block-container border="1pt solid black" width="50%">
8244
+ <fo:block> </fo:block>
8245
+ </fo:block-container>
8181
8246
  </xsl:template><xsl:template name="convertDate">
8182
8247
  <xsl:param name="date"/>
8183
8248
  <xsl:param name="format" select="'short'"/>
@@ -1,5 +1,6 @@
1
1
  annex: Appendix
2
2
  appendix: Annex
3
+ iso_annex: Annex
3
4
  see: see
4
5
  see_also: see also
5
6
  clause: Chapter
@@ -17,3 +18,4 @@ norm_with_refs_pref:
17
18
  document (including any amendments) applies.
18
19
  all_rights_reserved: All rights reserved
19
20
  table_of_contents: Contents
21
+ source: Adapted from
@@ -1,5 +1,6 @@
1
1
  annex: Annexe
2
2
  appendix: Appendice
3
+ iso_annex: Annexe
3
4
  see: voir
4
5
  see_also: voir aussi
5
6
  clause: chapître
@@ -40,3 +41,4 @@ norm_with_refs_pref:
40
41
  Les documents suivants cités dans le texte sont indispensables pour l'application de ce document. Pour les références datées, seule l’édition citée s’applique. Pour les références non datées, la dernière édition du document de référence s’applique (y compris les éventuels amendements).
41
42
  all_rights_reserved: Tous droits réservés
42
43
  table_of_contents: Table des matières
44
+ source: Adapté de
@@ -10,14 +10,17 @@ module IsoDoc
10
10
 
11
11
  def index(docxml)
12
12
  unless docxml.at(ns("//index"))
13
- docxml.xpath(ns("//indexsect")).each { |i| i.remove }
13
+ docxml.xpath(ns("//indexsect")).each(&:remove)
14
14
  return
15
15
  end
16
16
  i = docxml.at(ns("//indexsect")) ||
17
- docxml.root.add_child("<indexsect #{add_id}><title>#{@i18n.index}</title></indexsect>").first
18
- index = sort_indexterms(docxml.xpath(ns("//index")),
19
- docxml.xpath(ns("//index-xref[@also = 'false']")),
20
- docxml.xpath(ns("//index-xref[@also = 'true']")))
17
+ docxml.root.add_child("<indexsect #{add_id}><title>#{@i18n.index}"\
18
+ "</title></indexsect>").first
19
+ index = sort_indexterms(
20
+ docxml.xpath(ns("//index")),
21
+ docxml.xpath(ns("//index-xref[@also = 'false']")),
22
+ docxml.xpath(ns("//index-xref[@also = 'true']"))
23
+ )
21
24
  index1(docxml, i, index)
22
25
  end
23
26
 
@@ -33,8 +36,8 @@ module IsoDoc
33
36
  @xrefs.bookmark_anchor_names(docxml)
34
37
  end
35
38
 
36
- def sortable(s)
37
- HTMLEntities.new.decode(Nokogiri::XML.fragment(s).text)
39
+ def sortable(str)
40
+ HTMLEntities.new.decode(Nokogiri::XML.fragment(str).text)
38
41
  end
39
42
 
40
43
  def index_entries_opt
@@ -45,7 +48,7 @@ module IsoDoc
45
48
  ret = index_entries_head(words[primary],
46
49
  index.dig(words[primary], nil, nil),
47
50
  index_entries_opt)
48
- words2 = index[words[primary]]&.keys&.reject { |k| k.nil? }
51
+ words2 = index[words[primary]]&.keys&.compact
49
52
  &.each_with_object({}) { |w, v| v[w.downcase] = w }
50
53
  unless words2.empty?
51
54
  ret += "<ul>"
@@ -54,7 +57,7 @@ module IsoDoc
54
57
  end
55
58
  ret += "</ul>"
56
59
  end
57
- ret + "</li>"
60
+ "#{ret}</li>"
58
61
  end
59
62
 
60
63
  def index_entries2(words, index, secondary)
@@ -70,7 +73,7 @@ module IsoDoc
70
73
  end
71
74
  ret += "</ul>"
72
75
  end
73
- ret + "</li>"
76
+ "#{ret}</li>"
74
77
  end
75
78
 
76
79
  def index_entries_head(head, entries, opt)
@@ -118,8 +121,9 @@ module IsoDoc
118
121
  end
119
122
  end
120
123
 
121
- def xml_encode_attr(s)
122
- HTMLEntities.new.encode(s, :basic, :hexadecimal).gsub(/\&#x([^;]+);/) { |x| "&#x#{$1.upcase};" }
124
+ def xml_encode_attr(str)
125
+ HTMLEntities.new.encode(str, :basic, :hexadecimal)
126
+ .gsub(/&#x([^;]+);/) { |_x| "&#x#{$1.upcase};" }
123
127
  end
124
128
 
125
129
  # attributes are decoded into UTF-8, elements in extract_indexsee are still in entities
@@ -138,10 +142,10 @@ module IsoDoc
138
142
  end
139
143
  end
140
144
 
141
- def index2bookmark(t)
142
- t.name = "bookmark"
143
- t.children.each { |x| x.remove }
144
- t["id"] = "_#{UUIDTools::UUID.random_create}"
145
+ def index2bookmark(node)
146
+ node.name = "bookmark"
147
+ node.children.each(&:remove)
148
+ node["id"] = "_#{UUIDTools::UUID.random_create}"
145
149
  end
146
150
  end
147
151
  end
@@ -10,7 +10,7 @@ module IsoDoc
10
10
  @meta = Metadata.new(lang, script, labels)
11
11
  end
12
12
 
13
- def xref_init(lang, script, klass, labels, options)
13
+ def xref_init(lang, script, _klass, labels, options)
14
14
  html = HtmlConvert.new(language: lang, script: script)
15
15
  @xrefs = Xref.new(lang, script, html, labels, options)
16
16
  end
@@ -21,4 +21,3 @@ module IsoDoc
21
21
  end
22
22
  end
23
23
  end
24
-
@@ -1022,7 +1022,7 @@
1022
1022
  <xsl:apply-templates select="." mode="mathml"/>
1023
1023
  </xsl:variable>
1024
1024
  <fo:instream-foreign-object fox:alt-text="Math">
1025
- <xsl:if test="local-name(../..) = 'formula'">
1025
+ <xsl:if test="local-name(../..) = 'formula' or (local-name(../..) = 'td' and count(../../*) = 1)">
1026
1026
  <xsl:attribute name="width">95%</xsl:attribute>
1027
1027
  <xsl:attribute name="content-height">100%</xsl:attribute>
1028
1028
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
@@ -3431,6 +3431,11 @@
3431
3431
  <xsl:attribute name="padding-top">0.5mm</xsl:attribute>
3432
3432
 
3433
3433
 
3434
+ <xsl:if test="count(*) = 1 and (local-name(*[1]) = 'stem' or local-name(*[1]) = 'figure')">
3435
+ <xsl:attribute name="padding-left">0mm</xsl:attribute>
3436
+ </xsl:if>
3437
+
3438
+
3434
3439
 
3435
3440
  <xsl:if test="ancestor::*[local-name() = 'tfoot']">
3436
3441
  <xsl:attribute name="border">solid black 0</xsl:attribute>
@@ -5761,6 +5766,10 @@
5761
5766
  <xsl:call-template name="setId"/>
5762
5767
 
5763
5768
 
5769
+ <xsl:if test="@inline-header='true'">
5770
+ <xsl:attribute name="text-align">justify</xsl:attribute>
5771
+ </xsl:if>
5772
+
5764
5773
  <xsl:apply-templates/>
5765
5774
  </fo:block>
5766
5775
  </xsl:template><xsl:template match="*[local-name() = 'definitions']">
@@ -6054,6 +6063,70 @@
6054
6063
  <xsl:value-of select="substring(.,1,1)"/>
6055
6064
  </xsl:template><xsl:template match="*[local-name() = 'title']" mode="title">
6056
6065
  <fo:inline><xsl:apply-templates/></fo:inline>
6066
+ </xsl:template><xsl:template match="*[local-name() = 'form']">
6067
+ <fo:block>
6068
+ <xsl:apply-templates/>
6069
+ </fo:block>
6070
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'label']">
6071
+ <fo:inline><xsl:apply-templates/></fo:inline>
6072
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'text' or @type = 'date' or @type = 'file' or @type = 'password']">
6073
+ <fo:inline>
6074
+ <xsl:call-template name="text_input"/>
6075
+ </fo:inline>
6076
+ </xsl:template><xsl:template name="text_input">
6077
+ <xsl:variable name="count">
6078
+ <xsl:choose>
6079
+ <xsl:when test="normalize-space(@maxlength) != ''"><xsl:value-of select="@maxlength"/></xsl:when>
6080
+ <xsl:when test="normalize-space(@size) != ''"><xsl:value-of select="@size"/></xsl:when>
6081
+ <xsl:otherwise>10</xsl:otherwise>
6082
+ </xsl:choose>
6083
+ </xsl:variable>
6084
+ <xsl:call-template name="repeat">
6085
+ <xsl:with-param name="char" select="'_'"/>
6086
+ <xsl:with-param name="count" select="$count"/>
6087
+ </xsl:call-template>
6088
+ <xsl:text> </xsl:text>
6089
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'button']">
6090
+ <xsl:variable name="caption">
6091
+ <xsl:choose>
6092
+ <xsl:when test="normalize-space(@value) != ''"><xsl:value-of select="@value"/></xsl:when>
6093
+ <xsl:otherwise>BUTTON</xsl:otherwise>
6094
+ </xsl:choose>
6095
+ </xsl:variable>
6096
+ <fo:inline>[<xsl:value-of select="$caption"/>]</fo:inline>
6097
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'checkbox']">
6098
+ <fo:inline padding-right="1mm">
6099
+ <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%">
6100
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
6101
+ <xsl:attribute name="content-width">100%</xsl:attribute>
6102
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6103
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
6104
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
6105
+ <polyline points="0,0 80,0 80,80 0,80 0,0" stroke="black" stroke-width="5" fill="white"/>
6106
+ </svg>
6107
+ </fo:instream-foreign-object>
6108
+ </fo:inline>
6109
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'radio']">
6110
+ <fo:inline padding-right="1mm">
6111
+ <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%">
6112
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
6113
+ <xsl:attribute name="content-width">100%</xsl:attribute>
6114
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6115
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
6116
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
6117
+ <circle cx="40" cy="40" r="30" stroke="black" stroke-width="5" fill="white"/>
6118
+ <circle cx="40" cy="40" r="15" stroke="black" stroke-width="5" fill="white"/>
6119
+ </svg>
6120
+ </fo:instream-foreign-object>
6121
+ </fo:inline>
6122
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'select']">
6123
+ <fo:inline>
6124
+ <xsl:call-template name="text_input"/>
6125
+ </fo:inline>
6126
+ </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'textarea']">
6127
+ <fo:block-container border="1pt solid black" width="50%">
6128
+ <fo:block> </fo:block>
6129
+ </fo:block-container>
6057
6130
  </xsl:template><xsl:template name="convertDate">
6058
6131
  <xsl:param name="date"/>
6059
6132
  <xsl:param name="format" select="'short'"/>
@@ -25,29 +25,46 @@ module IsoDoc
25
25
  end
26
26
  end
27
27
 
28
- def table1(f)
29
- return if labelled_ancestor(f)
30
- return if f["unnumbered"]
28
+ def table1(elem)
29
+ return if labelled_ancestor(elem)
30
+ return if elem["unnumbered"]
31
31
 
32
- n = @xrefs.anchor(f["id"], :label, false)
33
- prefix_name(f, ".<tab/>", l10n("#{@i18n.table.capitalize} #{n}"), "name")
32
+ n = @xrefs.anchor(elem["id"], :label, false)
33
+ prefix_name(elem, ".<tab/>",
34
+ l10n("#{@i18n.table.capitalize} #{n}"), "name")
34
35
  end
35
36
 
36
- def annex1(f)
37
+ def figure1(elem)
38
+ if @jcgm
39
+ @iso.xrefs = @xrefs
40
+ @iso.figure1(elem)
41
+ else super
42
+ end
43
+ end
44
+
45
+ def annex1(elem)
37
46
  return super if @jcgm
38
- return if f["unnumbered"] == "true"
47
+ return if elem["unnumbered"] == "true"
39
48
 
40
- lbl = @xrefs.anchor(f["id"], :label)
41
- if t = f.at(ns("./title"))
49
+ lbl = @xrefs.anchor(elem["id"], :label)
50
+ if t = elem.at(ns("./title"))
42
51
  t.children = "<strong>#{t.children.to_xml}</strong>"
43
52
  end
44
- prefix_name(f, ".<tab/>", lbl, "title")
53
+ prefix_name(elem, ".<tab/>", lbl, "title")
45
54
  end
46
55
 
47
- def clause1(f)
48
- return if f["unnumbered"] == "true"
49
- return if f.at(("./ancestor::*[@unnumbered = 'true']"))
56
+ def clause(docxml)
57
+ super
58
+ if @jcgm
59
+ docxml.xpath(ns("//preface/introduction[clause]")).each do |f|
60
+ clause1(f)
61
+ end
62
+ end
63
+ end
50
64
 
65
+ def clause1(elem)
66
+ return if elem["unnumbered"] == "true"
67
+ return if elem.at(("./ancestor::*[@unnumbered = 'true']"))
51
68
  super
52
69
  end
53
70
 
@@ -56,31 +73,32 @@ module IsoDoc
56
73
  doccontrol docxml
57
74
  end
58
75
 
59
- def doccontrol(docxml)
60
- return unless docxml.at(ns("//bibdata/relation[@type = 'supersedes']"))
76
+ def doccontrol(doc)
77
+ return unless doc.at(ns("//bibdata/relation[@type = 'supersedes']"))
61
78
 
62
- clause = <<~END
79
+ clause = <<~DOCCONTROL
63
80
  <doccontrol>
64
81
  <title>Document Control</title>
65
82
  <table unnumbered="true"><tbody>
66
- <tr><th>Authors:</th><td/><td>#{list_authors(docxml)}</td></tr>
67
- #{doccontrol_row1(docxml)} #{doccontrol_row2(docxml)} #{list_drafts(docxml)}
83
+ <tr><th>Authors:</th><td/><td>#{list_authors(doc)}</td></tr>
84
+ #{doccontrol_row1(doc)} #{doccontrol_row2(doc)} #{list_drafts(doc)}
68
85
  </tbody></table></doccontrol>
69
- END
70
- docxml.root << clause
86
+ DOCCONTROL
87
+ doc.root << clause
71
88
  end
72
89
 
73
- def doccontrol_row1(docxml)
74
- return "" if list_draft(docxml, 1) == ["", ""] && list_cochairs(docxml).empty?
90
+ def doccontrol_row1(doc)
91
+ return "" if list_draft(doc, 1) == ["", ""] && list_cochairs(doc).empty?
75
92
 
76
93
  <<~ROW
77
- <tr>#{list_draft(docxml, 1)&.map { |x| "<td>#{x}</td>" }&.join}
78
- <td>#{list_cochairs(docxml)}</td></tr>
94
+ <tr>#{list_draft(doc, 1)&.map { |x| "<td>#{x}</td>" }&.join}
95
+ <td>#{list_cochairs(doc)}</td></tr>
79
96
  ROW
80
97
  end
81
98
 
82
99
  def doccontrol_row2(docxml)
83
- return "" if list_draft(docxml, 2) == ["", ""] && list_chairs(docxml).empty?
100
+ list_draft(docxml, 2) == ["", ""] && list_chairs(docxml).empty? and
101
+ return ""
84
102
 
85
103
  <<~ROW
86
104
  <tr>#{list_draft(docxml, 2)&.map { |x| "<td>#{x}</td>" }&.join}
@@ -99,15 +117,13 @@ module IsoDoc
99
117
  ret
100
118
  end
101
119
 
102
- def list_draft(xml, i)
103
- return ["", ""] unless d =
104
- xml.at(ns("//bibdata/relation[@type = 'supersedes'][#{i}]/bibitem"))
120
+ def list_draft(xml, idx)
121
+ d = xml.at(ns("//bibdata/relation[@type = 'supersedes'][#{idx}]"\
122
+ "/bibitem")) or return ["", ""]
105
123
 
106
124
  date = d&.at(ns("./date"))&.text
107
- draft = d&.at(ns("./version/draft"))&.text and
108
- draft = "Draft #{draft}"
109
- edn = d&.at(ns("./edition"))&.text and
110
- edn = "Version #{edn}"
125
+ draft = d&.at(ns("./version/draft"))&.text and draft = "Draft #{draft}"
126
+ edn = d&.at(ns("./edition"))&.text and edn = "Version #{edn}"
111
127
  [[draft, edn].join(" "), date]
112
128
  end
113
129
 
@@ -156,8 +172,8 @@ module IsoDoc
156
172
  fraction_group_digits: 3 }
157
173
  end
158
174
 
159
- def mathml1(f, locale)
160
- localize_maths(f, locale)
175
+ def mathml1(elem, locale)
176
+ localize_maths(elem, locale)
161
177
  end
162
178
 
163
179
  def bibdata_i18n(bibdata)
@@ -175,6 +191,49 @@ module IsoDoc
175
191
  pubdate.next.children = meta.monthyr(pubdate.text)
176
192
  end
177
193
 
194
+ def eref(docxml)
195
+ super
196
+ jcgm_eref(docxml, "//eref")
197
+ end
198
+
199
+ def origin(docxml)
200
+ super
201
+ jcgm_eref(docxml, "//origin[not(termref)]")
202
+ end
203
+
204
+ def quotesource(docxml)
205
+ super
206
+ jcgm_eref(docxml, "//quote/source")
207
+ end
208
+
209
+ def jcgm_eref(docxml, xpath)
210
+ return unless @jcgm
211
+
212
+ docxml.xpath(ns(xpath)).each do |x|
213
+ extract_brackets(x)
214
+ end
215
+ # merge adjacent text nodes
216
+ docxml.root.replace(Nokogiri::XML(docxml.root.to_xml).root)
217
+ docxml.xpath(ns(xpath)).each do |x| # rubocop: disable Style/CombinableLoops
218
+ if x&.next&.text? && /^\],\s+\[$/.match?(x&.next&.text) &&
219
+ %w(eref origin source).include?(x&.next&.next&.name)
220
+ x.next.replace(", ")
221
+ end
222
+ end
223
+ end
224
+
225
+ def extract_brackets(node)
226
+ start = node.at("./text()[1]")
227
+ finish = node.at("./text()[last()]")
228
+ if /^\[/.match?(start.text) && /\]$/.match?(finish.text)
229
+ start.replace(start.text[1..-1])
230
+ node.previous = "["
231
+ finish = node.at("./text()[last()]")
232
+ finish.replace(finish.text[0..-2])
233
+ node.next = "]"
234
+ end
235
+ end
236
+
178
237
  include Init
179
238
  end
180
239
  end
@@ -5,6 +5,7 @@ module IsoDoc
5
5
 
6
6
  class Xref < IsoDoc::Xref
7
7
  def initialize(lang, script, klass, i18n, options = {})
8
+ @iso = IsoDoc::Iso::Xref.new(lang, script, klass, i18n, options)
8
9
  super
9
10
  end
10
11
 
@@ -12,10 +13,10 @@ module IsoDoc
12
13
  @jcgm = docxml&.at(ns("//bibdata/ext/editorialgroup/committee/"\
13
14
  "@acronym"))&.value == "JCGM"
14
15
  @annexlbl =
15
- if docxml.at(ns("//bibdata/ext/structuredidentifier/appendix"))
16
+ if @jcgm then @labels["iso_annex"]
17
+ elsif docxml.at(ns("//bibdata/ext/structuredidentifier/appendix"))
16
18
  @labels["appendix"]
17
- else
18
- @labels["annex"]
19
+ else @labels["annex"]
19
20
  end
20
21
  super
21
22
  end
@@ -28,9 +29,8 @@ module IsoDoc
28
29
 
29
30
  def reference_names(ref)
30
31
  super
31
- if @jcgm
32
+ @jcgm and
32
33
  @anchors[ref["id"]][:xref] = wrap_brackets(@anchors[ref["id"]][:xref])
33
- end
34
34
  end
35
35
 
36
36
  def clause_names(docxml, sect_num)
@@ -109,8 +109,7 @@ module IsoDoc
109
109
  def section_name1_anchors(clause, num, level)
110
110
  lbl = @jcgm ? "" : "#{@labels['subclause']} "
111
111
  @anchors[clause["id"]] =
112
- { label: num, level: level,
113
- xref: l10n("#{lbl}#{num}"),
112
+ { label: num, level: level, xref: l10n("#{lbl}#{num}"),
114
113
  type: "clause" }
115
114
  end
116
115
 
@@ -226,6 +225,30 @@ module IsoDoc
226
225
  )
227
226
  end
228
227
  end
228
+
229
+ def initial_anchor_names(doc)
230
+ super
231
+ if @jcgm
232
+ @iso.introduction_names(doc.at(ns("//introduction")))
233
+ @anchors.merge!(@iso.get)
234
+ end
235
+ end
236
+
237
+ def sequential_figure_names(clause)
238
+ if @jcgm
239
+ @iso.sequential_figure_names(clause)
240
+ @anchors.merge!(@iso.get)
241
+ else super
242
+ end
243
+ end
244
+
245
+ def hierarchical_figure_names(clause, num)
246
+ if @jcgm
247
+ @iso.hierarchical_figure_names(clause, num)
248
+ @anchors.merge!(@iso.get)
249
+ else super
250
+ end
251
+ end
229
252
  end
230
253
  end
231
254
  end
@@ -1,9 +1,9 @@
1
- require 'metanorma'
2
- require 'metanorma/bipm'
1
+ require "metanorma"
2
+ require "metanorma/bipm"
3
3
  require "isodoc/bipm"
4
4
 
5
- require 'asciidoctor' unless defined? Asciidoctor::Converter
6
- require 'asciidoctor/bipm'
5
+ require "asciidoctor" unless defined? Asciidoctor::Converter
6
+ require "asciidoctor/bipm"
7
7
 
8
8
  if defined? Metanorma
9
9
  require_relative "metanorma/bipm"
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module BIPM
3
- VERSION = "1.1.1".freeze
3
+ VERSION = "1.1.2".freeze
4
4
  end
5
5
  end
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: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-26 00:00:00.000000000 Z
11
+ date: 2021-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic