View Single Post
Old 03-26-2013, 02:38 PM   #39
meme
Sigil developer
meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.
 
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
Yes - its important to remember that it is called "Pretty Print Tidy" and "HTML Tidy" - they are both using Tidy.

In the current version, the options are slightly different than they used to be, and there is more flexibility with what you do. But there are also some additional checks to make you aware of when there might be issues.

HTML Tidy should probably be ignored by most people. There are some rare use cases for it, but in general, just forget about it.

So Pretty Print Tidy should usually be checked in Preferences->Clean Source.

So what does Pretty Print Tidy do? 1) It converts your HTML to valid HTML if it isn't already ok - this means it closes end tags, but it can also remove some tags and content if its really messed up. 2) It indents and modifies the layout of the code so it looks nice. Note that it is the 'making the code valid' that can cause problems. The prettifying part just changes the layout (and of course can only run on valid code). So if your code is valid, pretty printing it won't cause it any harm.

Now Pretty Print Tidy won't run automatically unless you tell it to - by checking the Open and Save checkboxes.

Open

When checked this means that Pretty Print Tidy is run when you open the EPUB, or when you open the page after using Book View. If an EPUB is damaged before you open it and this option is set - a dialog will actually pop up telling you its invalid and asking if you want to open it as is, or make it valid code. If you tell it not to clean, then the code is left as is for the particular file that is damaged. Other files will be pretty printed and have their links updated if necessary, etc.

If you uncheck the option, then the code is loaded as is, and you have the option to correct errors manually.

Save

When checked this means Pretty Print Tidy is run when you save the EPUB. If there are invalid HTML files you are given a warning and asked if you want to clean them. If you decline, the files are saved as is.

If unchecked then the files are saved as is with only a status bar message telling you if your files are valid or not.


So what option should you be using? Well, in most cases the default (Open/Save and Pretty Print Tidy checked) is fine. If you actually have invalid HTML, then a dialog will pop up to tell you and you can skip the automatic fixing of the code, still save the file, and then go look for the invalid code to fix it.

You can of course use right-click in Code View to manually run the Reformat HTML code on one or all files instead of using Save to automatically force it to Pretty Print (especially for Replace Alls).

But how you use it is up to you and what you are working on. If you want complete control - uncheck Open/Save cleaning. But remember your files won't be pretty printed (which some people want) and you will not be warned about invalid HTML when you save (except the status bar message), although a Validation will point out issues. And if you open an invalid EPUB without cleaning, some files might not have their internal links updated (which only applies to files not created in Sigil) - and in fact many file floating around won't open without cleaning due to missing header information, etc. This usually isn't an issue if you created the file.
meme is offline   Reply With Quote