问题
I have a Plone site, themed with plone.app.theming.
how diazo minimizing html content? and remove spaces and carriage returns
Content:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div id="content">
<p>Not empty paragraph text</p>
<p><span>Not empty paragraph element</span>
</div>
</body>
</html>
Output:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head><body><div id="content"><p>Not empty paragraph text</p><p><span>Not empty paragraph element</span></div></body></html>
回答1:
You can remove leading and trailing whitespace and replace sequences of whitespace characters by a single space with normalize-space
as follows:
<xsl:template match="text()"><xsl:value-of select="normalize-space(.)"/></xsl:template>
We use it together with the following:
<xsl:template match="comment()"/>
<xsl:template match="node()[@style='display:none']"/>
This might help you minimizing some of your html-code.
Removing CR and Tabs will require a more complex set of rules.
来源:https://stackoverflow.com/questions/21532919/remove-spaces-and-carriage-returns-from-plone-content-with-diazominimizing-html