如何在不破坏标签的情况下剪辑HTML片段? [英] How to clip HTML fragments without breaking up tags?
本文介绍了如何在不破坏标签的情况下剪辑HTML片段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< b>
,而不是< / b>
。任何服务器端处理都应该在PHP中。 您应该查看Tidy HTML 。在前50个非HTML字符后面剪切它,然后通过Tidy运行到 fix HTML。
Say I have a 200 character string that contains HTML markup. I want to show a preview of just the first 50 chars. without 'splitting up' the tags. In other words, the fragment should not contain a <b>
without a </b>
. Any server side processing should be in PHP.
解决方案
You should check out Tidy HTML. Just cut it after the first 50 non-HTML characters, then run it through Tidy to fix the HTML.
这篇关于如何在不破坏标签的情况下剪辑HTML片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文