Skip to content

Commit 5e5d046

Browse files
Merge pull request #660 from metanorma/svg_resize
common.xsl updated for SVG wrong size fixing, metanorma/metanorma-bsi…
2 parents 12be7b2 + 998f2bb commit 5e5d046

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

xslt_src/common.xsl

+8-4
Original file line numberDiff line numberDiff line change
@@ -12648,6 +12648,8 @@
1264812648
</xsl:attribute>
1264912649
</xsl:template>
1265012650

12651+
<xsl:variable name="regex_starts_with_digit">^[0-9].*</xsl:variable>
12652+
1265112653
<xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
1265212654
<xsl:copy>
1265312655
<xsl:apply-templates select="@*" mode="svg_update"/>
@@ -12666,7 +12668,8 @@
1266612668

1266712669
<xsl:attribute name="width">
1266812670
<xsl:choose>
12669-
<xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
12671+
<!-- width is non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
12672+
<xsl:when test="$parent_image_width != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_width), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_width"/></xsl:when>
1267012673
<xsl:when test="$width != ''">
1267112674
<xsl:value-of select="round($width)"/>
1267212675
</xsl:when>
@@ -12675,7 +12678,8 @@
1267512678
</xsl:attribute>
1267612679
<xsl:attribute name="height">
1267712680
<xsl:choose>
12678-
<xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
12681+
<!-- height non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
12682+
<xsl:when test="$parent_image_height != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_height), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_height"/></xsl:when>
1267912683
<xsl:when test="$height != ''">
1268012684
<xsl:value-of select="round($height)"/>
1268112685
</xsl:when>
@@ -12692,7 +12696,7 @@
1269212696
<xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
1269312697
<xsl:attribute name="width">
1269412698
<xsl:choose>
12695-
<xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
12699+
<xsl:when test="$parent_image_width != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_width), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_width"/></xsl:when>
1269612700
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
1269712701
</xsl:choose>
1269812702
</xsl:attribute>
@@ -12703,7 +12707,7 @@
1270312707
<xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
1270412708
<xsl:attribute name="height">
1270512709
<xsl:choose>
12706-
<xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
12710+
<xsl:when test="$parent_image_height != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_height), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_height"/></xsl:when>
1270712711
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
1270812712
</xsl:choose>
1270912713
</xsl:attribute>

0 commit comments

Comments
 (0)