Skip to content

Commit

Permalink
Merge pull request #339 from metanorma/feature/xslt-update
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Dec 9, 2024
2 parents 5a78647 + 3b84c7e commit 14aae36
Showing 1 changed file with 111 additions and 25 deletions.
136 changes: 111 additions & 25 deletions lib/isodoc/cc/cc.standard.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -11670,7 +11670,7 @@
</xsl:template>

<!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
<xsl:template match="*[local-name() = 'span'][@style or @class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" mode="update_xml_step1" priority="2">
<xsl:template match="*[local-name() = 'span'][@style or @class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear' or @class = 'horizontal' or @class = 'norotate' or @class = 'halffontsize']" mode="update_xml_step1" priority="2">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="update_xml_step1"/>
Expand Down Expand Up @@ -13249,36 +13249,122 @@
<!-- END: insert cover page image -->

<!-- https://github.com/metanorma/docs/blob/main/109.adoc -->
<!-- U+301A LEFT WHITE SQUARE BRACKET (〚) -->
<!-- U+301B RIGHT WHITE SQUARE BRACKET (〛) -->
<xsl:variable name="regex_ja_spec">[\u301A\u301B]</xsl:variable>
<xsl:variable name="regex_ja_spec_">[
<!-- Rotate 90° clockwise -->
\u0028 <!-- U+0028 LEFT PARENTHESIS (() -->
\uFF08 <!-- U+FF08 FULLWIDTH LEFT PARENTHESIS (() -->
\u0029 <!-- U+0029 RIGHT PARENTHESIS ()) -->
\uFF09 <!-- U+FF09 FULLWIDTH RIGHT PARENTHESIS ()) -->
\u007B <!-- U+007B LEFT CURLY BRACKET ({) -->
\uFF5B <!-- U+FF5B FULLWIDTH LEFT CURLY BRACKET ({) -->
\u007D <!-- U+007D RIGHT CURLY BRACKET (}) -->
\uFF5D <!-- U+FF5D FULLWIDTH RIGHT CURLY BRACKET (}) -->
\u3014 <!-- U+3014 LEFT TORTOISE SHELL BRACKET (〔) -->
\u3015 <!-- U+3015 RIGHT TORTOISE SHELL BRACKET (〕) -->
\u3010 <!-- U+3010 LEFT BLACK LENTICULAR BRACKET (【) -->
\u3011 <!-- U+3011 RIGHT BLACK LENTICULAR BRACKET (】) -->
\u300A <!-- U+300A LEFT DOUBLE ANGLE BRACKET (《) -->
\u300B <!-- U+300B RIGHT DOUBLE ANGLE BRACKET (》) -->
\uFF62 <!-- U+FF62 HALFWIDTH LEFT CORNER BRACKET (「) -->
\u300C <!-- U+300C LEFT CORNER BRACKET (「) -->
\uFF63 <!-- U+FF63 HALFWIDTH RIGHT CORNER BRACKET (」) -->
\u300D <!-- U+300D RIGHT CORNER BRACKET (」) -->
\u300E <!-- U+300E LEFT WHITE CORNER BRACKET (『) -->
\u300F <!-- U+300F RIGHT WHITE CORNER BRACKET (』) -->
\u005B <!-- U+005B LEFT SQUARE BRACKET ([) -->
\uFF3B <!-- U+FF3B FULLWIDTH LEFT SQUARE BRACKET ([) -->
\u005D <!-- U+005D RIGHT SQUARE BRACKET (]) -->
\uFF3D <!-- U+FF3D FULLWIDTH RIGHT SQUARE BRACKET (]) -->
\u3008 <!-- U+3008 LEFT ANGLE BRACKET (〈) -->
\u3009 <!-- U+3009 RIGHT ANGLE BRACKET (〉) -->
\u3016 <!-- U+3016 LEFT WHITE LENTICULAR BRACKET (〖) -->
\u3017 <!-- U+3017 RIGHT WHITE LENTICULAR BRACKET (〗) -->

\u301A <!-- U+301A LEFT WHITE SQUARE BRACKET (〚) -->
\u301B <!-- U+301B RIGHT WHITE SQUARE BRACKET (〛) -->
\u301C <!-- U+301C WAVE DASH (〜) -->
\u3030 <!-- U+3030 WAVY DASH (〰 )-->
\u30FC <!-- U+30FC KATAKANA-HIRAGANA PROLONGED SOUND MARK (ー) -->
\u2329 <!-- U+2329 LEFT-POINTING ANGLE BRACKET (〈) -->
\u232A <!-- U+232A RIGHT-POINTING ANGLE BRACKET (〉) -->
\u3018 <!-- U+3018 LEFT WHITE TORTOISE SHELL BRACKET (〘) -->
\u3019 <!-- U+3019 RIGHT WHITE TORTOISE SHELL BRACKET (〙) -->
\u30A0 <!-- U+30A0 KATAKANA-HIRAGANA DOUBLE HYPHEN (゠) -->
\uFE59 <!-- U+FE59 SMALL LEFT PARENTHESIS (﹙) -->
\uFE5A <!-- U+FE5A SMALL RIGHT PARENTHESIS (﹚) -->
\uFE5B <!-- U+FE5B SMALL LEFT CURLY BRACKET (﹛) -->
\uFE5C <!-- U+FE5C SMALL RIGHT CURLY BRACKET (﹜) -->
\uFE5D <!-- U+FE5D SMALL LEFT TORTOISE SHELL BRACKET (﹝) -->
\uFE5E <!-- U+FE5E SMALL RIGHT TORTOISE SHELL BRACKET (﹞) -->
\uFF5C <!-- U+FF5C FULLWIDTH VERTICAL LINE (|) -->
\uFF5F <!-- U+FF5F FULLWIDTH LEFT WHITE PARENTHESIS (⦅) -->
\uFF60 <!-- U+FF60 FULLWIDTH RIGHT WHITE PARENTHESIS (⦆) -->
\uFFE3 <!-- U+FFE3 FULLWIDTH MACRON ( ̄) -->
\uFF3F <!-- U+FF3F FULLWIDTH LOW LINE (_) -->
\uFF5E <!-- U+FF5E FULLWIDTH TILDE (~) -->
<!-- Rotate 180° -->
\u309C <!-- U+309C KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK (゜) -->
\u3002 <!-- U+3002 IDEOGRAPHIC FULL STOP (。) -->
\uFE52 <!-- U+FE52 SMALL FULL STOP (﹒) -->
\uFF0E <!-- U+FF0E FULLWIDTH FULL STOP (.) -->
]</xsl:variable>
<xsl:variable name="regex_ja_spec"><xsl:value-of select="translate(normalize-space($regex_ja_spec_), ' ', '')"/></xsl:variable>
<xsl:template name="insertVerticalChar">
<xsl:param name="str"/>
<xsl:param name="writing-mode">lr-tb</xsl:param>
<xsl:param name="reference-orientation">90</xsl:param>
<xsl:param name="add_zero_width_space">false</xsl:param>
<xsl:if test="string-length($str) &gt; 0">
<xsl:variable name="char" select="substring($str,1,1)"/>
<fo:inline-container text-align="center" alignment-baseline="central" width="1em" margin="0" padding="0" text-indent="0mm" last-line-end-indent="0mm" start-indent="0mm" end-indent="0mm">
<xsl:if test="normalize-space($writing-mode) != ''">
<xsl:attribute name="writing-mode"><xsl:value-of select="$writing-mode"/></xsl:attribute>
<xsl:attribute name="reference-orientation">90</xsl:attribute>
</xsl:if>
<xsl:if test="normalize-space(java:matches(java:java.lang.String.new($char), concat('(', $regex_ja_spec, '{1,})'))) = 'true'">
<xsl:attribute name="reference-orientation">0</xsl:attribute>
<xsl:choose>
<xsl:when test="ancestor::*[local-name() = 'span'][@class = 'norotate']">
<xsl:value-of select="$str"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="string-length($str) &gt; 0">
<xsl:variable name="horizontal_mode" select="normalize-space(ancestor::*[local-name() = 'span'][@class = 'horizontal'] and 1 = 1)"/>
<xsl:variable name="char" select="substring($str,1,1)"/>
<fo:inline-container text-align="center" alignment-baseline="central" width="1em" margin="0" padding="0" text-indent="0mm" last-line-end-indent="0mm" start-indent="0mm" end-indent="0mm">
<xsl:if test="normalize-space($writing-mode) != ''">
<xsl:attribute name="writing-mode"><xsl:value-of select="$writing-mode"/></xsl:attribute>
<xsl:attribute name="reference-orientation">90</xsl:attribute>
</xsl:if>
<xsl:if test="normalize-space(java:matches(java:java.lang.String.new($char), concat('(', $regex_ja_spec, '{1,})'))) = 'true'">
<xsl:attribute name="reference-orientation">0</xsl:attribute>
</xsl:if>
<xsl:if test="$char = '゜' or $char = '。' or $char = '﹒' or $char = '.'">
<!-- Rotate 180°:
U+309C KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK (゜)
U+3002 IDEOGRAPHIC FULL STOP (。)
U+FE52 SMALL FULL STOP (﹒)
U+FF0E FULLWIDTH FULL STOP (.)
-->
<xsl:attribute name="reference-orientation">-90</xsl:attribute>
</xsl:if>
<fo:block-container width="1em">
<fo:block line-height="1em">
<xsl:choose>
<xsl:when test="$horizontal_mode = 'true'">
<xsl:value-of select="$str"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$char"/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:block-container>
</fo:inline-container>
<xsl:if test="$add_zero_width_space = 'true' and ($char = ',' or $char = '.' or $char = ' ' or $char = '·' or $char = ')' or $char = ']' or $char = '}')"><xsl:value-of select="$zero_width_space"/></xsl:if>

