Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formatting inside of <pre> tags #1117

Open
wants to merge 9 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions regression_testing/cases/access-cases/case-1006.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
keep-tabs: yes
output-xhtml: yes
show-info: no
force-output: yes
16 changes: 16 additions & 0 deletions regression_testing/cases/access-cases/case-1006@0.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<title>aert1.0/13.10.1</title>
</head>
<body>
<pre>
<code>
func sup() {
print("hello")
return
}
</code>
</pre>
</body>
</html>
17 changes: 17 additions & 0 deletions regression_testing/cases/access-expects/case-1006.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>aert1.0/13.10.1</title>
</head>
<body>
<pre>
<code>
func sup() {
print("hello")
return
}
</code>
</pre>
</body>
</html>
2 changes: 2 additions & 0 deletions regression_testing/cases/access-expects/case-1006.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
No warnings or errors were found.

12 changes: 11 additions & 1 deletion src/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2516,7 +2516,7 @@ static Node* GetTokenFromStream( TidyDocImpl* doc, GetTokenMode mode )
AttVal *attributes = NULL;
Node *node;
Bool fixComments;

switch ( cfgAutoBool(doc, TidyFixComments) )
{
case TidyYesState:
Expand All @@ -2542,6 +2542,16 @@ static Node* GetTokenFromStream( TidyDocImpl* doc, GetTokenMode mode )

while ((c = TY_(ReadChar)(doc->docIn)) != EndOfStream)
{
// Check to see if we're in a pre, if so, don't worry about whitespace
Node *parent = lexer->parent;
while (parent) {
if (nodeIsPRE(parent)) {
mode = Preformatted;
}

parent = parent->parent;
}

if (lexer->insertspace)
{
TY_(AddCharToLexer)(lexer, ' ');
Expand Down