metanorma-un 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -876,6 +876,10 @@
876
876
  <xsl:text>Édition </xsl:text>
877
877
  </title-edition>
878
878
 
879
+ <title-edition lang="ru">
880
+ <xsl:text>Издание </xsl:text>
881
+ </title-edition>
882
+
879
883
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
880
884
  <title-toc lang="en">
881
885
 
@@ -904,7 +908,11 @@
904
908
 
905
909
 
906
910
 
907
- </title-part>
911
+ </title-part>
912
+ <title-part lang="ru">
913
+
914
+
915
+ </title-part>
908
916
  <title-part lang="zh">第 # 部分:</title-part>
909
917
 
910
918
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -920,6 +928,7 @@
920
928
 
921
929
  <title-summary lang="en">Summary</title-summary>
922
930
 
931
+ <title-continued lang="ru">(продолжение)</title-continued>
923
932
  <title-continued lang="en">(continued)</title-continued>
924
933
  <title-continued lang="fr">(continué)</title-continued>
925
934
 
@@ -1631,13 +1640,19 @@
1631
1640
  </xsl:attribute-set><xsl:variable name="color-added-text">
1632
1641
  <xsl:text>rgb(0, 255, 0)</xsl:text>
1633
1642
  </xsl:variable><xsl:attribute-set name="add-style">
1634
- <xsl:attribute name="color">red</xsl:attribute>
1635
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
1636
- <!-- <xsl:attribute name="color">black</xsl:attribute>
1637
- <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1638
- <xsl:attribute name="padding-top">1mm</xsl:attribute>
1639
- <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1640
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
1643
+
1644
+ <xsl:attribute name="color">red</xsl:attribute>
1645
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
1646
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
1647
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1648
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
1649
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1650
+
1651
+ </xsl:attribute-set><xsl:variable name="add-style">
1652
+ <add-style xsl:use-attribute-sets="add-style"/>
1653
+ </xsl:variable><xsl:template name="append_add-style">
1654
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
1655
+ </xsl:template><xsl:variable name="color-deleted-text">
1641
1656
  <xsl:text>red</xsl:text>
1642
1657
  </xsl:variable><xsl:attribute-set name="del-style">
1643
1658
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -2069,14 +2084,42 @@
2069
2084
 
2070
2085
 
2071
2086
  </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:variable name="ace_tag">ace-tag_</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents">
2087
+ <xsl:variable name="nodes_preface_">
2088
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
2089
+ <node id="{@id}"/>
2090
+ </xsl:for-each>
2091
+ </xsl:variable>
2092
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
2093
+
2072
2094
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2073
2095
  <xsl:sort select="@displayorder" data-type="number"/>
2096
+
2097
+ <!-- process Section's title -->
2098
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2099
+ <xsl:if test="$preceding-sibling_id != ''">
2100
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2101
+ </xsl:if>
2102
+
2074
2103
  <xsl:apply-templates select="." mode="contents"/>
2075
2104
  </xsl:for-each>
2076
2105
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
2077
2106
 
2107
+ <xsl:variable name="nodes_sections_">
2108
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
2109
+ <node id="{@id}"/>
2110
+ </xsl:for-each>
2111
+ </xsl:variable>
2112
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
2113
+
2078
2114
  <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true'] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][@normative='true']]">
2079
2115
  <xsl:sort select="@displayorder" data-type="number"/>
2116
+
2117
+ <!-- process Section's title -->
2118
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2119
+ <xsl:if test="$preceding-sibling_id != ''">
2120
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2121
+ </xsl:if>
2122
+
2080
2123
  <xsl:apply-templates select="." mode="contents"/>
2081
2124
  </xsl:for-each>
2082
2125
 
@@ -2215,7 +2258,7 @@
2215
2258
  </xsl:call-template>
2216
2259
  </xsl:if>
2217
2260
  </xsl:variable>
2218
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
2261
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
2219
2262
 
2220
2263
 
2221
2264
  <xsl:variable name="margin-side">
@@ -2492,7 +2535,7 @@
2492
2535
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2493
2536
  <!-- 2009 thinspace -->
2494
2537
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
2495
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
2538
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
2496
2539
  </xsl:call-template>
2497
2540
  </xsl:variable>
2498
2541
  <xsl:variable name="max_length">
@@ -4140,6 +4183,9 @@
4140
4183
  </fo:inline>
4141
4184
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
4142
4185
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
4186
+ <xsl:if test="parent::*[local-name() = 'add']">
4187
+ <xsl:call-template name="append_add-style"/>
4188
+ </xsl:if>
4143
4189
  <xsl:apply-templates/>
4144
4190
  </fo:basic-link>
4145
4191
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -4255,6 +4301,13 @@
4255
4301
 
4256
4302
 
4257
4303
 
4304
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4305
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4306
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4307
+ <xsl:call-template name="append_add-style"/>
4308
+ </xsl:if>
4309
+
4310
+
4258
4311
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
4259
4312
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
4260
4313
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -4293,6 +4346,12 @@
4293
4346
 
4294
4347
 
4295
4348
 
4349
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4350
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4351
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4352
+ <xsl:call-template name="append_add-style"/>
4353
+ </xsl:if>
4354
+
4296
4355
  <xsl:apply-templates select="*[local-name() = 'name']"/>
4297
4356
 
4298
4357
  </fo:inline>
@@ -4346,6 +4405,7 @@
4346
4405
  </fo:block>
4347
4406
  </xsl:template><xsl:template match="*[local-name() = 'term']">
4348
4407
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
4408
+
4349
4409
 
4350
4410
 
4351
4411
 
@@ -4787,7 +4847,11 @@
4787
4847
  <xsl:value-of select="."/>
4788
4848
  </xsl:template><xsl:template match="node()" mode="contents">
4789
4849
  <xsl:apply-templates mode="contents"/>
4790
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
4850
+ </xsl:template><xsl:template match="*[local-name() = 'preface' or local-name() = 'sections']/*[local-name() = 'p'][@type = 'section-title' and not(@displayorder)]" priority="3" mode="contents"/><xsl:template match="*[local-name() = 'p'][@type = 'section-title' and not(@displayorder)]" mode="contents_no_displayorder">
4851
+ <xsl:call-template name="contents_section-title"/>
4852
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
4853
+ <xsl:call-template name="contents_section-title"/>
4854
+ </xsl:template><xsl:template match="*[local-name() = 'clause']/*[local-name() = 'p'][@type = 'section-title' and (@depth != ../*[local-name() = 'title']/@depth or ../*[local-name() = 'title']/@depth = 1)]" priority="3" mode="contents"/><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" name="contents_section-title" mode="contents">
4791
4855
  <xsl:variable name="level">
4792
4856
  <xsl:call-template name="getLevel">
4793
4857
  <xsl:with-param name="depth" select="@depth"/>
@@ -6104,7 +6168,7 @@
6104
6168
 
6105
6169
 
6106
6170
 
6107
-
6171
+
6108
6172
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
6109
6173
  </fo:list-block>
6110
6174
  <!-- <xsl:for-each select="./iho:note">
@@ -6122,6 +6186,11 @@
6122
6186
 
6123
6187
 
6124
6188
 
6189
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
6190
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
6191
+ <xsl:call-template name="append_add-style"/>
6192
+ </xsl:if>
6193
+
6125
6194
  <xsl:call-template name="getListItemFormat"/>
6126
6195
  </fo:block>
6127
6196
  </fo:list-item-label>
@@ -7178,53 +7247,153 @@
7178
7247
  <xsl:param name="first"/>
7179
7248
  <xsl:if test="$number != ''">
7180
7249
  <xsl:variable name="words">
