05-13-2021, 11:06 AM | #16 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Okay, Please give RemoveInLineStyles_v030.zip a try. It is attached to the first post in this thread.
It requires at least Sigil-1.0 to work but should properly handle any epub layout. |
05-28-2021, 05:45 PM | #17 |
Evangelist
Posts: 482
Karma: 2267928
Join Date: Nov 2015
Device: none
|
The new version doesn't seem to work:
Code:
Traceback (most recent call last): File "C:\Programs\Sigil\plugin_launchers\python\launcher.py", line 142, in launch self.exitcode = target_script.run(container) File "C:\Users\xxx\AppData\Local\sigil-ebook\sigil\plugins\RemoveInLineStyles\plugin.py", line 164, in run bk.addbookpath(css_new_filename, css_new_bookpath, cssdata, mime='text/css') File "C:\Programs\Sigil\plugin_launchers\python\bookcontainer.py", line 457, in addbookpath return self._w.addbookpath(uniqueid, bookpath, data, mime) File "C:\Programs\Sigil\plugin_launchers\python\wrapper.py", line 721, in addbookpath with open(filepath, 'wb') as fp: PermissionError: [Errno 13] Permission denied: 'C:\\sgc_styles.css' |
Advert | |
|
05-28-2021, 06:18 PM | #18 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
It should fail given the path is outside the epub: 'C:\\sgc_styles.css'
Are you trying to create the css file outside the epub? Or is this some strange Windows path issue. It worked just fine on macOS when I tried it. Hmmm... Something is very strange. Last edited by KevinH; 05-28-2021 at 06:35 PM. |
05-28-2021, 06:34 PM | #19 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Please try adding an existing css file to your epub just temporarily.
What is its resulting book path (mouse over the added css file in BookBrowser to see its full book path). Try then running the plugin. The plugin should put the file right beside the existing css file you added temporarily? Did it or does the plugin still generate an error? If so move the temporarily added css file into a "Styles" folder and try the plugin once again. What errors does it generate? If you have an epub that you can generate the error with, would you please post it someplace private (unless it is public domain) and pm me (KevinH) here onMobileread with a private link so that I can try to reproduce what settings are causing the plugin to write something to your root directory instead of to your epub plugin output folder. Last edited by KevinH; 05-28-2021 at 06:40 PM. |
05-28-2021, 06:49 PM | #20 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
By any chance is your epub an epub2 with no OEBPS folder and no existing stylesheets?
|
Advert | |
|
05-28-2021, 10:15 PM | #21 |
Evangelist
Posts: 482
Karma: 2267928
Join Date: Nov 2015
Device: none
|
It is added to the root folder. It is a flat EPUB3 file with existing stylesheets.
The generated stylesheet was successfully added after the existing stylesheets were moved into Styles subfolder. |
05-28-2021, 10:23 PM | #22 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
If it has existing stylesheets, are they all stored in the root of the epub? Or are some css stored in a different place?
The addbookpath routine literally prepends the path to the plugin working directory to the file path built from its book path. This simply can not be at the root level of the C drive. As the plugin's work directory is created in temp with a unique path. I will create an epub3 that is flat with no organizing or grouping folders but with a existing css file at the root level of the epub to see if I can recreate what you are seeing. Is there anything else unique about your test epub? |
05-28-2021, 10:33 PM | #23 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Okay, I think I can see how no folder at all could cause an issue for my plugin code but not the exact one you are seeing. But perhaps it is related. So give me a day or two and I will post a revised v031 version for you to try. Hopefully it will prevent the issue you are seeing as well.
|
05-30-2021, 06:29 PM | #24 |
Evangelist
Posts: 482
Karma: 2267928
Join Date: Nov 2015
Device: none
|
That can happen if you append an absolute path starting with \ or /.
|
05-30-2021, 07:19 PM | #25 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
But I prepend a outdir to it. Would you feel comfortable hand editing the plugin.py in a text editor and trying to see if this fixes the issue. If so, here is what I would like you to try if possible:
Near line 70 in plugin.py you will see the following: Code:
css_new_filename = unique_filename('sgc_styles.css', namelist) style_folders = bk.group_to_folders("Styles","") css_new_bookpath = style_folders[0] + "/" + css_new_filename Code:
css_new_filename = unique_filename('sgc_styles.css', namelist) style_folders = bk.group_to_folders("Styles",[""]) css_new_bookpath = css_new_filename if style_folders[0] != "": css_new_bookpath = style_folders[0] + "/" + css_new_filename And notice the test for non-empty default style_folder to prevent starting with "/" in the book path. The spacing for the indent is 4 spaces in case it gets messed up by the post. If you could try that and let me know if it works. If it does I will make an official new release with that change in place. If you do not feel comfortable editing python code, just let me know and I will try to build something for you to test. I have just been so tied up with the new Sigil release. I apologize for the delay. |
05-30-2021, 07:30 PM | #26 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
I made the change just in case. Please give this one a try before I make an official new release.
I have my fingers crossed! [Attachment removed - see the first post in this thread for the plugin zip archive] Last edited by KevinH; 05-31-2021 at 10:08 PM. |
05-31-2021, 10:48 AM | #27 |
Evangelist
Posts: 482
Karma: 2267928
Join Date: Nov 2015
Device: none
|
It seems to work correctly.
|
05-31-2021, 11:30 AM | #28 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Thanks for testing it.
I will make v031 the official release once I get back to my desktop machine. KevinH ps. It is now uploaded to the first post in this thread. Last edited by KevinH; 05-31-2021 at 10:09 PM. |
01-05-2022, 10:01 PM | #29 | |
Evangelist
Posts: 425
Karma: 77256
Join Date: Sep 2011
Device: none
|
Quote:
Perhaps those styles are mentioned as either there is some other way to deal with them, or you might have been planning to treat such someday? I have a Google Books EPUB, available from only there, that may have been made by them. In cases where Google is the sole source and it is not a publisher that decided such, maybe sometimes they are produced from scan, or I do not know. This one exclusively uses either inline, or for most common elements places styles in head > style. 50+ xhtml and not all share all styles; each head > style contains only those used by that file. As such, moving each to an external style sheet would be a bit of effort. I may do such for now, yet if know of an easier way, or you mentioned that you might get around to such someday, I'd know the situation. Possible many such Google sourced EPUBs are as such, so someday useful for others who deal with them, if there isn't yet a nice way. Thanks. Last edited by democrite; 01-05-2022 at 10:44 PM. |
|
01-06-2022, 12:33 PM | #30 |
Sigil Developer
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Your best bet is to write a script that uses a stream editor like sed to extract the style tag from head in each xhtml file and replace it with a link to a new stylesheet you will fill with the extracted styles, one for each xhtml file.
Alternatively, you can readily do this in a plugin since they support a number of parsers including quick parser, gumbo, and bs4. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[FileType Plugin] YVES Bible Plugin | ClashTheBunny | Plugins | 27 | 01-16-2023 01:25 AM |
[GUI Plugin] KindleUnpack - The Plugin | DiapDealer | Plugins | 492 | 10-25-2022 08:13 AM |
Plugin not customizable: Plugin: HTML Output does not need customization | flyingfoxlee | Conversion | 2 | 02-24-2012 02:24 AM |
[GUI Plugin] Plugin Updater **Deprecated** | kiwidude | Plugins | 159 | 06-19-2011 12:27 PM |
New Plugin Type Idea: Library Plugin | cgranade | Plugins | 3 | 09-15-2010 12:11 PM |