使用Diazo从Plone内容中删除空格和回车符(最小化html代码) [英] remove spaces and carriage returns from Plone content with Diazo(minimizing html code)
本文介绍了使用Diazo从Plone内容中删除空格和回车符(最小化html代码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个以plone.app.theming为主题的Plone网站.
I have a Plone site, themed with plone.app.theming.
如何重氮使html内容最小化? 并删除空格和回车符
how diazo minimizing html content? and remove spaces and carriage returns
内容:
<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>
输出:
<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>
推荐答案
您可以删除前导和尾随空格,并使用normalize-space
将空格字符序列替换为单个空格,如下所示:
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']"/>
这可以帮助您最小化一些html代码.
This might help you minimizing some of your html-code.
删除CR和制表符将需要一组更复杂的规则.
Removing CR and Tabs will require a more complex set of rules.
这篇关于使用Diazo从Plone内容中删除空格和回车符(最小化html代码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文