[PATCH 07/17] XHTML export: Use zero-width spaces instead of non-breaking spaces

andrew-libreoffice.org at pileofstuff.org andrew-libreoffice.org at pileofstuff.org
Thu Aug 14 14:53:47 PDT 2014


From: Andrew Sayers <andrew-libreoffice.org at pileofstuff.org>

The XHTML writer sometimes needs to force an element to have height.
Using non-breaking spaces in underlined paragraphs shows an ugly
underline, so we use zero-width spaces instead.
---
 filter/source/xslt/odf2xhtml/export/xhtml/body.xsl | 22 +++++++++++-----------
 .../source/xslt/odf2xhtml/export/xhtml/table.xsl   |  4 ++--
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git filter/source/xslt/odf2xhtml/export/xhtml/body.xsl filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
index fc018c4..d4d5ee7 100644
--- filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
+++ filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
@@ -391,9 +391,9 @@
 						 </xsl:with-param>-->
 					</xsl:apply-templates>
 				</xsl:element>
-				<!-- after the last draw:frame sibling the CSS float is disabled
-					  is an unbreakable whitespace to give conent to the element and force a browser not to ignore the element -->
-				<div style="clear:both; line-height:0; width:0; height:0; margin:0; padding:0;"> </div>
+				<!-- after the last draw:frame sibling, the CSS float is disabled.
+					&#x200b; (zero-width space) gives conent to the element, forcing the browser to display the element -->
+				<div style="clear:both; line-height:0; width:0; height:0; margin:0; padding:0;">&#x200b;</div>
 			</xsl:when>
 			<xsl:when test="text:tab and not(ancestor::text:index-body)">
 				<!-- If there is a tabulator (ie. text:tab) within a paragraph, a heuristic for ODF tabulators creates a
@@ -516,7 +516,7 @@
 							</xsl:attribute>
 						</xsl:when>
 						<xsl:otherwise>
-							<!-- if there are more than 3 TABS in the style, create a none-breakable-space as whitespace -->
+							<!-- if there are more than 3 TABS in the style, create a non-breakable-space as whitespace -->
 							<xsl:text> </xsl:text>
 						</xsl:otherwise>
 					</xsl:choose>
@@ -743,7 +743,7 @@
 					<xsl:with-param name="globalData" select="$globalData" />
 					<xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
 				</xsl:call-template>
-				<xsl:text> </xsl:text>
+				<xsl:text>&#x200b;</xsl:text>
 			</xsl:otherwise>
 		</xsl:choose>
 	</xsl:template>
@@ -889,7 +889,7 @@
 		</xsl:call-template>
 		<!-- after the last draw:frame sibling the CSS float is disabled -->
 		<xsl:if test="@text:anchor-type!='as-char'">
-			<div style="clear:both; line-height:0; width:0; height:0; margin:0; padding:0;"> </div>
+			<div style="clear:both; line-height:0; width:0; height:0; margin:0; padding:0;">&#x200b;</div>
 		</xsl:if>
 	</xsl:template>
 
@@ -995,7 +995,7 @@
 						<xsl:value-of select="$svgY"/>
 						<xsl:text>cm;</xsl:text>
 					</xsl:attribute>
-					<xsl:text> </xsl:text>
+					<xsl:text>&#x200b;</xsl:text>
 				</xsl:element>
 			</xsl:if>
 		</xsl:if>
@@ -2056,13 +2056,13 @@
 											</xsl:choose>
 										</xsl:variable>
 										<!-- Some browsers have problems with stand-alone elements (i.e. <span/>),
-											so we use a non-breaking space instead -->
+											so we use a zero-width space instead -->
 										<xsl:choose>
 											<xsl:when test="$labelContent != ''">
 												<xsl:value-of select="$labelContent"/>
 											</xsl:when>
 											<xsl:otherwise>
-												<xsl:comment> </xsl:comment>
+												<xsl:comment>&#x200b;</xsl:comment>
 											</xsl:otherwise>
 										</xsl:choose>
 									</xsl:element>
@@ -2551,7 +2551,7 @@
 			</xsl:apply-templates>
 			<!-- this span disables the float necessary to bring two block elements on one line. It contains a space as IE6 bug workaround -->
 			<span class="odfLiEnd"></span>
-			<xsl:text> </xsl:text>
+			<xsl:text>&#x200b;</xsl:text>
 		</xsl:element>
 
 		<xsl:apply-templates mode="list-item-children" select="following-sibling::*[1]">
@@ -2620,7 +2620,7 @@
 
 			<!-- this span disables the float necessary to bring two block elements on one line. It contains a space as IE6 bug workaround -->
 			<span class="odfLiEnd"></span>
-			<xsl:text> </xsl:text>
+			<xsl:text>&#x200b;</xsl:text>
 		</xsl:element>
 
 		<xsl:apply-templates mode="list-item-children" select="following-sibling::*[1]">
diff --git filter/source/xslt/odf2xhtml/export/xhtml/table.xsl filter/source/xslt/odf2xhtml/export/xhtml/table.xsl
index 2f72ee7..b7180ba 100644
--- filter/source/xslt/odf2xhtml/export/xhtml/table.xsl
+++ filter/source/xslt/odf2xhtml/export/xhtml/table.xsl
@@ -159,7 +159,7 @@
 			</xsl:if>
 
 			<!-- empty cell tags cause problems with with CSS styles (for the empty cells and others)
-				therefore a non-breaking space ( / ) has been inserted -->
+				therefore a zero-width space has been inserted -->
 			<xsl:choose>
 				<xsl:when test="node()">
 					<xsl:call-template name="apply-styles-and-content">
@@ -170,7 +170,7 @@
 					<xsl:call-template name="apply-styles-and-content">
 						<xsl:with-param name="globalData" select="$globalData" />
 					</xsl:call-template>
-					<xsl:text> </xsl:text>
+					<xsl:text>&#x200b;</xsl:text>
 				</xsl:otherwise>
 			</xsl:choose>
 
-- 
1.8.5.1



More information about the LibreOffice mailing list