Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Tidy stripping space at the start

File.html

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

Command

$ tidy File.html

Output

word<i>ratti</i>

Desired output

word<i> ratti</i>

Where's the space?

Log

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>
like image 976
Chankey Pathak Avatar asked Nov 10 '22 05:11

Chankey Pathak


1 Answers

This issue seems to have been solved in newer versions. I was using the version from 2003. I just updated tidy on my machine with 2009'th version and with that the output is like below.

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

So it is preserving space now, however it does not delete the span tag, anyway this looks like a proper answer to the question.

like image 98
Chankey Pathak Avatar answered Jan 24 '23 15:01

Chankey Pathak