View Single Post
Old 03-10-2023, 03:52 PM   #19
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,114
Karma: 1954138
Join Date: Aug 2015
Device: Kindle
The difference between what happens when in editor mode and what happens in Action Chains, is caused by the fact the calibre parses html differently when in editor mode. When in editor mode, calibre will remove some meta tags, that are otherwise not deleted. I don't know the exact reasons for why calibre does this, but I trust that Kovid has done this for good reasons.

It is trivial (in terms of code) to change the plugin to have it perform exactly the same in both modes. But I don't know if this would break some other action or functionality of the plugin. What is not trivial, however, is repeating all the hours of testing that has gone into the plugin to ensure nothing else breaks because of this change, which is not something I am prepared to do.

Anyway, The difference in output is not significant (some meta tags and whitespace) and does not affect the end result. The bottom line is that the html files are beautified and fixed in both modes. If you are bent on having them exactly the same, try the chain attached below, which deletes the culprit meta tags. If you are still not getting the result you want, there is nothing to be done as the changes required for this require huge amount of testing that I am not ready to do.

Spoiler:

*** This part is intended as a documentation of the issue for the future reference. ***

When coding the batch mode of the plugin (which is called from Action Chains and command line), I preferred to to use the same code that calibre's polish functionality uses:

from calibre.ebooks.oeb.polish.container import get_container
container = get_container(book_path)

On contrast, the editor uses a similar function also called get_container() that will additionaly set a variable called tweak_mode as True

from calibre.gui2.tweak_book.boss import get_container
container = get_container(book_path)

As the result of this, html files are parsed differently based on the value of tweak_mode variable. See ContainerBase.parse_xhtml()
Attached Files
File Type: zip Misc Actions.zip (678 Bytes, 134 views)
capink is offline   Reply With Quote