[Yanel-commits] rev 24041 - in public/yanel/trunk/src:
contributions/resources/wiki/xslt
core/java/org/wyona/yanel/core/serialization
simon at wyona.com
simon at wyona.com
Fri Apr 27 09:42:28 CEST 2007
Author: simon
Date: 2007-04-27 09:42:15 +0200 (Fri, 27 Apr 2007)
New Revision: 24041
Modified:
public/yanel/trunk/src/contributions/resources/wiki/xslt/wiki2xhtml.xsl
public/yanel/trunk/src/core/java/org/wyona/yanel/core/serialization/HTMLSerializer.java
Log:
fixes bug #5145 thanks to josias!
Modified: public/yanel/trunk/src/contributions/resources/wiki/xslt/wiki2xhtml.xsl
===================================================================
--- public/yanel/trunk/src/contributions/resources/wiki/xslt/wiki2xhtml.xsl 2007-04-27 07:38:42 UTC (rev 24040)
+++ public/yanel/trunk/src/contributions/resources/wiki/xslt/wiki2xhtml.xsl 2007-04-27 07:42:15 UTC (rev 24041)
@@ -182,7 +182,7 @@
<xsl:when test="@label"><xsl:value-of select="@label"/></xsl:when>
<xsl:otherwise><xsl:value-of select="@href"/></xsl:otherwise>
</xsl:choose>
- </u><a href="?yanel.usecase=create&create.name={@href}">?</a><xsl:text> </xsl:text>
+ </u><a href="?yanel.usecase=create&create.name={@href}">?</a>
<!--
</u><a href="?yanel.usecase=create&create.name={@href}&resource.type=<{http://www.wyona.org/yanel/resource/1.0}wiki/>">?</a><xsl:text> </xsl:text>
-->
@@ -190,10 +190,10 @@
<xsl:otherwise>
<xsl:choose>
<xsl:when test="@label">
- <a href="{@href}"><xsl:value-of select="@label"/></a><xsl:text> </xsl:text>
+ <a href="{@href}"><xsl:value-of select="@label"/></a>
</xsl:when>
<xsl:otherwise>
- <a href="{@href}"><xsl:value-of select="@href"/></a><xsl:text> </xsl:text>
+ <a href="{@href}"><xsl:value-of select="@href"/></a>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/serialization/HTMLSerializer.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/serialization/HTMLSerializer.java 2007-04-27 07:38:42 UTC (rev 24040)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/serialization/HTMLSerializer.java 2007-04-27 07:42:15 UTC (rev 24041)
@@ -23,8 +23,13 @@
private boolean doIndent;
private boolean visitedRootElement = false;
- private String[] nonCollapsableElements = { "textarea", "script", "style", "div" };
+ protected static final String[] nonCollapsableElements = { "textarea", "script", "style", "div" };
+ protected static final String[] inlineElements = {"a", "abbr", "acronym", "b", "basefont",
+ "bdo", "big", "br", "cite", "code", "dfn", "em", "font", "i", "img", "input", "kbd",
+ "label", "q", "s", "samp", "select", "small", "span", "strike", "strong", "sub", "sup",
+ "textarea", "tt", "u", "var"};
+
public HTMLSerializer() {
}
@@ -101,13 +106,29 @@
} else {
print("</" + eName + ">");
}
- if (this.doIndent) {
- // not a real indent yet, just add linebreaks
+ if (this.doIndent && !isInlineElement(eName)) {
+ // Not a real indent yet, just add line breaks.
+ // Don't add line breaks after inline-elements because it might break the
+ // layout. see http://www.w3.org/TR/CSS21/text.html#q8
print("\n");
}
}
/**
+ * Indicates whether an html element is a inline element or not.
+ * @param element element name
+ * @return true if it's an inline element, false otherwise.
+ */
+ protected boolean isInlineElement(String element) {
+ for (int i = 0; i < inlineElements.length; i++) {
+ if (element.equals(inlineElements[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Writes the pending element if there is one.
* This method is called when we know that the element is either non-empty
* or non-collapsable.
More information about the Yanel-commits
mailing list