简体   繁体   English

在p标签中包装段落

[英]Wrapping paragraphs in p tags

I have a HTML Document that has correct paragraph formatting for most of the text But there are some paragraphs that don't contain p tags and as such are not displaying correctly. 我有一个HTML文档,其中包含大多数文本的正确段落格式但是有些段落不包含p标签,因此无法正确显示。

Is there way to inclose paragraphs with <p> </p> tags using a text editor with regular expressions? 有没有办法用正常表达式的文本编辑器用<p> </p>标签包含段落? I tried using HTML tidy, but I cant get it to recognize separate paragraphs or it reformats it in the wrong way, I dont know what is going on... 我尝试使用HTML整洁,但我不能让它识别单独的段落或它以错误的方式重新格式化,我不知道发生了什么...

I need each paragraph that doesnt already contain html tags to have the paragraphs wrapped: 我需要每个段落都没有包含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.

Like this 像这样

<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>'

Using regular expressions: 使用正则表达式:

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

Is the easiest, but it requires cleaning up an extra close tag at the start of the document and an extra open tag at the end. 是最简单的,但它需要在文档的开头清理一个额外的关闭标记,并在最后添加一个额外的开放标记。 It is possible to get it perfect but I don't find it's worth the trouble. 有可能让它变得完美,但我觉得它不值得麻烦。

I'd agree with the guy above, just add them in manually. 我同意上面的那个人,只需手动添加它们。 If the content is coming from a web page on your server just deploy a WYSIWYG editor (loads of them around) and they should cater for that function. 如果内容来自服务器上的网页,只需部署一个WYSIWYG编辑器(它们周围的负载),它们应该满足该功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM