Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 09-08-2013, 07:03 AM   #286
BobC
Guru
BobC ought to be getting tired of karma fortunes by now.BobC ought to be getting tired of karma fortunes by now.BobC ought to be getting tired of karma fortunes by now.BobC ought to be getting tired of karma fortunes by now.BobC ought to be getting tired of karma fortunes by now.BobC ought to be getting tired of karma fortunes by now.BobC ought to be getting tired of karma fortunes by now.BobC ought to be getting tired of karma fortunes by now.BobC ought to be getting tired of karma fortunes by now.BobC ought to be getting tired of karma fortunes by now.BobC ought to be getting tired of karma fortunes by now.
 
Posts: 691
Karma: 3026110
Join Date: Dec 2008
Location: Lancashire, U.K.
Device: BeBook 1, BeBook Pure, Kobo Glo, (and HD),Energy Sistem EReader Pro +
Quote:
You can search for the footnote number with \[(\d+)\] and the footnote id with id(\d+) and then combine both.
Thanks, the searching isn't difficult - it's the arithmetic transformation that I haven't been able to work out.

BobC
BobC is offline   Reply With Quote
Old 09-08-2013, 07:34 AM   #287
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,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by BobC View Post
Thanks, the searching isn't difficult - it's the arithmetic transformation that I haven't been able to work out.
AFAIK, you cannot do arithmetic transformations with regular expressions at all (other than adding or removing one or more numerals from an existing number). You'd need a scripting language for it.

If you posted a code snippet of a paragraph with a footnote reference, the actual footnote code and the desired transformation, the regex gurus might come up with a solution.
Doitsu is offline   Reply With Quote
Old 10-10-2013, 03:38 PM   #288
LuCouto
Member
LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.
 
Posts: 18
Karma: 11216
Join Date: Sep 2013
Device: Kindle and iPad Mini 4
Hi there,

I'm looking for a Regex expression in order to automatically generate IDs !

So, I actually have the following code:
Code:
<sup>8</sup>
That must become an ID as:
Code:
<a id="note8">8</a>
Please note that the number must be used twice !

Is there a simple way to do this with Regex ? (I've 1232 IDs to generate!)

TIA,
LuCouto is offline   Reply With Quote
Old 10-10-2013, 03:46 PM   #289
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,659
Karma: 54369090
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by LuCouto View Post
Hi there,

I'm looking for a Regex expression in order to automatically generate IDs !

So, I actually have the following code:
Code:
<sup>8</sup>
That must become an ID as:
Code:
<a id="note8">8</a>
Please note that the number must be used twice !

Is there a simple way to do this with Regex ? (I've 1232 IDs to generate!)

TIA,
you can use the capture replace as many times as you wish
<sup>(\d+)</sup>
Code:
<a id="note\1">\1</a>
theducks is offline   Reply With Quote
Old 10-10-2013, 03:52 PM   #290
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,441
Karma: 192992430
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Spot on, Ducky!

It's not part of the original request, but I would consider adding brackets around the digits to give fat fingers a slightly bigger "tap" zone to aim for.

Code:
<a id="note\1">[\1]</a>
Just a suggestion.
DiapDealer is offline   Reply With Quote
Old 10-10-2013, 04:41 PM   #291
LuCouto
Member
LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.LuCouto can tame squirrels without the assistance of a chair or a whip.
 
Posts: 18
Karma: 11216
Join Date: Sep 2013
Device: Kindle and iPad Mini 4
Wow! That was SUPER fast!!! Thanks a lot theducks and DiapDealer! In two seconds I've made all the IDs!

Just one more question

Is there a way to make a for… to request in order to execute the command, for example, 200 times only ?

Last edited by LuCouto; 10-10-2013 at 04:58 PM.
LuCouto is offline   Reply With Quote
Old 10-10-2013, 06:39 PM   #292
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,659
Karma: 54369090
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by LuCouto View Post
Wow! That was SUPER fast!!! Thanks a lot theducks and DiapDealer! In two seconds I've made all the IDs!

Just one more question

Is there a way to make a for… to request in order to execute the command, for example, 200 times only ?
There is no scripting (for-Next...)

You can set the range to selected files and highlight those files in the book browser. That limits Replace All to those files
theducks is offline   Reply With Quote
Old 10-10-2013, 06:42 PM   #293
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,659
Karma: 54369090
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by DiapDealer View Post
Spot on, Ducky!

It's not part of the original request, but I would consider adding brackets around the digits to give fat fingers a slightly bigger "tap" zone to aim for.

Code:
<a id="note\1">[\1]</a>
Just a suggestion.
I HAVE to use a stylus: Glove size: XL
Did I mention 'I hate touch'. Too Sensitive for my kind of swipe. too tiny a zone for big fingers.

Last edited by theducks; 10-10-2013 at 06:50 PM.
theducks is offline   Reply With Quote
Old 02-25-2014, 04:19 AM   #294
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,607
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Setting up a div container around quotes.

My converter creates paragraphs only, but not div containers.

I have a very long book to deal with, with a lot of quotes, some of them very long. I use two main paragraph styles, "bodytext" (100%) and "quote" with a smaller size.

The problem is that these quotes may include from one to four paragraphs. I would like to neatly separate the quote from the bodytext for readability purposes, but if I do it using only paragraphs, long quotes look weird because the space between paragraphs is too big. Obviously I need to enclose each quote within a div which will take care of the needed whitespace.

Say a div with bottom and top margins of 1em, while the quote paragraphs themselves will have much smaller margins (or not at all).

I can do that manually... or set up a regex. This is the question.
roger64 is offline   Reply With Quote
Old 02-25-2014, 04:40 AM   #295
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,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by roger64 View Post
The problem is that these quotes may include from one to four paragraphs. I would like to neatly separate the quote from the bodytext for readability purposes [...] I can do that manually... or set up a regex. This is the question.
Do the paragraphs with quotes start with guillemets or are otherwise formally different from the paragraphs before or after them (e.g., do they all start with the same word/tag)?

If not, it'd would be extremely difficult to use a regex, because in order to use a regex the text to be found needs to follow a predictable pattern.
Doitsu is offline   Reply With Quote
Old 02-25-2014, 04:47 AM   #296
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,607
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Thanks for your interest

Quote:
Originally Posted by Doitsu View Post
Do the paragraphs with quotes start with guillemets or are otherwise formally different from the paragraphs before or after them (e.g., do they all start with the same word/tag)?

If not, it'd would be extremely difficult to use a regex, because in order to use a regex the text to be found needs to follow a predictable pattern.
They can begin with absolutely anything including [...]

But the predictable pattern is that there can be from one to four successive
Code:
<p class="quote">
to enclose within a div.
These "quote" paragraphs make them stand out from the other bodytext paragraphs where I use only
Code:
<p>
.

Last edited by roger64; 02-25-2014 at 04:53 AM.
roger64 is offline   Reply With Quote
Old 02-25-2014, 06:09 AM   #297
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,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by roger64 View Post
But the predictable pattern is that there can be from one to four successive
Code:
<p class="quote">
to enclose within a div.
I'm petty sure that there's a more elegant solution, but I'd use a simple two step approach in Sigil (I'm not sure if this works with Calibre Editor):

1. Insert opening <div> before first quote paragraph:

Find:<p>(.*?)</p>\s*<p class="quote">
Replace:<p>\1</p>\n<div class="quote">\n<p class="quote">

2. Insert closing </div> after last quote paragraph:

Find:<p class="quote">(.*?)</p>\s*<p>
Replace:<p class="quote">\1</p>\n</div>\n<p>

Obviously this only works if there's at least one non-quote paragraph before the first and after the last quote paragraph.
Doitsu is offline   Reply With Quote
Old 02-25-2014, 08:50 AM   #298
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,607
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Thanks a lot for your kind help which saves me a lot of time.

Yes all the quotes are enclosed withing plain p tags, so this is working.

I had tried to figure out a one step process and miserably failed. Setting into place first all the opening div tags and then the closing div tags is indeed a safe way.

I keep Sigil for regex because I have there all my saved searches. Yours will join the others.
roger64 is offline   Reply With Quote
Old 02-28-2014, 09:00 PM   #299
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,607
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
So I did a practical try with a book including 89 quotes. It worked very well.

On the first run, it produced 87 opening tags and 89 closing tags. This discrepancy triggered a reporting mistake. It was due to the fact that two times I had NOT a plain <p> style before the quote, so, of course, these two times the regex did not create any tag.

It's better to prevent the problem than trying to solve it once it happened. That's why, before performing these two separate regexes, it would have been better for me to ask Sigil to number the occurrences for each of them. If the figures are equal (say 89 all): go for it. If not, look for the explanation.

Last edited by roger64; 02-28-2014 at 09:15 PM.
roger64 is offline   Reply With Quote
Old 02-28-2014, 09:46 PM   #300
DaleDe
Grand Sorcerer
DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.
 
DaleDe's Avatar
 
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
Well that case isn't particularly a good example. When quoting multiple paragraphs it is normal not close the quote until the last paragraph but have open ones at the start of each one.

Dale
DaleDe is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Examples of Subgroups emonti8384 Lounge 32 02-26-2011 06:00 PM
Accessories Pen examples Gunnerp245 enTourage Archive 15 02-21-2011 03:23 PM
Stylesheet examples? Skitzman69 Sigil 15 09-24-2010 08:24 PM
Examples kafkaesque1978 iRiver Story 1 07-26-2010 03:49 PM
Looking for examples of typos in eBooks Tonycole General Discussions 1 05-05-2010 04:23 AM


All times are GMT -4. The time now is 05:13 AM.


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