7181
- <words>
7182
- <word cardinal="1">One-</word>
7183
- <word ordinal="1">First </word>
7184
- <word cardinal="2">Two-</word>
7185
- <word ordinal="2">Second </word>
7186
- <word cardinal="3">Three-</word>
7187
- <word ordinal="3">Third </word>
7188
- <word cardinal="4">Four-</word>
7189
- <word ordinal="4">Fourth </word>
7190
- <word cardinal="5">Five-</word>
7191
- <word ordinal="5">Fifth </word>
7192
- <word cardinal="6">Six-</word>
7193
- <word ordinal="6">Sixth </word>
7194
- <word cardinal="7">Seven-</word>
7195
- <word ordinal="7">Seventh </word>
7196
- <word cardinal="8">Eight-</word>
7197
- <word ordinal="8">Eighth </word>
7198
- <word cardinal="9">Nine-</word>
7199
- <word ordinal="9">Ninth </word>
7200
- <word ordinal="10">Tenth </word>
7201
- <word ordinal="11">Eleventh </word>
7202
- <word ordinal="12">Twelfth </word>
7203
- <word ordinal="13">Thirteenth </word>
7204
- <word ordinal="14">Fourteenth </word>
7205
- <word ordinal="15">Fifteenth </word>
7206
- <word ordinal="16">Sixteenth </word>
7207
- <word ordinal="17">Seventeenth </word>
7208
- <word ordinal="18">Eighteenth </word>
7209
- <word ordinal="19">Nineteenth </word>
7210
- <word cardinal="20">Twenty-</word>
7211
- <word ordinal="20">Twentieth </word>
7212
- <word cardinal="30">Thirty-</word>
7213
- <word ordinal="30">Thirtieth </word>
7214
- <word cardinal="40">Forty-</word>
7215
- <word ordinal="40">Fortieth </word>
7216
- <word cardinal="50">Fifty-</word>
7217
- <word ordinal="50">Fiftieth </word>
7218
- <word cardinal="60">Sixty-</word>
7219
- <word ordinal="60">Sixtieth </word>
7220
- <word cardinal="70">Seventy-</word>
7221
- <word ordinal="70">Seventieth </word>
7222
- <word cardinal="80">Eighty-</word>
7223
- <word ordinal="80">Eightieth </word>
7224
- <word cardinal="90">Ninety-</word>
7225
- <word ordinal="90">Ninetieth </word>
7226
- <word cardinal="100">Hundred-</word>
7227
- <word ordinal="100">Hundredth </word>
7250
+ <words>
7251
+ <xsl:choose>
7252
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
7253
+ <word cardinal="1">Une-</word>
7254
+ <word ordinal="1">Première </word>
7255
+ <word cardinal="2">Deux-</word>
7256
+ <word ordinal="2">Seconde </word>
7257
+ <word cardinal="3">Trois-</word>
7258
+ <word ordinal="3">Tierce </word>
7259
+ <word cardinal="4">Quatre-</word>
7260
+ <word ordinal="4">Quatrième </word>
7261
+ <word cardinal="5">Cinq-</word>
7262
+ <word ordinal="5">Cinquième </word>
7263
+ <word cardinal="6">Six-</word>
7264
+ <word ordinal="6">Sixième </word>
7265
+ <word cardinal="7">Sept-</word>
7266
+ <word ordinal="7">Septième </word>
7267
+ <word cardinal="8">Huit-</word>
7268
+ <word ordinal="8">Huitième </word>
7269
+ <word cardinal="9">Neuf-</word>
7270
+ <word ordinal="9">Neuvième </word>
7271
+ <word ordinal="10">Dixième </word>
7272
+ <word ordinal="11">Onzième </word>
7273
+ <word ordinal="12">Douzième </word>
7274
+ <word ordinal="13">Treizième </word>
7275
+ <word ordinal="14">Quatorzième </word>
7276
+ <word ordinal="15">Quinzième </word>
7277
+ <word ordinal="16">Seizième </word>
7278
+ <word ordinal="17">Dix-septième </word>
7279
+ <word ordinal="18">Dix-huitième </word>
7280
+ <word ordinal="19">Dix-neuvième </word>
7281
+ <word cardinal="20">Vingt-</word>
7282
+ <word ordinal="20">Vingtième </word>
7283
+ <word cardinal="30">Trente-</word>
7284
+ <word ordinal="30">Trentième </word>
7285
+ <word cardinal="40">Quarante-</word>
7286
+ <word ordinal="40">Quarantième </word>
7287
+ <word cardinal="50">Cinquante-</word>
7288
+ <word ordinal="50">Cinquantième </word>
7289
+ <word cardinal="60">Soixante-</word>
7290
+ <word ordinal="60">Soixantième </word>
7291
+ <word cardinal="70">Septante-</word>
7292
+ <word ordinal="70">Septantième </word>
7293
+ <word cardinal="80">Huitante-</word>
7294
+ <word ordinal="80">Huitantième </word>
7295
+ <word cardinal="90">Nonante-</word>
7296
+ <word ordinal="90">Nonantième </word>
7297
+ <word cardinal="100">Cent-</word>
7298
+ <word ordinal="100">Centième </word>
7299
+ </xsl:when>
7300
+ <xsl:when test="$lang = 'ru'">
7301
+ <word cardinal="1">Одна-</word>
7302
+ <word ordinal="1">Первое </word>
7303
+ <word cardinal="2">Две-</word>
7304
+ <word ordinal="2">Второе </word>
7305
+ <word cardinal="3">Три-</word>
7306
+ <word ordinal="3">Третье </word>
7307
+ <word cardinal="4">Четыре-</word>
7308
+ <word ordinal="4">Четвертое </word>
7309
+ <word cardinal="5">Пять-</word>
7310
+ <word ordinal="5">Пятое </word>
7311
+ <word cardinal="6">Шесть-</word>
7312
+ <word ordinal="6">Шестое </word>
7313
+ <word cardinal="7">Семь-</word>
7314
+ <word ordinal="7">Седьмое </word>
7315
+ <word cardinal="8">Восемь-</word>
7316
+ <word ordinal="8">Восьмое </word>
7317
+ <word cardinal="9">Девять-</word>
7318
+ <word ordinal="9">Девятое </word>
7319
+ <word ordinal="10">Десятое </word>
7320
+ <word ordinal="11">Одиннадцатое </word>
7321
+ <word ordinal="12">Двенадцатое </word>
7322
+ <word ordinal="13">Тринадцатое </word>
7323
+ <word ordinal="14">Четырнадцатое </word>
7324
+ <word ordinal="15">Пятнадцатое </word>
7325
+ <word ordinal="16">Шестнадцатое </word>
7326
+ <word ordinal="17">Семнадцатое </word>
7327
+ <word ordinal="18">Восемнадцатое </word>
7328
+ <word ordinal="19">Девятнадцатое </word>
7329
+ <word cardinal="20">Двадцать-</word>
7330
+ <word ordinal="20">Двадцатое </word>
7331
+ <word cardinal="30">Тридцать-</word>
7332
+ <word ordinal="30">Тридцатое </word>
7333
+ <word cardinal="40">Сорок-</word>
7334
+ <word ordinal="40">Сороковое </word>
7335
+ <word cardinal="50">Пятьдесят-</word>
7336
+ <word ordinal="50">Пятидесятое </word>
7337
+ <word cardinal="60">Шестьдесят-</word>
7338
+ <word ordinal="60">Шестидесятое </word>
7339
+ <word cardinal="70">Семьдесят-</word>
7340
+ <word ordinal="70">Семидесятое </word>
7341
+ <word cardinal="80">Восемьдесят-</word>
7342
+ <word ordinal="80">Восьмидесятое </word>
7343
+ <word cardinal="90">Девяносто-</word>
7344
+ <word ordinal="90">Девяностое </word>
7345
+ <word cardinal="100">Сто-</word>
7346
+ <word ordinal="100">Сотое </word>
7347
+ </xsl:when>
7348
+ <xsl:otherwise> <!-- default english -->
7349
+ <word cardinal="1">One-</word>
7350
+ <word ordinal="1">First </word>
7351
+ <word cardinal="2">Two-</word>
7352
+ <word ordinal="2">Second </word>
7353
+ <word cardinal="3">Three-</word>
7354
+ <word ordinal="3">Third </word>
7355
+ <word cardinal="4">Four-</word>
7356
+ <word ordinal="4">Fourth </word>
7357
+ <word cardinal="5">Five-</word>
7358
+ <word ordinal="5">Fifth </word>
7359
+ <word cardinal="6">Six-</word>
7360
+ <word ordinal="6">Sixth </word>
7361
+ <word cardinal="7">Seven-</word>
7362
+ <word ordinal="7">Seventh </word>
7363
+ <word cardinal="8">Eight-</word>
7364
+ <word ordinal="8">Eighth </word>
7365
+ <word cardinal="9">Nine-</word>
7366
+ <word ordinal="9">Ninth </word>
7367
+ <word ordinal="10">Tenth </word>
7368
+ <word ordinal="11">Eleventh </word>
7369
+ <word ordinal="12">Twelfth </word>
7370
+ <word ordinal="13">Thirteenth </word>
7371
+ <word ordinal="14">Fourteenth </word>
7372
+ <word ordinal="15">Fifteenth </word>
7373
+ <word ordinal="16">Sixteenth </word>
7374
+ <word ordinal="17">Seventeenth </word>
7375
+ <word ordinal="18">Eighteenth </word>
7376
+ <word ordinal="19">Nineteenth </word>
7377
+ <word cardinal="20">Twenty-</word>
7378
+ <word ordinal="20">Twentieth </word>
7379
+ <word cardinal="30">Thirty-</word>
7380
+ <word ordinal="30">Thirtieth </word>
7381
+ <word cardinal="40">Forty-</word>
7382
+ <word ordinal="40">Fortieth </word>
7383
+ <word cardinal="50">Fifty-</word>
7384
+ <word ordinal="50">Fiftieth </word>
7385
+ <word cardinal="60">Sixty-</word>
7386
+ <word ordinal="60">Sixtieth </word>
7387
+ <word cardinal="70">Seventy-</word>
7388
+ <word ordinal="70">Seventieth </word>
7389
+ <word cardinal="80">Eighty-</word>
7390
+ <word ordinal="80">Eightieth </word>
7391
+ <word cardinal="90">Ninety-</word>
7392
+ <word ordinal="90">Ninetieth </word>
7393
+ <word cardinal="100">Hundred-</word>
7394
+ <word ordinal="100">Hundredth </word>
7395
+ </xsl:otherwise>
7396
+ </xsl:choose>
7228
7397
  </words>
