Skip to content

empty <script> tag wraps but doesn't indent properly #13

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

Closed
AlexHowansky opened this issue Mar 9, 2012 · 5 comments
Closed

empty <script> tag wraps but doesn't indent properly #13

AlexHowansky opened this issue Mar 9, 2012 · 5 comments

Comments

@AlexHowansky
Copy link

Given this input file:

<!doctype html>
<html>
<head>
<title>test</title>
<link href="foo.css" media="screen" rel="stylesheet" type="text/css">
<script type="text/javascript" src="bar.js"></script>
</head>
<body>
</body>
</html>

I'll run tidy like this:

tidy --indent yes --indent-spaces 4 --wrap 0 --quiet yes --tidy-mark no test.html

And get:

<!DOCTYPE html>
<html>
    <head>
        <title>
            test
        </title>
        <link href="foo.css" media="screen" rel="stylesheet" type="text/css">
        <script type="text/javascript" src="bar.js">
</script>
    </head>
    <body>
    </body>
</html>

Note that the closing script tag is wrapped but not indented. If I put a comment inside the tags:

<!doctype html>
<html>
<head>
<title>test</title>
<link href="foo.css" media="screen" rel="stylesheet" type="text/css">
<script type="text/javascript" src="bar.js"><!-- nothing --></script>
</head>
<body>
</body>
</html>

Then I'll get this:

<!DOCTYPE html>
<html>
    <head>
        <title>
            test
        </title>
        <link href="foo.css" media="screen" rel="stylesheet" type="text/css">
        <script type="text/javascript" src="bar.js">
<!-- nothing -->
        </script>
    </head>
    <body>
    </body>
</html>

I'm thinking that the closing script tag should either not wrap at all (in the case where there's no content) or wrap and be indented to match the opening tag.

Thanks.

@daaain
Copy link

daaain commented Mar 14, 2012

I'd rather prefer it to not wrap at all in case there's no content in the node (or rather if there is a src attribute?), makes the head contents twice as long and ugly. Will attempt a fix and send a pull request later.

@sideshowbarker
Copy link
Contributor

I'm not keen on changing this. This has always been the tidy behavior and it is not something new that got introduced in this fork. I think it's intended behavior with some rationale behind it, though I don't know what. Somebody should research it.

@daaain
Copy link

daaain commented Mar 14, 2012

Well it seems that it's recognised as a bug, but treated as so low priority that no one touched it since October 2008...

Original email thread on the mailing list: http://lists.w3.org/Archives/Public/html-tidy/2008OctDec/0005.html

Bug in tracker: http://sourceforge.net/tracker/?func=detail&atid=390963&aid=2207646&group_id=27659

I couldn't find any reasoning why would this be a desired effect, so maybe something which could be a nice fix (albeit admittedly cosmetic) both for this project and upstream?

@sideshowbarker
Copy link
Contributor

Not finding any stated reasoning for it doesn't mean there is none. If it were a clear and simple thing to make a change for I expect it would've been changed long ago. Anyway, it's up to you if you want to put time into writing a patch. If you do it will need to be tested to make sure it doesn't regress anything, introduce new bugs.

@sideshowbarker
Copy link
Contributor

Closing this out as there's not be an action on it. I don't plan on making any change for this myself. If somebody else does, feel free to re-open this and/or make a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants