spl*_*ter 6 tinymce plone strip diazo
我有一个Plone网站,以plone.app.theming为主题.我遇到的问题是设计非常严格,不假设任何空<p>元素或任何其他无意义的TinyMCE输出.这些元素打破了预期的设计.所以我想从内容中删除空元素.我试过内联xslt(根据http://diazo.org/advanced.html#inline-xsl-directives应该支持),如:
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[not(*) and not(text()[normalize-space()])]"/>
Run Code Online (Sandbox Code Playgroud)
但它并没有成功.事实上它让人觉得奇怪.p我想要摆脱的空标签保持完整,但其他一些元素
<a href="mylink"> <img src="../++theme++jarn.com/whatever.png" /></a>
Run Code Online (Sandbox Code Playgroud)
转换成
<a href="mylink"></a>
Run Code Online (Sandbox Code Playgroud)
将图像条纹化.替换match="*[…第二个模板match="p[…并没有删除图像,但那些讨厌<p>的仍然在输出中.
有关如何使用重氮规则摆脱空元素的任何提示?
更新 2012年1月31日这是我需要p剥离空标签的内容:
<div id="parent-fieldname-text">
<p></p>
<p> </p>
<p> </p>
<p><section id="what-we-do">
<p class="visualClear summary">Not empty Paragraph</p>
<ul class="thumbsList">
<li><a href="mylink"> <img src="../++theme++jarn.com/whatever.png" /></a></li>
<li><a href="mylink"> <img src="../++theme++jarn.com/whatever.png" /></a></li>
</ul>
</section></p>
</div>
Run Code Online (Sandbox Code Playgroud)
重氮转型规则:
<?xml version="1.0" encoding="UTF-8"?>
<rules
xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="p[not(*) and not(normalize-space())]"/>
<!-- The default theme, used for standard Plone web pages -->
<theme href="index.html" css:if-content="#visual-portal-wrapper" />
<replace css:theme-children="div.contentWrapper" css:content-children="#content" />
</rules>
Run Code Online (Sandbox Code Playgroud)
将变换应用到Plone站点后得到的输出与输入完全相同,而我打算<p>在打开后获得这3个空标记<div>.
如果我更改第二个模板以匹配所有元素,match="*…那么图像将被剥离,但空<p>标记仍然存在.
对我有用。我在https://github.com/plone/diazo/commit/94ddff7117d25d3a8a89457eeb272b5500ec21c5添加了一个在删除内容规则中使用 Dimitre 的 xpath 的示例,但它也可以用作等效的 xsl:template 。该示例被简化为基础知识,但它也可以使用问题中的完整示例内容。
| 归档时间: |
|
| 查看次数: |
803 次 |
| 最近记录: |