Pretty Print/Fix deleting lines of code
-
- Rank I - Novice
- Posts: 14
- Joined: Sat Oct 14, 2006 6:05 am
Pretty Print/Fix deleting lines of code
I am converting a site to be responsive using Bootstrap. The following lines of code provide the collapsing Navbar and the bar icon for mobile use:
<div class="navbar navbar-default navbar-static-top">
<div class="container">
<img class="featureImg" src="images/panorama1170x96.jpg" alt="Wokingham panorama" height="100%" width="100%">
<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse"></button>
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav navbar-left">
<li class="active">
<a href="index.html">Home</a>
</li>
Using Pretty Print/Fix on the code deletes four lines leaving:
<div class="navbar navbar-default navbar-static-top">
<div class="container">
<img class="featureImg" src="images/panorama1170x96.jpg" alt="Wokingham panorama" height="100%" width="100%">
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav navbar-left">
<li class="active">
<a href="index.html">Home</a>
</li>
<li>
<a href="aboutws.html">About</a>
</li>
I like to use Pretty Print/Fix but cannot do so if it deletes lines of code rather than just tidying things up.
I would appreciate any thoughts on why it is deleting lines of code and any suggestions of what if anything I can do to stop it doing so.
<div class="navbar navbar-default navbar-static-top">
<div class="container">
<img class="featureImg" src="images/panorama1170x96.jpg" alt="Wokingham panorama" height="100%" width="100%">
<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse"></button>
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav navbar-left">
<li class="active">
<a href="index.html">Home</a>
</li>
Using Pretty Print/Fix on the code deletes four lines leaving:
<div class="navbar navbar-default navbar-static-top">
<div class="container">
<img class="featureImg" src="images/panorama1170x96.jpg" alt="Wokingham panorama" height="100%" width="100%">
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav navbar-left">
<li class="active">
<a href="index.html">Home</a>
</li>
<li>
<a href="aboutws.html">About</a>
</li>
I like to use Pretty Print/Fix but cannot do so if it deletes lines of code rather than just tidying things up.
I would appreciate any thoughts on why it is deleting lines of code and any suggestions of what if anything I can do to stop it doing so.
-
- Site Admin
- Posts: 3785
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
Re: Pretty Print/Fix deleting lines of code
Hello,
It looks like it's trying to tidy up too much by dropping empty "span" elements.
In the next v15 update I've added two new options under the "More Options" menu: "Drop Empty Elements" and "Drop Empty Paragraphs"
Both new options are checked by default because that is the HTML Tidy default.
What you want is to set drop-empty-elements to false, which is what the "Drop Empty Elements" option will do if the option is unchecked.
To add the option to a HTML Tidy profile, you'll need to edit a file.
Please see:
https://www.htmlvalidator.com/current/d ... ofiles.htm
Adding "--drop-empty-elements 0" to the args attribute value of the profile(s) you want to change should do it.
Example:
args="--drop-empty-elements 0"
or
args="--indent 1 --indent-spaces 1 --drop-empty-elements 0"
Then save the file and reload the HTML Tidy profiles or just exit and restart CSS HTML Validator and it will re-read the HTML Tidy profiles to updated with the changes.
If you'd like a new build to try with the new options I've just added to make this easier then let me know what edition you are using.
I hope this helps!
It looks like it's trying to tidy up too much by dropping empty "span" elements.
In the next v15 update I've added two new options under the "More Options" menu: "Drop Empty Elements" and "Drop Empty Paragraphs"
Both new options are checked by default because that is the HTML Tidy default.
What you want is to set drop-empty-elements to false, which is what the "Drop Empty Elements" option will do if the option is unchecked.
To add the option to a HTML Tidy profile, you'll need to edit a file.
Please see:
https://www.htmlvalidator.com/current/d ... ofiles.htm
Adding "--drop-empty-elements 0" to the args attribute value of the profile(s) you want to change should do it.
Example:
args="--drop-empty-elements 0"
or
args="--indent 1 --indent-spaces 1 --drop-empty-elements 0"
Then save the file and reload the HTML Tidy profiles or just exit and restart CSS HTML Validator and it will re-read the HTML Tidy profiles to updated with the changes.
If you'd like a new build to try with the new options I've just added to make this easier then let me know what edition you are using.
I hope this helps!
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
-
- Rank I - Novice
- Posts: 14
- Joined: Sat Oct 14, 2006 6:05 am
Re: Pretty Print/Fix deleting lines of code
Hello Albert,
I have tried adding to the tidy xml file
<profile name="nodrop" args="--drop-empty-elements 0"/> and alternatively
<profile name="nodrop" args="--indent 1 --indent-spaces 1 --drop-empty-elements 0"/>
but it still drops the four lines.
I am using Validator Standard vesion 15.02.
Perhaps you could send me a new build with the new options.
Thanks,
Mike
I have tried adding to the tidy xml file
<profile name="nodrop" args="--drop-empty-elements 0"/> and alternatively
<profile name="nodrop" args="--indent 1 --indent-spaces 1 --drop-empty-elements 0"/>
but it still drops the four lines.
I am using Validator Standard vesion 15.02.
Perhaps you could send me a new build with the new options.
Thanks,
Mike
-
- Site Admin
- Posts: 3785
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
Re: Pretty Print/Fix deleting lines of code
Hi Mike,
You will also need to make sure you're using the correct profile by selecting it... in this case it is "nodrop" as specified by your config file.
I've put online a new version of CSS HTML Validator Home which you can download here:
https://www.htmlvalidator.com/download/registered.php
You should get v15.0210 even though the page says v15.0200. Please upgrade to that version and let me know how the new option works. Thanks!
You will also need to make sure you're using the correct profile by selecting it... in this case it is "nodrop" as specified by your config file.
I've put online a new version of CSS HTML Validator Home which you can download here:
https://www.htmlvalidator.com/download/registered.php
You should get v15.0210 even though the page says v15.0200. Please upgrade to that version and let me know how the new option works. Thanks!
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
-
- Rank I - Novice
- Posts: 14
- Joined: Sat Oct 14, 2006 6:05 am
Re: Pretty Print/Fix deleting lines of code
Hi Albert,
I selected the "nodrop" profile when checking out args="--drop-empty-elements 0" and args="--indent 1 --indent-spaces 1 --drop-empty-elements 0".
I have downloaded and installed v15.0200. I have searched Options for the "More Options" menu but cannot seem to find it.
Could you tell me where to look to find the "More Options" menu so that I can deselect "Drop Empty Elements" and "Drop Empty Paragraphs".
Mike
I selected the "nodrop" profile when checking out args="--drop-empty-elements 0" and args="--indent 1 --indent-spaces 1 --drop-empty-elements 0".
I have downloaded and installed v15.0200. I have searched Options for the "More Options" menu but cannot seem to find it.
Could you tell me where to look to find the "More Options" menu so that I can deselect "Drop Empty Elements" and "Drop Empty Paragraphs".
Mike
-
- Site Admin
- Posts: 3785
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
Re: Pretty Print/Fix deleting lines of code
Hi Mike,
You'll need v15.0210, not v15.0200.
Then, go to the Pretty Print/Fix tool (Ctrl+F11). There is a "More Options" menu in the control panel on the right. The option should be in there.
You'll need v15.0210, not v15.0200.
Then, go to the Pretty Print/Fix tool (Ctrl+F11). There is a "More Options" menu in the control panel on the right. The option should be in there.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
-
- Rank I - Novice
- Posts: 14
- Joined: Sat Oct 14, 2006 6:05 am
Re: Pretty Print/Fix deleting lines of code
Hi Albert,
My mistake in typing my last post. The version I have loaded is:
CSE HTML Validator v15.02 – 32-bit
Editor v15.0210 (Std); Engine DLL v15.0210 (Std)
I can't find the Pretty Print/Fix tool in the menus and (Ctrl+F11) doesn't seem to do anything.
Mike
My mistake in typing my last post. The version I have loaded is:
CSE HTML Validator v15.02 – 32-bit
Editor v15.0210 (Std); Engine DLL v15.0210 (Std)
I can't find the Pretty Print/Fix tool in the menus and (Ctrl+F11) doesn't seem to do anything.
Mike
-
- Site Admin
- Posts: 3785
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
Re: Pretty Print/Fix deleting lines of code
Hello,
When you load CSE HTML Validator, there should be a 'Tools' menu in the main menu and in that menu a 'Pretty Print/Fix Dialog' option. Is that not there?
When you load CSE HTML Validator, there should be a 'Tools' menu in the main menu and in that menu a 'Pretty Print/Fix Dialog' option. Is that not there?
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
-
- Rank I - Novice
- Posts: 14
- Joined: Sat Oct 14, 2006 6:05 am
Re: Pretty Print/Fix deleting lines of code
Hi Albert,
Found it. I had not found the the 'Options' menu after selecting that a 'Pretty Print/Fix Dialog' option in the 'Tools' menu.
I have unchecked "Drop Empty Elements" but unfortunately 'Pretty Print/Fix' still deletes the four lines.
Thanks for your help. I appreciat that you have spent time trying to resolve this.
I am happy to try anything else that you might suggest but I can manage by copying the four lines, using Pretty Print/Fix and then reinserting the lines.
Mike
Found it. I had not found the the 'Options' menu after selecting that a 'Pretty Print/Fix Dialog' option in the 'Tools' menu.
I have unchecked "Drop Empty Elements" but unfortunately 'Pretty Print/Fix' still deletes the four lines.
Thanks for your help. I appreciat that you have spent time trying to resolve this.
I am happy to try anything else that you might suggest but I can manage by copying the four lines, using Pretty Print/Fix and then reinserting the lines.
Mike
-
- Site Admin
- Posts: 3785
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
Re: Pretty Print/Fix deleting lines of code
That's strange. Please try copying and pasting the below HTML document into a new document and running the Pretty Print & Fix tool on it.
When I do this with the 'Drop Empty Elements' option unchecked it does not drop the empty elements.
If it doesn't work then please go to 'Options->View Last Tidy Command Line' and tell me what it says.
It may be possible that the edits you made to the profile could also be interfering so make sure you choose the appropriate profile in the tool's control panel (the panel on the right side of the Pretty Print & Fix dialog box).
Code: Select all
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Drop test</title>
<meta name="generator" content="CSE HTML Validator (https://www.htmlvalidator.com/)">
</head>
<body>
<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse"></button>
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
</body>
</html>
If it doesn't work then please go to 'Options->View Last Tidy Command Line' and tell me what it says.
It may be possible that the edits you made to the profile could also be interfering so make sure you choose the appropriate profile in the tool's control panel (the panel on the right side of the Pretty Print & Fix dialog box).
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
-
- Rank I - Novice
- Posts: 14
- Joined: Sat Oct 14, 2006 6:05 am
Re: Pretty Print/Fix deleting lines of code
It is working. It shows the span items in a continuous line with the button class but that's just fine.
<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse"></button> <span class=
"icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
Many thanks for your help in sorting this out and for your useful program that I have used over a number of years for various websites.
Regards,
Mike
<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse"></button> <span class=
"icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
Many thanks for your help in sorting this out and for your useful program that I have used over a number of years for various websites.
Regards,
Mike
-
- Site Admin
- Posts: 3785
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
Re: Pretty Print/Fix deleting lines of code
Mike, great! I'm glad it's working. I think it is putting them on the same line because "span" is an inline element and inline elements are usually inline.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial