HTML在开始时整洁地剥离空间



File.html

word<i><span> <span>ratti</span></span></i>

命令

$ tidy File.html

输出

word<i>ratti</i>

所需输出

word<i> ratti</i>

空间在哪里?

记录

line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 1 column 1 - Warning: plain text isn't allowed in <head> elements
line 1 column 8 - Warning: <span> is probably intended as </span>
line 1 column 5 - Warning: replacing unexpected span by </span>
line 1 column 33 - Warning: discarding unexpected </span>
line 1 column 40 - Warning: discarding unexpected </i>
line 1 column 1 - Warning: inserting missing 'title' element
line 1 column 8 - Warning: trimming empty <span>
Info: Document content looks like HTML 4.01 Transitional
8 warnings, 0 errors were found!
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st November 2003), see www.w3.org">
<title></title>
</head>
<body>
word<i>ratti</i>
</body>
</html>

此问题似乎已在较新版本中得到解决。我使用的是2003年的版本。我刚刚用2009年的版本更新了我的机器上的整洁,输出如下。

content: word<i><span> <span>ratti</span></span></i>
command: tidy file.html
output: word <i><span><span>ratti</span></span></i>

因此,它现在保留了空间,但它没有删除span标记,无论如何,这看起来是这个问题的正确答案。

最新更新