![]() |
#1 |
Bright Wing Books
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4
Karma: 919570
Join Date: May 2013
Location: Vancouver, BC
Device: none
|
![]()
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! |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,359
Karma: 203720150
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. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
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 |
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,683
Karma: 24031401
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. Last edited by Doitsu; 04-24-2015 at 05:35 PM. Reason: Updated BS3 to BS4 |
![]() |
![]() |
![]() |
#5 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,313
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
|
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??? ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,313
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
|
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! |
![]() |
![]() |
![]() |
#7 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,683
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
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.) Last edited by Doitsu; 04-24-2015 at 05:08 PM. Reason: Updated BS3 to BS4 |
|
![]() |
![]() |
![]() |
#8 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,313
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
|
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> |
![]() |
![]() |
![]() |
#9 | |
Bright Wing Books
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4
Karma: 919570
Join Date: May 2013
Location: Vancouver, BC
Device: none
|
Quote:
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! |
|
![]() |
![]() |
![]() |
#10 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,683
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
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. |
|
![]() |
![]() |
![]() |
#11 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,359
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
|
|
![]() |
![]() |
![]() |
#12 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
![]() |
#13 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
![]() |
Tags |
numbers, regex, sigil |
|
![]() |
||||
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 |