Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 04-24-2015, 02:02 PM   #1
Bright Wing
Bright Wing Books
Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.
 
Bright Wing's Avatar
 
Posts: 4
Karma: 919570
Join Date: May 2013
Location: Vancouver, BC
Device: none
Post Regex for adding numbers to endnote links in Sigil

Hello all,

I have spent a goodly amount time searching for what I think is a simple solution. So I thought I would crowd source it here:

I need to add the href and id numbers to this string (and 310 like it) to my book using Sigil (0.8.6):

<a id="endnote{INSERT number here}" href="../Text/notes.xhtml#endnotes{INSERT number here}">

What is the Regex for doing so?

Thanks!
Bright Wing is offline   Reply With Quote
Old 04-24-2015, 02:56 PM   #2
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,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
There's no incrementing counter function in Sigil's PCRE regex engine. It has to capture the number from the text it matches before it can be inserted into any replace expression. I don't think regex is going to help you here.

You may need to use something like the regex-function feature of calibre's editor to create a custom python routine to create the numbers to add to matched strings.
DiapDealer is offline   Reply With Quote
Advert
Old 04-24-2015, 03:24 PM   #3
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
calibre's manual has an example for using function mode to auto-number sections, you can adapt it to handle endnotes.

http://manual.calibre-ebook.com/func...ering-sections
eschwartz is offline   Reply With Quote
Old 04-24-2015, 03:32 PM   #4
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,583
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Last year I created a throwaway Sigil incrementation plugin that might do the trick. Since I only used it for 2 books, you might want to thoroughly test it with a backup copy first.

