Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 05-08-2017, 03:31 AM   #1
hantsaniala
Member
hantsaniala began at the beginning.
 
hantsaniala's Avatar
 
Posts: 16
Karma: 10
Join Date: Dec 2015
Device: sigil
[Plugin] reLink 1.0a : Link unspecified href to the right XHTML file.

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 And it's my first post.
Attached Files
File Type: zip reLink_v1.0.1a.zip (2.0 KB, 355 views)

Last edited by hantsaniala; 05-22-2017 at 05:22 AM. Reason: Updating attachement.
hantsaniala is offline   Reply With Quote
Old 05-08-2017, 04:10 AM   #2
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
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.
Doitsu is offline   Reply With Quote
Advert
Old 05-20-2017, 09:27 AM   #3
samirahmed007
Junior Member
samirahmed007 began at the beginning.
 
Posts: 4
Karma: 10
Join Date: May 2017
Device: kindle
Quote:
Originally Posted by khadafi View Post
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 And it's my first post.

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
samirahmed007 is offline   Reply With Quote
Old 05-20-2017, 10:11 AM   #4
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by samirahmed007 View Post
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

Last edited by DiapDealer; 05-20-2017 at 10:21 AM.
DiapDealer is online now   Reply With Quote
Old 05-22-2017, 05:21 AM   #5
hantsaniala
Member
hantsaniala began at the beginning.
 
hantsaniala's Avatar
 
Posts: 16
Karma: 10
Join Date: Dec 2015
Device: sigil
I've updated the pulgin as Doitsu and DiapDealer said.

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 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.
Attached Files
File Type: zip reLink_v1.0.1a.zip (2.0 KB, 355 views)
hantsaniala is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
table of content file link not add in toc.ncx file bhambhu Conversion 0 01-14-2016 01:40 AM
XHTML file limit? BobK99 Sigil 4 03-08-2013 05:38 AM
How to link to a XHTML Table in a epub. ebookn00b ePub 5 06-05-2012 12:35 PM
ncx file to html/xhtml file javochase Conversion 1 06-23-2011 06:57 PM
xhtml file name change bobcdy Sigil 11 10-23-2010 12:05 AM


All times are GMT -4. The time now is 09:56 PM.


MobileRead.com is a privately owned, operated and funded community.