我有一个包含一行无格式html的div,我只需要格式化这个div,而不是在这些html页面中使用其他格式。我有大约152页,格式相似,我不知道如何格式化这些页面...
我使用Simple PHP HTML DOM Parser来创建这些页面,这个div没有正确格式化。
该格式类似于以下内容:
<div class="r_features" itemprop="description">
<h2>Features</h2> <ul> <li>lorem ipsum one two three</li> <li>lorem ipsum one two three</li> <li>lorem ipsum one two three</li> <li>lorem ipsum one two three</li> <li>lorem ipsum one two three</li> <li>lorem ipsum one two three</li> <li>lorem ipsum one two three</li> <li>lorem ipsum one two three</li> </ul>
</div>
左边有一个缩进到r_features
div,在这个div之前和之后有更多格式化的div。因此,如果我使用Dreamweaver批量/批量格式化这些页面,那么所有其他div都会受到干扰。我只需要保留页面的现有格式,但只更改此div。
如何在不打扰其他div的情况下实现这一目标?我正在尝试寻找一个程序或php工具,让我选择确切的div来应用格式化。
编辑: 这就是我需要为html文件格式化div的方法......这些div包含一行中的列表,表格和段落,如上例所示。我正在尝试格式化这些div类似于以下格式:
<div class="r_features" itemprop="description">
<h2>Features</h2>
<ul>
<li>lorem ipsum one two three</li>
<li>lorem ipsum one two three</li>
<li>lorem ipsum one two three</li>
<li>lorem ipsum one two three</li>
<li>lorem ipsum one two three</li>
<li>lorem ipsum one two three</li>
<li>lorem ipsum one two three</li>
<li>lorem ipsum one two three</li>
</ul>
</div>
答案 0 :(得分:0)
Notepad ++有html整洁的插件,可以让你整理或重新格式化你的HTML代码。如果这是你正在寻找的东西,并不是很确定,但希望它有所帮助。
答案 1 :(得分:0)
我明白了......
我在PHP Simple HTML Dom Parser中使用了file_get_html()
函数来获取文件的html内容。
在此期间,整个html被转换为单行字符串,因为此函数的默认参数,$stripRN
设置为true
...到期对此,文件的输出被转换为字符串,而不是格式化的html。
所以我首先在Dreamweaver中格式化内容,然后通过使用命令file_get_html()
加载文件并将其第9个参数设置为false
来将该内容复制到文件中。 / p>
以下是如何使用该功能保持源格式不变。
$html = file_get_html("content_html/$file_name", NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL, NULL);
content_html是我的www目录中的一个文件夹。 $ file_name是正在遍历的html文件。