Note that since all Sigil plugins require Python, you'll need to install Python 2.7. I'd recommend installing ActivePython 2.7.8.1. (Do not install the 3.4.1.0 version; it's incompatible with this plugin.)

To install the plugin do the following:

0. Install Python 2.7.
1. Select Plugins > Manage Plugins.
2. Click the Auto button after Python 2.7. (You should see a file path.)
3. Click Add Plugin, select the attached .zip file, click Open and OK.

You can select the plugin via Plugins > Edit > AddIDs > Start.
To process all a tags in the epub simply click OK.
To process only a tags with a specific class, enter class in the Attribute box and the name of the class in the Value box.
Attached Files
File Type: zip AddIDs.zip (144.5 KB, 341 views)

Last edited by Doitsu; 04-24-2015 at 05:35 PM. Reason: Updated BS3 to BS4
Doitsu is offline   Reply With Quote
Old 04-24-2015, 03:38 PM   #5
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Thanks Doitsu! The increment function in Calibre was one of the only things pulling me away from Sigil (not that it worked)...

Question: Is this ONLY for <a> tags - or can I designate any element? ie <h2>Chapter [increment]</h2>

...and while I'm being greedy... does it increment in letters, or roman numerals???
Turtle91 is offline   Reply With Quote
Advert
Old 04-24-2015, 03:43 PM   #6
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Oh...I see....

This is what I got with my test:

<h2 id="1" href="../Text/notes.xhtml#endnotes1">Chapter </h2>
<h2 id="2" href="../Text/notes.xhtml#endnotes2">Chapter </h2>
<h2 id="3" href="../Text/notes.xhtml#endnotes3">Chapter </h2>
<h2 id="4" href="../Text/notes.xhtml#endnotes4">Chapter </h2>
<h2 id="5" href="../Text/notes.xhtml#endnotes5">Chapter </h2>
<h2 id="6" href="../Text/notes.xhtml#endnotes6">Chapter </h2>


definitely geared towards endnotes, but it makes it very easy to have a single search/replace to fix!

Thanks again!
Turtle91 is offline   Reply With Quote
Old 04-24-2015, 03:51 PM   #7
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,583
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by Turtle91 View Post
Thanks Doitsu! The increment function in Calibre was one of the only things pulling me away from Sigil (not that it worked)...

Question: Is this ONLY for <a> tags - or can I designate any element? ie <h2>Chapter [increment]</h2>
The version that I uploaded in the previous post is hard-coded for a tags, however, by deleting one line in the plugin it'll work with all tags because it doesn't add hrefs.

Please use the version that I attached to this post, which you can select via Plugins > Edit > AddIdsAll

(To add incremental ids to headings simply enter the heading tag in the first box, e.g. h1.)
Attached Files
File Type: zip AddIDsAll.zip (146.4 KB, 359 views)

Last edited by Doitsu; 04-24-2015 at 05:08 PM. Reason: Updated BS3 to BS4
Doitsu is offline   Reply With Quote
Old 04-24-2015, 04:05 PM   #8
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Very Nice! Thanks again!

Code:
<h2 id="1">Chapter </h2>
<h2 id="2">Chapter </h2>
<h2 id="3">Chapter </h2>
<h2 id="4">Chapter </h2>
<h2 id="5">Chapter </h2>
<h2 id="6">Chapter </h2>
Turtle91 is offline   Reply With Quote
Old 04-24-2015, 05:19 PM   #9
Bright Wing
Bright Wing Books
Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.Bright Wing ought to be getting tired of karma fortunes by now.
 
Bright Wing's Avatar
 
Posts: 4
Karma: 919570
Join Date: May 2013
Location: Vancouver, BC
Device: none
Quote:
Originally Posted by Doitsu View Post
Last year I created a throwaway Sigil incrementation plugin that might do the trick. Since I only used it for 2 books, you might want to thoroughly test it with a backup copy first.

Note that since all Sigil plugins require Python, you'll need to install Python 2.7. I'd recommend installing ActivePython 2.7.8.1. (Do not install the 3.4.1.0 version; it's incompatible with this plugin.)

To install the plugin do the following:

0. Install Python 2.7.
1. Select Plugins > Manage Plugins.
2. Click the Auto button after Python 2.7. (You should see a file path.)
3. Click Add Plugin, select the attached .zip file, click Open and OK.

You can select the plugin via Plugins > Edit > AddIDs > Start.
To process all a tags in the epub simply click OK.
To process only a tags with a specific class, enter class in the Attribute box and the name of the class in the Value box.
Thank you, Doitsu,

I am thrilled with your plugin suggestion, but when i seek to add the .zip file from your download, it tells me that it is not a valid Sigil plugin, despite installing, as per your instructions exactly, the python file. I am using Sigil .0.8.6 on macbook pro... could that be the problem?

Help!
Bright Wing is offline   Reply With Quote
Old 04-24-2015, 05:47 PM   #10
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,583
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by Bright Wing View Post
I am thrilled with your plugin suggestion, but when i seek to add the .zip file from your download, it tells me that it is not a valid Sigil plugin, despite installing, as per your instructions exactly, the python file
This usually only happens, if you rename the zip file or try to install the unpacked zip file.
I tested it on Linux and Windows machines without any problems.
If you downloaded the zip file under a different name or renamed it afterwards, please rename it back to AddIDs.zip and try to install it again. If it still doesn't work it might be an OSX build issue.

BTW, I uploaded a slightly updated plugin in the meantime that fixes a rare bug with empty titles and adds pretty print output.

P.S. If you still can't get it to work check out the Calibre Editor. Apparently, it can increment ids, but I haven't tested it yet.

Last edited by Doitsu; 04-24-2015 at 05:49 PM.
Doitsu is offline   Reply With Quote
Old 04-24-2015, 05:52 PM   #11
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,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by Bright Wing View Post
Thank you, Doitsu,

I am thrilled with your plugin suggestion, but when i seek to add the .zip file from your download, it tells me that it is not a valid Sigil plugin, despite installing, as per your instructions exactly, the python file. I am using Sigil .0.8.6 on macbook pro... could that be the problem?

Help!
I think I remember Safari automatically unzipping/opening downloaded zip files at some time or another. If that's what's going on, you probably need to figure out how to make it stop doing that. Otherwise, it's probably one of the things Doitsu mentioned.
DiapDealer is offline   Reply With Quote
Old 04-25-2015, 08:18 AM   #12
exaltedwombat
Guru
exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.
 
Posts: 878
Karma: 2457540
Join Date: Nov 2011
Device: none
If you create the text in Word, using its footnote function, you'll find that Calibre will convert the docx to epub very efficiently, with functioning footnote links. You can then move it to Sigil for further work if you wish.
exaltedwombat is offline   Reply With Quote
Old 04-25-2015, 09:06 AM   #13
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
You can also use my Word add-in. It will also convert your notes correctly and you can choose to have them either at the end of a chapter or at the end of the book.
Toxaris is offline   Reply With Quote
Reply

Tags
numbers, regex, sigil


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
? about adding links to blog etc. in Sigil-made ebook Gregg Bell Sigil 5 03-18-2013 07:56 PM
Footnote/Endnote Links Not Working William5 Conversion 1 08-31-2012 06:39 AM
Sequential numbers regex? soparch Sigil 7 10-10-2011 05:51 AM
Will footnote/endnote links work with the Kobo Touch? djloewen Kobo Reader 11 09-03-2011 09:45 AM
RegEx: Removing Page Numbers that have Spaces captainslow Conversion 2 02-27-2011 04:14 PM


All times are GMT -4. The time now is 10:09 AM.


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