7229
7398
  </xsl:variable>
7230
7399
 
@@ -7298,4 +7467,18 @@
7298
7467
  <xsl:otherwise>_</xsl:otherwise>
7299
7468
  </xsl:choose>
7300
7469
  </xsl:attribute>
7470
+ </xsl:template><xsl:template name="substring-after-last">
7471
+ <xsl:param name="value"/>
7472
+ <xsl:param name="delimiter"/>
7473
+ <xsl:choose>
7474
+ <xsl:when test="contains($value, $delimiter)">
7475
+ <xsl:call-template name="substring-after-last">
7476
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
7477
+ <xsl:with-param name="delimiter" select="$delimiter"/>
7478
+ </xsl:call-template>
7479
+ </xsl:when>
7480
+ <xsl:otherwise>
7481
+ <xsl:value-of select="$value"/>
7482
+ </xsl:otherwise>
7483
+ </xsl:choose>
7301
7484
  </xsl:template></xsl:stylesheet>
@@ -3,24 +3,25 @@ require "roman-numerals"
3
3
  module IsoDoc
4
4
  module UN
5
5
  class Xref < IsoDoc::Xref
6
- def initial_anchor_names(d)
7
- preface_names(d.at(ns("//preface/abstract")))
8
- preface_names(d.at(ns("//foreword")))
9
- preface_names(d.at(ns("//introduction")))
10
- d.xpath(ns("//preface/clause")).each do |c|
6
+ def initial_anchor_names(doc)
7
+ preface_names(doc.at(ns("//preface/abstract")))
8
+ preface_names(doc.at(ns("//foreword")))
9
+ preface_names(doc.at(ns("//introduction")))
10
+ doc.xpath(ns("//preface/clause")).each do |c|
11
11
  preface_names(c)
