【问题标题】:HTML Tidy. Please don't add end tagsHTML 整洁。请不要添加结束标签
【发布时间】:2012-07-14 17:40:54
【问题描述】:

我有三个文件。

header.php
index.php
footer.php

头文件包含从<html><div id='content'> 索引文件包含页面内容 页脚文件包含</div></html> 它们一起包含一个普通的带有 PHP 的 HTML 文件

当我使用 Tidy HTML 来整理我的 php 文件的 HTML 时,它会出错。 当我整理 header.php 时,它会在我的名为 content 的 div 中添加结束标签,但它不应该这样做。 div 继续通过 index.php 并在 footer.php 中关闭以指定文件的内容。

是否可以让 HTML Tidy 忽略缺少的结束标签?

【问题讨论】:

  • 您是在本地编辑器上使用 tidy,还是在谈论 jsfiddle 之类的网站?

标签: html tidy htmltidy


【解决方案1】:

可以这样解决:

<html>
<head>
  <?php include "head.php" ?>
</head>
<body>
  <?php include "header.php" ?>
  <?php include "index.php" ?>
  <?php include "footer.php" ?>
</body>
</html>

并且文件 index.php、head.php、header.php 和 footer.php 现在应该有开始和结束标记。该程序这样做是因为它认为您错过了封闭标签。我看到了 Tidy HTML,它会自动放置关闭标签。


来源:我以这种方式做网站的经验

【讨论】:

    【解决方案2】:

    听起来你的config 中需要hide-endtags: yes

    Type: Boolean
    Default: no
    Example: y/n, yes/no, t/f, true/false, 1/0  
    

    此选项指定 Tidy 是否应在以下情况下省略可选的结束标记 生成漂亮的打印标记。如果您 正在输出到 XML。

    根据规范linked herehtmlbody 开始标签也是可选的,我的Tidy 也删除了这些,应该没问题。 cfg文件:

    hide-endtags: yes // Don't add optional end tags. Also hides optional start tags like HTML and BODY.
    tidy-mark: no  // Don't add generator meta tag.
    

    但是,它仍然关闭divThis alternative suggested here 按预期工作。

    【讨论】:

      猜你喜欢
      • 2018-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-22
      • 2023-03-19
      相关资源
      最近更新 更多