<xsl:if test="$horizontal_mode = 'false'">
<xsl:call-template name="insertVerticalChar">
<xsl:with-param name="str" select="substring($str, 2)"/>
<xsl:with-param name="writing-mode" select="$writing-mode"/>
<xsl:with-param name="reference-orientation" select="$reference-orientation"/>
<xsl:with-param name="add_zero_width_space" select="$add_zero_width_space"/>
</xsl:call-template>
</xsl:if>
</xsl:if>
<fo:block-container width="1em">
<fo:block line-height="1em"><xsl:value-of select="$char"/></fo:block>
</fo:block-container>
</fo:inline-container>
<xsl:if test="$add_zero_width_space = 'true' and ($char = ',' or $char = '.' or $char = ' ' or $char = '·' or $char = ')' or $char = ']' or $char = '}')"><xsl:value-of select="$zero_width_space"/></xsl:if>
<xsl:call-template name="insertVerticalChar">
<xsl:with-param name="str" select="substring($str, 2)"/>
<xsl:with-param name="writing-mode" select="$writing-mode"/>
<xsl:with-param name="reference-orientation" select="$reference-orientation"/>
<xsl:with-param name="add_zero_width_space" select="$add_zero_width_space"/>
</xsl:call-template>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="number-to-words">
Expand Down

0 comments on commit 14aae36

Please sign in to comment.