gpt4 book ai didi

html - 在 p 标签中包装段落

转载 作者:太空宇宙 更新时间:2023-11-04 13:21:34 25 4
gpt4 key购买 nike

我有一个 HTML 文档,其中大部分文本的段落格式都是正确的,但是有些段落不包含 p 标签,因此无法正确显示。

有没有办法用 <p> </p> 来包含段落?使用带有正则表达式的文本编辑器的标签?我尝试使用 HTML tidy,但我无法让它识别单独的段落或以错误的方式重新格式化它,我不知道发生了什么......

我需要每个不包含 html 标签的段落来换行:

Template Design Creation for the layout for the content that will exist on each page.

Custom Programing to make certain features work with the design.

Photos of the Location For the Website Design Elements.

像这样

<p>Template Design Creation for the layout for the content that will exist on each page.</p>

<p>Custom Programing to make certain features work with the design.</p>

<p>Photos of the Location For the Website Design Elements.</p>'

最佳答案

使用正则表达式:

/($|\n|^)/$1<\/p>\n<p>/g

是最简单的,但它需要在文档的开头清理一个额外的关闭标记,并在末尾清理一个额外的打开标记。有可能让它变得完美,但我觉得不值得这么麻烦。

关于html - 在 p 标签中包装段落,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16443019/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com