metanorma-iso 1.10.3 → 1.10.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,7 @@
9
9
 
10
10
 
11
11
 
12
- <xsl:key name="kfn" match="iso:p/iso:fn" use="@reference"/>
12
+ <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
13
13
 
14
14
  <xsl:key name="attachments" match="iso:eref[contains(@bibitemid, '.exp')]" use="@bibitemid"/>
15
15
 
@@ -1686,69 +1686,19 @@
1686
1686
  <xsl:template match="iso:li//iso:p//text()">
1687
1687
  <xsl:choose>
1688
1688
  <xsl:when test="contains(., '&#9;')">
1689
+ <!-- <fo:inline white-space="pre"><xsl:value-of select="translate(., $thinspace, ' ')"/></fo:inline> -->
1689
1690
  <fo:inline white-space="pre"><xsl:value-of select="."/></fo:inline>
1690
1691
  </xsl:when>
1691
1692
  <xsl:otherwise>
1693
+ <!-- <xsl:value-of select="translate(., $thinspace, ' ')"/> -->
1692
1694
  <xsl:value-of select="."/>
1693
1695
  </xsl:otherwise>
1694
1696
  </xsl:choose>
1695
1697
 
1696
1698
  </xsl:template>
1697
1699
 
1698
- <!--
1699
- <fn reference="1">
1700
- <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
1701
- </fn>
1702
- -->
1703
1700
 
1704
- <xsl:variable name="p_fn">
1705
- <xsl:for-each select="//iso:p/iso:fn[generate-id(.)=generate-id(key('kfn',@reference)[1])]">
1706
- <!-- copy unique fn -->
1707
- <fn gen_id="{generate-id(.)}">
1708
- <xsl:copy-of select="@*"/>
1709
- <xsl:copy-of select="node()"/>
1710
- </fn>
1711
- </xsl:for-each>
1712
- </xsl:variable>
1713
1701
 
1714
- <xsl:template match="iso:p/iso:fn" priority="2">
1715
- <xsl:variable name="gen_id" select="generate-id(.)"/>
1716
- <xsl:variable name="reference" select="@reference"/>
1717
- <xsl:variable name="number">
1718
- <!-- <xsl:number level="any" count="iso:p/iso:fn"/> -->
1719
- <xsl:value-of select="count(xalan:nodeset($p_fn)//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
1720
- </xsl:variable>
1721
- <xsl:choose>
1722
- <xsl:when test="xalan:nodeset($p_fn)//fn[@gen_id = $gen_id]">
1723
- <fo:footnote>
1724
- <fo:inline font-size="80%" keep-with-previous.within-line="always" vertical-align="super">
1725
- <fo:basic-link internal-destination="footnote_{@reference}_{$number}" fox:alt-text="footnote {@reference} {$number}">
1726
- <!-- <xsl:value-of select="@reference"/> -->
1727
- <xsl:value-of select="$number + count(//iso:bibitem[ancestor::iso:references[@normative='true']]/iso:note)"/><xsl:text>)</xsl:text>
1728
- </fo:basic-link>
1729
- </fo:inline>
1730
- <fo:footnote-body>
1731
- <fo:block font-size="10pt" margin-bottom="12pt">
1732
- <fo:inline id="footnote_{@reference}_{$number}" keep-with-next.within-line="always" padding-right="3mm"> <!-- font-size="60%" alignment-baseline="hanging" -->
1733
- <xsl:value-of select="$number + count(//iso:bibitem[ancestor::iso:references[@normative='true']]/iso:note)"/><xsl:text>)</xsl:text>
1734
- </fo:inline>
1735
- <xsl:for-each select="iso:p">
1736
- <xsl:apply-templates/>
1737
- </xsl:for-each>
1738
- </fo:block>
1739
- </fo:footnote-body>
1740
- </fo:footnote>
1741
- </xsl:when>
1742
- <xsl:otherwise>
1743
- <fo:inline font-size="60%" keep-with-previous.within-line="always" vertical-align="super">
1744
- <fo:basic-link internal-destination="footnote_{@reference}_{$number}" fox:alt-text="footnote {@reference} {$number}">
1745
- <xsl:value-of select="$number + count(//iso:bibitem/iso:note)"/>
1746
- </fo:basic-link>
1747
- </fo:inline>
1748
- </xsl:otherwise>
1749
- </xsl:choose>
1750
- </xsl:template>
1751
-
1752
1702
  <xsl:template match="iso:p/iso:fn/iso:p">