12
12
  end
13
- preface_names(d.at(ns("//acknowledgements")))
13
+ preface_names(doc.at(ns("//acknowledgements")))
14
14
  sequential_asset_names(
15
- d.xpath(ns("//preface/abstract | //foreword | //introduction | "\
16
- "//preface/clause | //acknowledgements")))
17
- middle_section_asset_names(d)
18
- clause_names(d, 0)
19
- termnote_anchor_names(d)
20
- termexample_anchor_names(d)
15
+ doc.xpath(ns("//preface/abstract | //foreword | //introduction | "\
16
+ "//preface/clause | //acknowledgements")),
17
+ )
18
+ middle_section_asset_names(doc)
19
+ clause_names(doc, 0)
20
+ termnote_anchor_names(doc)
21
+ termexample_anchor_names(doc)
21
22
  end
22
23
 
23
- def clause_names(docxml, sect_num)
24
+ def clause_names(docxml, _sect_num)
24
25
  q = "//clause[parent::sections]"
25
26
  @paranumber = 0
26
27
  i = 0
@@ -57,24 +58,28 @@ module IsoDoc
57
58
 
58
59
  def label_leaf_section(clause, lvl)
59
60
  @paranumber += 1
60
- @anchors[clause["id"]] = {label: @paranumber.to_s,
61
- xref: l10n("#{@labels['paragraph']} #{@paranumber}"),
62
- level: lvl, type: "paragraph" }
61
+ @anchors[clause["id"]] =
62
+ { label: @paranumber.to_s, elem: @labels["paragraph"],
63
+ xref: l10n("#{@labels['paragraph']} #{@paranumber}"),
64
+ level: lvl, type: "paragraph" }
63
65
  end
