[英]Remove blank paragraph tags - TinyMCE
I am trying to remove blank paragraphs generated by TinyMCE. 我想删除TinyMCE生成的空白段落。 I want to use a RegEx because the set of HTML tags is finite in my universe but I am not sure how to go about it.
我想使用RegEx,因为我的Universe中的HTML标记集是有限的,但我不确定如何去做。
For this purpose my definition of blank is anything that does not have text. 为此,我对空白的定义是任何没有文本的东西。 Here are some blank tag paragraphs I am getting from TinyMCE:
以下是我从TinyMCE获得的一些空白标签段落:
<p><strong><br></strong></p>
<p><br></p>
<p> </p>
<p></p>
Basically if no text is going to show up inside the paragraph tags, I want to remove it.. any ideas? 基本上如果没有文本会出现在段落标签内,我想删除它..任何想法?
Give the Html Agility Pack a try, it'll parse your HTML fragment into a DOM which can be traversed to strip any <p>
tags that meet your criteria. 尝试使用Html Agility Pack ,它会将您的HTML片段解析为一个DOM,可以遍历该DOM以去除符合您条件的任何
<p>
标记。 This'll be much easier and more robust that using a regex. 使用正则表达式会更容易,更强大。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.