MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Plugins (https://www.mobileread.com/forums/forumdisplay.php?f=268)
-   -   [Plugin] reLink : Link unspecified href to the right XHTML file. (https://www.mobileread.com/forums/showthread.php?t=286200)

hantsaniala 05-08-2017 04:31 AM

[Plugin] reLink 1.0a : Link unspecified href to the right XHTML file.
 
1 Attachment(s)
Hello everyone !

I just want to share this plugin "edit" that Just find the XHTML source where the ID is from and replace the link by it's real path.

Eg :
Let's suppose that there is a <p id="myid001">Text</p> in Chapter003.xhtml. So the script find it and convert all link that point to it like this :
Code:

<a href="#myid001">Text</a>
to
Code:

<a href="../Text/Chapter003.xhtml#myid001">
You just must specify an tag id so the script can find the right XHTML file to link it.

EDIT : The plugin assumes that all fragment ids are unique, however, if multiple files contain the same id they'll all be changed to the last file that the id was used in.

You can use the AddIDs by Doitsu to generate ID on your document if there is no ID in.

Requirements :
- Python 3.4
- BeautifulSoup 4
- Sigil 0.8.7

Version : 1.0a

Thanks !

NB : Sorry, my english is poor :o And it's my first post. :D

Doitsu 05-08-2017 05:10 AM

Thanks for contributing this plugin!

I did a quick test and it appears that your plugin will prefix fragment ids with the file name if it can be found in any file.

To make it even more useful, I'd recommend the following:

1. Add the following line to plugin.xml to automatically start the plugin:

Code:

<autostart>true</autostart>
2. Make sure that the message "Mise a jour de <nom de fichier>" is only being displayed if a file was actually updated.

3. The plugin assumes that all fragment ids are unique, however, if multiple files contain the same id they'll all be changed to the last file that the id was used in.

samirahmed007 05-20-2017 10:27 AM

Quote:

Originally Posted by khadafi (Post 3517792)
Hello everyone !

I just want to share this plugin "edit" that Just find the XHTML source where the ID is from and replace the link by it's real path.

Eg :
Let's suppose that there is a <p id="myid001">Text</p> in Chapter003.xhtml. So the script find it and convert all link that point to it like this :
Code:

<a href="#myid001">Text</a>
to
Code:

<a href="../Text/Chapter003.xhtml#myid001">
You just must specify an tag id so the script can find the right XHTML file to link it.

EDIT : The plugin assumes that all fragment ids are unique, however, if multiple files contain the same id they'll all be changed to the last file that the id was used in.

You can use the AddIDs by Doitsu to generate ID on your document if there is no ID in.

Requirements :
- Python 3.4
- BeautifulSoup 4
- Sigil 0.8.7

Version : 1.0a

Thanks !

NB : Sorry, my english is poor :o And it's my first post. :D


not work plugin

Status: failed

Traceback (most recent call last):
File "C:\Program Files\Sigil\plugin_launchers\python\launcher.py", line 134, in launch
target_script = __import__(script_module)
File "C:\Users\com106\AppData\Local\sigil-ebook\sigil\plugins\reLink\plugin.py", line 4, in <module>
from bs4 import BeautifulSoup
ImportError: No module named 'bs4'
Error: No module named 'bs4'


Please suggest

DiapDealer 05-20-2017 11:11 AM

Quote:

Originally Posted by samirahmed007 (Post 3524271)
Please suggest

Either configure Sigil's Plugin manager to use an external Python interpreter with the BeautifulSoup module installed, or convince the plugin author to modify the plugin to use Sigil's own sigil_bs4 module if it's present (sigil_bs4 has been available to Sigil plugins since v0.8.900).

The easiest "fix" would be to change line 4 of plugin.py from:
Code:

from bs4 import BeautifulSoup
to:
Code:

try:
    from sigil_bs4 import BeautifulSoup
except:
    from bs4 import BeautifulSoup


hantsaniala 05-22-2017 06:21 AM

1 Attachment(s)
I've updated the pulgin as Doitsu and DiapDealer said.:2thumbsup

Quote:

not work plugin

Status: failed

Traceback (most recent call last):
File "C:\Program Files\Sigil\plugin_launchers\python\launcher.py", line 134, in launch
target_script = __import__(script_module)
File "C:\Users\com106\AppData\Local\sigil-ebook\sigil\plugins\reLink\plugin.py", line 4, in <module>
from bs4 import BeautifulSoup
ImportError: No module named 'bs4'
Error: No module named 'bs4'


Please suggest
The reason that why I've not noticed that the bs4 is embeded with sigil is that I'm still using Sigil 0.8.7 :o Sorry. And on my computer, bs4 is installed manually by Pypi. So, if this doesn't fix your issue samirahmed007, I suggest you too install bs4 by pip too.

Thanks for the help bro. :thanks:


All times are GMT -4. The time now is 08:54 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.