64
66
 
65
67
  def label_annex_leaf_section(clause, num, lvl)
66
68
  @paranumber += 1
67
- @anchors[clause["id"]] = {label: @paranumber.to_s,
68
- xref: l10n("#{@labels['paragraph']} #{num}.#{@paranumber}"),
69
- level: lvl, type: "paragraph" }
69
+ @anchors[clause["id"]] =
70
+ { label: @paranumber.to_s, elem: @labels["paragraph"],
71
+ xref: l10n("#{@labels['paragraph']} #{num}.#{@paranumber}"),
72
+ level: lvl, type: "paragraph" }
70
73
  end
71
74
 
72
75
  def section_names(clause, num, lvl)
73
76
  return num if clause.nil?
77
+
74
78
  leaf_section?(clause) and label_leaf_section(clause, lvl) and return
75
79
  num = num + 1
76
80
  lbl = levelnumber(num, 1)
77
81
  @anchors[clause["id"]] = { label: lbl, level: lvl, type: "clause",
82
+ elem: @labels["clause"],
78
83
  xref: l10n("#{@labels['clause']} #{lbl}") }
79
84
  i = 1
80
85
  clause.xpath(ns(NONTERMINAL)).each do |c|
@@ -89,6 +94,7 @@ module IsoDoc
89
94
  /\.(?<leafnum>[^.]+$)/ =~ num