1753
1703
  <xsl:apply-templates/>
1754
1704
  </xsl:template>
@@ -2011,6 +1961,11 @@
2011
1961
  <!-- End of Index processing -->
2012
1962
  <!-- =================== -->
2013
1963
 
1964
+ <!-- <xsl:variable name="thinspace" select="'&#x2009;'"/>
1965
+ <xsl:template match="text()[contains(., $thinspace)]">
1966
+ <xsl:value-of select="translate(., $thinspace, ' ')"/>
1967
+ </xsl:template> -->
1968
+
2014
1969
 
2015
1970
  <xsl:template name="insertHeaderFooter">
2016
1971
  <xsl:param name="font-weight" select="'bold'"/>
@@ -2741,6 +2696,76 @@
2741
2696
 
2742
2697
  </xsl:attribute-set><xsl:attribute-set name="toc-style">
2743
2698
  <xsl:attribute name="line-height">135%</xsl:attribute>
2699
+ </xsl:attribute-set><xsl:attribute-set name="fn-style">
2700
+ <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
2701
+ </xsl:attribute-set><xsl:attribute-set name="fn-num-style">
2702
+ <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
2703
+
2704
+
2705
+
2706
+
2707
+
2708
+
2709
+
2710
+
2711
+ <xsl:attribute name="font-size">80%</xsl:attribute>
2712
+ <xsl:attribute name="vertical-align">super</xsl:attribute>
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2722
+ </xsl:attribute-set><xsl:attribute-set name="fn-body-style">
2723
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
2724
+ <xsl:attribute name="font-style">normal</xsl:attribute>
2725
+ <xsl:attribute name="text-indent">0</xsl:attribute>
2726
+ <xsl:attribute name="start-indent">0</xsl:attribute>
2727
+
2728
+
2729
+
2730
+
2731
+
2732
+
2733
+
2734
+
2735
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
2736
+ <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
2737
+
2738
+
2739
+
2740
+
2741
+
2742
+
2743
+
2744
+
2745
+
2746
+
2747
+
2748
+ </xsl:attribute-set><xsl:attribute-set name="fn-body-num-style">
2749
+ <xsl:attribute name="keep-with-next.within-line">always</xsl:attribute>
2750
+
2751
+
2752
+
2753
+
2754
+
2755
+
2756
+
2757
+
2758
+ <xsl:attribute name="padding-right">3mm</xsl:attribute>
2759
+
2760
+
2761
+
2762
+
2763
+
2764
+
2765
+
2766
+
2767
+
2768
+
2744
2769
  </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:template name="OLD_processPrefaceSectionsDefault_Contents">
2745
2770
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
2746
2771
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
@@ -3783,6 +3808,104 @@
3783
3808
 
3784
3809
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']/*[local-name()='name']" mode="process"/><xsl:template match="*[local-name()='table']/*[local-name()='note']/*[local-name()='p']" mode="process">
3785
3810
  <xsl:apply-templates/>
3811
+ </xsl:template><xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" priority="2" name="fn">
3812
+
3813
+ <!-- list of footnotes to calculate actual footnotes number -->
3814
+ <xsl:variable name="p_fn_">
3815
+ <xsl:choose>
3816
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
3817
+ <fn gen_id="{generate-id(.)}">
3818
+ <xsl:copy-of select="@*"/>
3819
+ <xsl:copy-of select="node()"/>
3820
+ </fn>
3821
+ </xsl:when>
3822
+ <xsl:otherwise>
3823
+ <!-- itetation for:
3824
+ footnotes in bibdata/title
3825
+ footnotes in bibliography
3826
+ footnotes in document's body (except table's head/body/foot and figure text)
3827
+ -->
3828
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3829
+ <fn gen_id="{generate-id(.)}">
3830
+ <xsl:copy-of select="@*"/>
3831
+ <xsl:copy-of select="node()"/>
3832
+ </fn>
3833
+ </xsl:for-each>
3834
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*">
3835
+ <xsl:sort select="@displayorder" data-type="number"/>
3836
+ <xsl:for-each select=".//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] | .//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
3837
+ <!-- copy unique fn -->
3838
+ <fn gen_id="{generate-id(.)}">
3839
+ <xsl:copy-of select="@*"/>
3840
+ <xsl:copy-of select="node()"/>
3841
+ </fn>
3842
+ </xsl:for-each>
3843
+ </xsl:for-each>
3844
+ </xsl:otherwise>
3845
+ </xsl:choose>
3846
+ </xsl:variable>
3847
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
3848
+
3849
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
3850
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
3851
+ <xsl:variable name="reference" select="@reference"/>
3852
+ <!-- fn sequence number in document -->
3853
+ <xsl:variable name="current_fn_number">
3854
+ <xsl:choose>
3855
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
3856
+ <xsl:otherwise>
3857
+ <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
3858
+ </xsl:otherwise>
3859
+ </xsl:choose>
3860
+ </xsl:variable>
3861
+ <xsl:variable name="current_fn_number_text">
3862
+ <xsl:value-of select="$current_fn_number"/>
3863
+
3864
+
3865
+ <xsl:text>)</xsl:text>
3866
+
3867
+ </xsl:variable>
3868
+
3869
+ <xsl:variable name="ref_id" select="concat('footnote_', $lang, '_', $reference, '_', $current_fn_number)"/>
3870
+ <xsl:variable name="footnote_inline">
3871
+ <fo:inline xsl:use-attribute-sets="fn-num-style">
3872
+
3873
+ <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
3874
+ <xsl:value-of select="$current_fn_number_text"/>
3875
+ </fo:basic-link>
3876
+ </fo:inline>
3877
+ </xsl:variable>
3878
+ <!-- DEBUG: p_fn=<xsl:copy-of select="$p_fn"/>
3879
+ gen_id=<xsl:value-of select="$gen_id"/> -->
3880
+ <xsl:choose>
3881
+ <xsl:when test="normalize-space(@skip_footnote_body) = 'true'">
3882
+ <xsl:copy-of select="$footnote_inline"/>
3883
+ </xsl:when>
3884
+ <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false'">
3885
+ <fo:footnote xsl:use-attribute-sets="fn-style">
3886
+ <xsl:copy-of select="$footnote_inline"/>
3887
+ <fo:footnote-body>
3888
+
3889
+ <fo:block-container text-indent="0" start-indent="0">
3890
+
3891
+
3892
+ <fo:block xsl:use-attribute-sets="fn-body-style">
3893
+
3894
+
3895
+ <fo:inline id="{$ref_id}" xsl:use-attribute-sets="fn-body-num-style">
3896
+
3897
+ <xsl:value-of select="$current_fn_number_text"/>
3898
+ </fo:inline>
3899
+ <xsl:apply-templates/>
3900
+ </fo:block>
3901
+ </fo:block-container>
3902
+ </fo:footnote-body>
3903
+ </fo:footnote>
3904
+ </xsl:when>
3905
+ <xsl:otherwise>
3906
+ <xsl:copy-of select="$footnote_inline"/>
3907
+ </xsl:otherwise>
3908
+ </xsl:choose>
3786
3909
  </xsl:template><xsl:template name="fn_display">
3787
3910
  <xsl:variable name="references">
3788
3911
 
@@ -3984,6 +4107,8 @@
3984
4107
 
3985
4108
  </fo:basic-link>
3986
4109
  </fo:inline>
4110
+ </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
4111
+ <fo:inline><xsl:value-of select="."/></fo:inline>
3987
4112
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
3988
4113
  <fo:inline>
3989
4114
  <xsl:apply-templates/>
@@ -4997,22 +5122,6 @@
4997
5122
  <xsl:if test="not(preceding-sibling::*[local-name() = 'p'])"><xsl:value-of select="$callout"/></xsl:if>
4998
5123
  <xsl:apply-templates/>
4999
5124
  </fo:inline>
5000
- </xsl:template><xsl:template match="*[local-name() = 'modification']">
5001
- <xsl:variable name="title-modified">
5002
-
5003
- <xsl:call-template name="getLocalizedString">
5004
- <xsl:with-param name="key">modified</xsl:with-param>
5005
- </xsl:call-template>
5006
-
5007
-
5008
- </xsl:variable>
5009
-
5010
- <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
5011
- <xsl:choose>
5012
- <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:if test="normalize-space($text) != ''"><xsl:text>—</xsl:text></xsl:if></xsl:when>
5013
- <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:if test="normalize-space($text) != ''"><xsl:text> — </xsl:text></xsl:if></xsl:otherwise>
5014
- </xsl:choose>
5015
- <xsl:apply-templates/>
5016
5125
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
5017
5126
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
5018
5127
 
@@ -6253,60 +6362,69 @@
6253
6362
  <xsl:variable name="termsource_text">
6254
6363
  <xsl:apply-templates/>
6255
6364
  </xsl:variable>
6256
-
6257
- <xsl:choose>
6365
+ <xsl:copy-of select="$termsource_text"/>
6366
+ <!-- <xsl:choose>
6258
6367
  <xsl:when test="starts-with(normalize-space($termsource_text), '[')">
6259
- <!-- <xsl:apply-templates /> -->
6260
6368
  <xsl:copy-of select="$termsource_text"/>
6261
6369
  </xsl:when>
6262
6370
  <xsl:otherwise>
6263
-
6264
-
6371
+ <xsl:if test="$namespace = 'bsi'">
6372
+ <xsl:choose>
6373
+ <xsl:when test="$document_type = 'PAS' and starts-with(*[local-name() = 'origin']/@citeas, '[')"><xsl:text>{</xsl:text></xsl:when>
6374
+ <xsl:otherwise><xsl:text>[</xsl:text></xsl:otherwise>
6375
+ </xsl:choose>
6376
+ </xsl:if>
6377
+ <xsl:if test="$namespace = 'gb' or $namespace = 'iso' or $namespace = 'iec' or $namespace = 'itu' or $namespace = 'unece' or $namespace = 'unece-rec' or $namespace = 'nist-cswp' or $namespace = 'nist-sp' or $namespace = 'ogc-white-paper' or $namespace = 'csa' or $namespace = 'csd' or $namespace = 'm3d' or $namespace = 'iho' or $namespace = 'bipm' or $namespace = 'jcgm'">
6265
6378
  <xsl:text>[</xsl:text>
6266
-
6267
- <!-- <xsl:apply-templates /> -->
6379
+ </xsl:if>
6268
6380
  <xsl:copy-of select="$termsource_text"/>
6269
-
6270
-
6381
+ <xsl:if test="$namespace = 'bsi'">
6382
+ <xsl:choose>
6383
+ <xsl:when test="$document_type = 'PAS' and starts-with(*[local-name() = 'origin']/@citeas, '[')"><xsl:text>}</xsl:text></xsl:when>
6384
+ <xsl:otherwise><xsl:text>]</xsl:text></xsl:otherwise>
6385
+ </xsl:choose>
6386
+ </xsl:if>
6387
+ <xsl:if test="$namespace = 'gb' or $namespace = 'iso' or $namespace = 'iec' or $namespace = 'itu' or $namespace = 'unece' or $namespace = 'unece-rec' or $namespace = 'nist-cswp' or $namespace = 'nist-sp' or $namespace = 'ogc-white-paper' or $namespace = 'csa' or $namespace = 'csd' or $namespace = 'm3d' or $namespace = 'iho' or $namespace = 'bipm' or $namespace = 'jcgm'">
6271
6388
  <xsl:text>]</xsl:text>
6272
-
6389
+ </xsl:if>
6273
6390
  </xsl:otherwise>
6274
- </xsl:choose>
6391
+ </xsl:choose> -->
6275
6392
  </fo:block>
6276
6393
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6277
6394
  <xsl:if test="normalize-space() != ''">
6278
6395
  <xsl:value-of select="."/>
6279
6396
  </xsl:if>
