![]() |
#541 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Aug 2024
Device: Sigil
|
Plugin code needs review/corrections
The python code in the attached plugin is based on input from Chat GPT (unfortunately I am not a developer myself). It needs review/corrections, as it does not process properly. Is there anyone willing to help me with this?
The plugin is supposed to create a table of contents in the <nav> section of every html file. This TOC shall include references/hyperlinks to all H1, H2 and H3 headings of the current page itself and all other pages that have the first 11 characters of the file name in common (this identifies these files as part of the same main chapter). Any advise is very much appreciated. |
![]() |
![]() |
![]() |
#542 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,805
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Just merge the html files so that one chapter is equivalent to one file. Let Sigil generate the nav using its tools.
What is the whole point for the tool you requested? What are you trying to achieve and why? If this is for generating epubs, it seems strange to merge a nav into every html file? Last edited by KevinH; 09-28-2024 at 02:13 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#543 | |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,377
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
Chapter 42 Section 01 Subsection 01-01 Subsection 01-02 ... Section 02 Subsection 02-01 Subsection 02-02 ... |
|
![]() |
![]() |
![]() |
#544 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,355
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
A pop-up ToC would definitely be more effective. Do all readers/devices support one now??
I wonder if the OP is simply trying to replicate old style web books with the last/first/next links?? |
![]() |
![]() |
![]() |
#545 | |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,377
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
That was what their original request sounded like. The mini-ToC was a later request. For me, neither request makes much sense. On my Kobo ereaders, I tap in the middle of the screen and can use the arrows on the position slider to jump forward/back chapters or hit the ToC to bring up the full ToC. The original message was a bit confusing since the OP seemed to want the backward/forward arrows on each page not just at the start of a chapter. |
|
![]() |
![]() |
Advert | |
|
![]() |
#546 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Aug 2024
Device: Sigil
|
Purpose of the plugin
Thank you for all replies! I understand that this seems a bit strange. But the html produced by this plugin is not supposesd to be used with an ebook reader, but will be exported as pure html to be used with a webbrowser. Therefore, the navigation tools of ebook readers are not available. In the html version there will be a button that makes the TOC slide in or out as the user requests. So it will work similar to the TOC popup in an ebook reader.
|
![]() |
![]() |
![]() |
#547 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,377
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Sigil is not a (X)HTML editor. It is intended for editing ePub files which use a limited subset of HTML/CSS. While quite a bit of HTML/CSS works in ePub, there is a fair bit that does not.
You might be able to take a look at the code used and modify it to meet your needs. Looking at Boundary from Baen's Free Library, it looks to be a fairly simple task to add back/next/Toc to an HTML file. I've attached the free library version of Boundary. |
![]() |
![]() |
![]() |
#548 |
Connoisseur
![]() Posts: 77
Karma: 10
Join Date: Jul 2023
Device: none
|
Python plugin launcher?
How difficult would it be to write a python program that would load an epub using ebooklib or similar, create a bk class, and run the plugin? This would be very useful for debugging.
|
![]() |
![]() |
![]() |
#549 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,805
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Just have the plugin always return -1 to indicate an error so that you get the full debug output.
You could write an equivalent to plugin runner to unzip an epub, parse its opf and set up the plugin environment and run the wrapper/launcher. But as I said, just return -1 so any debug output is copied to Sigil's Plugin Runner console. |
![]() |
![]() |
![]() |
#550 |
Connoisseur
![]() Posts: 77
Karma: 10
Join Date: Jul 2023
Device: none
|
Launcher: missing or incorrect paths passed in
I was testing my plugin and added it without deleting it first and when I started it got Launcher: missing or incorrect paths passed in. I then deleted it and reloaded it and it worked fine (or at least it loaded).
|
![]() |
![]() |
![]() |
#551 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,805
Karma: 6000000
Join Date: Nov 2009
Device: many
|
The plugin runner dialog and launcher does a sanity check for all paths passed in and will refuse to launch if anything is incorrect, doesn't exist, can not be read, etc
Editing directly in the plugin folder can result in temporary issues that trigger this. These issues generally do not happen when plugins are zipped up and properly installed. Last edited by KevinH; 12-21-2024 at 09:59 PM. |
![]() |
![]() |
![]() |
#552 | |
Connoisseur
![]() Posts: 77
Karma: 10
Join Date: Jul 2023
Device: none
|
Quote:
|
|
![]() |
![]() |
![]() |
#553 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,805
Karma: 6000000
Join Date: Nov 2009
Device: many
|
No ideas here at all. On macOS, I always directly edit the plugin.py (or whatever py file I am debugging) inside my local Library/Application Support/sigil-ebook/sigil/plugins/MYPLUGINFOLDER/ and save it.
I just make sure to always close completely out of the Sigil Plugin Runner dialog first before editing anything. I have never needed to change versions in plugin.xml file or reinstall. I keep Sigil open and running with a test epub while doing this. I can repeatedly launch the plugin and get my output in the Sigil Plugin Runner console (as long as I change plugin.py to return a -1 indicating error always until fully debugged). So very fast: "run - see output or errors - modify - run" cycles are possible. Last edited by KevinH; 12-22-2024 at 02:44 PM. |
![]() |
![]() |
![]() |
#554 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,605
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
My experience has been much the same as Kevin's when editing/debugging plugins on Linux or Windows. I don't think I've ever had to uninstall/reinstall to get them to work.
If you're launching the plugins via toolbar shortcuts, you might try launching them via the plugin menu and see if that makes a difference. If your plugin is set to manually start (from the Plugin Runner), then you definitely don't want to make changes to plugin.py with the Plugin Runner already open, and then press start. You also might run into permissions errors (which can trigger the errors your getting) if you're keeping the plugin's Python files open in an editor while trying to run the plugin. Last edited by DiapDealer; 12-22-2024 at 02:08 PM. |
![]() |
![]() |
![]() |
#555 | |
Connoisseur
![]() Posts: 77
Karma: 10
Join Date: Jul 2023
Device: none
|
Quote:
I much prefer not going through a build cycle to find a syntax error, or stepping through my code rather than putting in print statements to find a logic error. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Loading Plugin in development | Sladd | Development | 6 | 06-17-2014 06:57 PM |
Question for plugin development gurus | DiapDealer | Plugins | 2 | 02-04-2012 11:33 PM |
DR800 Plugin development for DR800/DR1000 | yuri_b | iRex Developer's Corner | 0 | 09-18-2010 09:46 AM |
Device plugin development | reader42 | Plugins | 10 | 03-29-2010 12:39 PM |
Calibre plugin development - Newbie problems | minstrel | Plugins | 5 | 04-12-2009 12:44 PM |