90
95
  clause["unnumbered"] == "true" or
91
96
  @anchors[clause["id"]] = { label: leafnum, level: level, type: "clause",
97
+ elem: @labels["clause"],
92
98
  xref: l10n("#{@labels['clause']} #{num}") }
93
99
  i = 1
94
100
  clause.xpath(ns(NONTERMINAL)).each do |c|
@@ -97,27 +103,32 @@ module IsoDoc
97
103
  end
98
104
  end
99
105
 
100
- def annex_name_lbl(clause, num)
106
+ def annex_name_lbl(_clause, num)
101
107
  l10n("<strong>#{@labels['annex']} #{num}</strong>")
102
108
  end
103
109
 
104
110
  SUBCLAUSES =
105
111
  "./clause | ./references | ./term | ./terms | ./definitions".freeze
106
112
 
113
+ def annex_name_anchors(clause, num)
114
+ { label: annex_name_lbl(clause, num),
115
+ elem: @labels["annex"],
116
+ type: "clause", value: num.to_s, level: 1,
117
+ xref: "#{@labels['annex']} #{num}" }
118
+ end
107
119
 
108
120
  def annex_names(clause, num)
109
121
  hierarchical_asset_names(clause, num)
110
122
  leaf_section?(clause) and
111
123
  label_annex_leaf_section(clause, num, 1) and return
112
- @anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
113
- type: "clause", value: num,
114
- xref: l10n("#{@labels['annex']} #{num}"), level: 1 }
124
+ @anchors[clause["id"]] = annex_name_anchors(clause, num)
115
125
  if a = single_annex_special_section(clause)
116
- annex_names1(a, "#{num}", 1)
126
+ annex_names1(a, num.to_s, 1)
117
127
  else
118
128
  i = 1
119
129
  clause.xpath(ns(SUBCLAUSES)).each do |c|
120
130
  next if c["unnumbered"] == "true"
131
+
121
132
  annex_names1(c, "#{num}.#{annex_levelnum(i, 2)}", 2)
122
133
  i += 1 if !leaf_section?(c)
123
134
  end
@@ -129,10 +140,11 @@ module IsoDoc
129
140
  label_annex_leaf_section(clause, num, level) and return
130
141
  /\.(?<leafnum>[^.]+$)/ =~ num
131
142
  @anchors[clause["id"]] = { label: leafnum, xref: l10n("#{@labels['annex']} #{num}"),
132
- level: level, type: "clause" }
143
+ level: level, type: "clause", elem: @labels["annex"] }
133
144
  i = 1
134
145
  clause.xpath(ns("./clause | ./references")).each do |c|
135
146
  next if c["unnumbered"] == "true"
147
+
136
148
  annex_names1(c, "#{num}.#{annex_levelnum(i, level + 1)}", level + 1)
137
149
  i += 1 if !leaf_section?(c)
138
150
  end
@@ -156,6 +168,7 @@ module IsoDoc
156
168
  i = 0
157
169
  clause.xpath(ns(".//admonition")).each do |t|
158
170
  next if t["id"].nil? || t["id"].empty?
171
+
159
172
  i += 1 unless t["unnumbered"] == "true"
160
173
  @anchors[t["id"]] = anchor_struct(i.to_s, nil, @labels["admonition"],
161
174
  "box", t["unnumbered"])
@@ -166,6 +179,7 @@ module IsoDoc
166
179
  i = 0
167
180
  clause.xpath(ns(".//admonition")).each do |t|
168
181
  next if t["id"].nil? || t["id"].empty?
182
+
169
183
  i += 1 unless t["unnumbered"] == "true"
170
184
  @anchors[t["id"]] =
171
185
  anchor_struct("#{num}.#{i}", nil, @labels["admonition"], "box",