remove spaces and carriage returns from Plone content with Diazo(minimizing html code)

点点圈 提交于 2019-12-11 03:53:39

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!