6280
- </xsl:template><xsl:variable name="localized.source">
6281
- <xsl:call-template name="getLocalizedString">
6282
- <xsl:with-param name="key">source</xsl:with-param>
6283
- </xsl:call-template>
6284
- </xsl:variable><xsl:template match="*[local-name() = 'origin']">
6397
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/*[local-name() = 'strong'][1][following-sibling::*[1][local-name() = 'origin']]/text()">
6398
+ <fo:inline>
6399
+
6400
+
6401
+ <xsl:value-of select="."/>
6402
+ </fo:inline>
6403
+ </xsl:template><xsl:template match="*[local-name() = 'origin']">
6285
6404
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6286
6405
  <xsl:if test="normalize-space(@citeas) = ''">
6287
6406
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
6288
6407
  </xsl:if>
6289
-
6290
-
6291
- <fo:inline>
6292
-
6293
-
6294
-
6295
-
6296
-
6297
- <xsl:value-of select="$localized.source"/>
6298
- <xsl:text>: </xsl:text>
6299
-
6300
-
6301
-
6302
-
6303
- </fo:inline>
6304
-
6305
6408
  <fo:inline xsl:use-attribute-sets="origin-style">
6306
6409
  <xsl:apply-templates/>
6307
6410
  </fo:inline>
6411
+ </fo:basic-link>
6412
+ </xsl:template><xsl:template match="*[local-name() = 'modification']">
6413
+ <xsl:variable name="title-modified">
6308
6414
 
6309
- </fo:basic-link>
6415
+ <xsl:call-template name="getLocalizedString">
6416
+ <xsl:with-param name="key">modified</xsl:with-param>
6417
+ </xsl:call-template>
6418
+
6419
+
6420
+ </xsl:variable>
6421
+
6422
+ <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
6423
+ <xsl:choose>
6424
+ <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:if test="normalize-space($text) != ''"><xsl:text>—</xsl:text></xsl:if></xsl:when>
6425
+ <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:if test="normalize-space($text) != ''"><xsl:text> — </xsl:text></xsl:if></xsl:otherwise>
6426
+ </xsl:choose>
6427
+ <xsl:apply-templates/>
6310
6428
  </xsl:template><xsl:template match="*[local-name() = 'modification']/*[local-name() = 'p']">
6311
6429
  <fo:inline><xsl:apply-templates/></fo:inline>
6312
6430
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
@@ -6935,7 +7053,31 @@
6935
7053
  <fo:block-container border="1pt solid black" width="50%">
6936
7054
  <fo:block> </fo:block>
6937
7055
  </fo:block-container>
6938
- </xsl:template><xsl:template match="*[local-name() = 'toc']">
7056
+ </xsl:template><xsl:variable name="toc_level">
7057
+ <xsl:choose>
7058
+ <xsl:when test="1 = 2"/> <!-- to do https://github.com/metanorma/mn-native-pdf/issues/337: if there is value in xml -->
7059
+ <xsl:otherwise><!-- default value -->
7060
+
7061
+
7062
+
7063
+
7064
+
7065
+
7066
+
7067
+
7068
+
7069
+
7070
+
7071
+
7072
+
7073
+
7074
+
7075
+
7076
+
7077
+
7078
+ </xsl:otherwise>
7079
+ </xsl:choose>
7080
+ </xsl:variable><xsl:template match="*[local-name() = 'toc']">
6939
7081
  <xsl:param name="colwidths"/>
6940
7082
  <xsl:variable name="colwidths_">
6941
7083
  <xsl:choose>
@@ -7575,4 +7717,14 @@
7575
7717
  </xsl:otherwise>
7576
7718
  </xsl:choose>
7577
7719
  </xsl:if>
7720
+ </xsl:template><xsl:template name="setAltText">
7721
+ <xsl:param name="value"/>
7722
+ <xsl:attribute name="fox:alt-text">
7723
+ <xsl:choose>
7724
+ <xsl:when test="normalize-space($value) != ''">
7725
+ <xsl:value-of select="$value"/>
7726
+ </xsl:when>
7727
+ <xsl:otherwise>_</xsl:otherwise>
7728
+ </xsl:choose>
7729
+ </xsl:attribute>
7578
7730
  </xsl:template></xsl:stylesheet>
@@ -181,7 +181,7 @@ module IsoDoc
181
181
  (v = elem.at(ns("./definition/verbal-definition"))) &&
182
182
  v.elements.first.name == "p") or return
183
183
  v.elements.first.children.first.previous =
184
- "&lt;#{d.remove.children.to_xml}&gt; "
184
+ "&#x3c;#{d.remove.children.to_xml}&#x3e; "
185
185
  end
186
186
 
187
187
  include Init
@@ -124,9 +124,7 @@ module IsoDoc
124
124
 
125
125
  def termref_parse(node, out)
126
126
  out.p **termref_attrs do |p|
127
- p << "[TERMREF]"
128
127
  node.children.each { |n| parse(n, p) }
129
- p << "[/TERMREF]"
130
128
  end
131
129
  end
132
130
 
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "1.10.3".freeze
3
+ VERSION = "1.10.4".freeze
4
4
  end
5
5
  end
@@ -48,7 +48,7 @@ RSpec.describe IsoDoc do
48
48
  expect(File.exist?("test.html")).to be true
49
49
  html = File.read("test.html", encoding: "UTF-8")
50
50
  expect(html).to include "<title>Cereals and pulses&#xA0;&#x2014; "\
51
- "Specifications and test methods&#xA0;&#x2014; Rice</title>"
51
+ "Specifications and test methods&#xA0;&#x2014; Rice</title>"
52
52
  expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/})
53
53
  expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
54
54
  end
@@ -77,7 +77,7 @@ RSpec.describe IsoDoc do
77
77
  expect(File.exist?("test.html")).to be true
78
78
  html = File.read("test.html", encoding: "UTF-8")
79
79
  expect(html).to include "title>Cereals and pulses&#xA0;&#x2014; "\
80
- "Specifications and test methods&#xA0;&#x2014; Rice</title>"
80
+ "Specifications and test methods&#xA0;&#x2014; Rice</title>"
81
81
  expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/})
82
82
  expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
83
83
  end
@@ -206,14 +206,10 @@ RSpec.describe IsoDoc do
206
206
  <definition>
207
207
  <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
208
208
  </definition>
209
- <termsource status="modified">
210
- <origin bibitemid="ISO7301" citeas="ISO 7301:2011" type="inline">
211
- <locality type="clause">
212
- <referenceFrom>3.1</referenceFrom>
213
- </locality>ISO 7301:2011, 3.1</origin>
214
- <modification>
215
- <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term &quot;cargo rice&quot; is shown as deprecated, and Note 1 to entry is not included here</p>
216
- </modification>
209
+ <termsource status="modified">[SOURCE:
210
+ <origin bibitemid="ISO7301" citeas="ISO 7301:2011" type="inline"><locality type="clause">
211
+ <referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>, modified &#x2013;
212
+ The term &quot;cargo rice&quot; is shown as deprecated, and Note 1 to entry is not included here]
217
213
  </termsource>
218
214
  </term>
219
215
  </terms>
@@ -226,23 +222,32 @@ RSpec.describe IsoDoc do
226
222
  .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
227
223
 
228
224
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
229
- <div class="WordSection3">
230
- <p class="zzSTDTitle1"/>
231
- <div>
232
- <a id="_terms_and_definitions" name="_terms_and_definitions"/>
233
- <h1>1
234
- <span style="mso-tab-count:1">  </span>
235
- Terms and Definitions</h1>
236
- <p class="TermNum">
237
- <a id="paddy1" name="paddy1"/>1.1</p>
238
- <p class="Terms" style="text-align:left;">paddy</p>
239
- <p class="Definition">
240
- <a id="_eb29b35e-123e-4d1c-b50b-2714d41e747f" name="_eb29b35e-123e-4d1c-b50b-2714d41e747f"/>rice retaining its husk after threshing</p>
241
- <p class="Source">[SOURCE:
242
- <a href="#ISO7301">ISO 7301:2011, 3.1</a>
243
- , modified — The term &quot;cargo rice&quot; is shown as deprecated, and Note 1 to entry is not included here]</p>
244
- </div>
245
- </div>
225
+ <div class='WordSection3'>
226
+ <p class='zzSTDTitle1'/>
227
+ <div>
228
+ <a name='_terms_and_definitions' id='_terms_and_definitions'/>
229
+ <h1>
230
+ 1
231
+ <span style='mso-tab-count:1'>&#xA0; </span>
232
+ Terms and Definitions
233
+ </h1>
234
+ <p class='TermNum'>
235
+ <a name='paddy1' id='paddy1'/>
236
+ 1.1
237
+ </p>
238
+ <p class='Terms' style='text-align:left;'>paddy</p>
239
+ <p class='Definition'>
240
+ <a name='_eb29b35e-123e-4d1c-b50b-2714d41e747f' id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'/>
241
+ rice retaining its husk after threshing
242
+ </p>
243
+ <p class='Source'>
244
+ [SOURCE:
245
+ <a href='#ISO7301'>ISO 7301:2011, 3.1</a>
246
+ , modified &#x2013; The term "cargo rice" is shown as deprecated, and Note
247
+ 1 to entry is not included here]
248
+ </p>
249
+ </div>
250
+ </div>
246
251
  OUTPUT
247
252
  end
248
253
 
@@ -262,6 +267,84 @@ RSpec.describe IsoDoc do
262
267
  expect(word).to include('Content-Disposition: inline; filename="header.html"')
263
268
  end
264
269
 
270
+ it "populates HTML ToC" do
271
+ IsoDoc::Iso::HtmlConvert
272
+ .new(WORD_HTML_CSS.dup)
273
+ .convert("test", <<~"INPUT", false)
274
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
275
+ <sections>
276
+ <clause id="A" inline-header="false" obligation="normative">
277
+ <title>1
278
+ <tab/>
279
+ Clause 4</title>
280
+ <clause id="N" inline-header="false" obligation="normative">
281
+ <title>1.1
282
+ <tab/>
283
+ Introduction
284
+ <bookmark id="Q"/>
285
+ to this
286
+ <fn reference="1">
287
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
288
+ </title>
289
+ </clause>
290
+ <clause id="O" inline-header="false" obligation="normative">
291
+ <title>1.2
292
+ <tab/>
293
+ Clause 4.2</title>
294
+ <p>A
295
+ <fn reference="1">
296
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
297
+ </p>
298
+ </clause>
299
+ </clause>
300
+ <clause id="P"><title>2<tab/>Clause 5</title>
301
+ <clause id="P1"><title>2.1<tab/>Clause 5.1</title></clause>
302
+ </clause>
303
+ <clause id="Q"><title>3<tab/>Clause 6</title></clause>
304
+ </sections>
305
+ </iso-standard>
306
+ INPUT
307
+
308
+ html = Nokogiri::XML(File.read("test.html", encoding: "UTF-8"))
309
+ .at("//div[@id = 'toc']").to_xml
310
+
311
+ expect(xmlpp(html))
312
+ .to be_equivalent_to xmlpp(<<~'OUTPUT')
313
+ <div id='toc'>
314
+ <ul>
315
+ <li class='h1'>
316
+ <div class='collapse-group'>
317
+ <a href='#toc0'>1 &#xA0; Clause 4</a>
318
+ <div class='collapse-button'/>
319
+ </div>
320
+ <ul class='content collapse'>
321
+ <li class='h2'>
322
+ <a href='#toc1'> 1.1 &#xA0; Introduction to this </a>
323
+ </li>
324
+ <li class='h2'>
325
+ <a href='#toc2'> 1.2 &#xA0; Clause 4.2</a>
326
+ </li>
327
+ </ul>
328
+ </li>
329
+ <li class='h1'>
330
+ <div class='collapse-group'>
331
+ <a href='#toc3'>2&#xA0; Clause 5</a>
332
+ <div class='collapse-button'/>
333
+ </div>
334
+ <ul class='content collapse'>
335
+ <li class='h2'>
336
+ <a href='#toc4'> 2.1&#xA0; Clause 5.1</a>
337
+ </li>
338
+ </ul>
339
+ </li>
340
+ <li class='h1'>
341
+ <a href='#toc5'> 3&#xA0; Clause 6</a>
342
+ </li>
343
+ </ul>
344
+ </div>
345
+ OUTPUT
346
+ end
347
+
265
348
  it "populates Word ToC" do
266
349
  IsoDoc::Iso::WordConvert
267
350
  .new(WORD_HTML_CSS_WORDINTRO.dup)
@@ -886,7 +969,7 @@ RSpec.describe IsoDoc do
886
969
  </div>
887
970
  OUTPUT
888
971
  expect(word).to include '<p class="zzWarning">This document is not '\
889
- "an ISO International Standard"
972
+ "an ISO International Standard"
890
973
  end
891
974
 
892
975
  it "populates Word ToC" do