03-29-2010, 06:46 AM | #16 |
Connoisseur
Posts: 94
Karma: 538
Join Date: Nov 2009
Device: iPad
|
Would be good if there was a sticky with all your regex, detailing what they exactly do and a simple guide to put them in the right place, something like what they have over at MP3Tag...
Now can someone make one for removing all unwanted white space, I have a few ebooks where every line has a white space beneath it, have tried a few ways of getting rid to make the epub more compact but no joy so far Jay |
03-29-2010, 07:34 PM | #17 |
Wizard
Posts: 1,196
Karma: 1281258
Join Date: Sep 2009
Device: PRS-505
|
|
Advert | |
|
03-30-2010, 06:54 AM | #18 | |
Connoisseur
Posts: 94
Karma: 538
Join Date: Nov 2009
Device: iPad
|
Quote:
I loaded a correct epub in Sigil 0.2, copied the stylesheet.css info to Notepad then did the same with one of my epubs which has the white spaces, compared the info between the two but they both look similar. Could someone post a stylesheet.css of how it should look, then I could learn from that Jay |
|
03-30-2010, 08:37 PM | #19 |
Guru
Posts: 644
Karma: 1242364
Join Date: May 2009
Location: The Right Coast
Device: PC (Calibre), Nexus 7 2013 (Moon+ Pro), HTC HD2/Leo (Freda)
|
Jay,
The amount of white space between paragraphs is generally called "paragraph spacing" or leading. As such it should be handled within the normal text definition of the CSS stylesheet of your ebook. It has nothing to do with RegEx at all. Your ebook should have a stylesheet included within it; alternately it is at the top of any file which contains the body text of the book. If it's an epub it could be in every chapter. I don't know the exact command, but I believe this is one field that allows em, en, px or % measurements (among others) to be used. As such you might have to play with the values provided, changing the numbers enough to cause an obvious change to the text (add 20 to whatever number is there, see what the outcome is, etc). |
03-31-2010, 01:34 AM | #20 |
Zealot
Posts: 147
Karma: 56
Join Date: Dec 2009
Location: Antwerpen
Device: iPhone, Sony PRS-505, EPUBreader
|
|
Advert | |
|
03-31-2010, 07:19 AM | #21 | |
Connoisseur
Posts: 94
Karma: 538
Join Date: Nov 2009
Device: iPad
|
Quote:
This is a epub with a line space under each line, this is the stylesheet.css from Sigil 0.20 @namespace h "http://www.w3.org/1999/xhtml"; .calibre { display: block; font-size: 1em; margin-bottom: 0; margin-left: 5pt; margin-right: 5pt; margin-top: 0; page-break-before: always; text-align: justify } .calibre1 { border-bottom: 0; border-top: 0; display: block; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; text-align: center; text-indent: 1.5em } .calibre2 { height: auto; width: auto } .calibre3 { display: block; font-family: monospace; margin-bottom: 1em; margin-left: 0; margin-right: 0; margin-top: 1em; white-space: pre } a { color: inherit; text-decoration: inherit; cursor: default } a[href] { color: blue; text-decoration: underline; cursor: pointer } This is the code view of the same epub from sigil 0.19 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style type="text/css"> /*<![CDATA[*/ @namespace h "http://www.w3.org/1999/xhtml"; .calibre { display: block; font-size: 1em; margin-bottom: 0; margin-left: 5pt; margin-right: 5pt; margin-top: 0; page-break-before: always; text-align: justify } .calibre1 { border-bottom: 0; border-top: 0; display: block; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; text-align: center; text-indent: 1.5em } .calibre2 { height: auto; width: auto } .calibre3 { display: block; font-family: monospace; margin-bottom: 1em; margin-left: 0; margin-right: 0; margin-top: 1em; white-space: pre } a { color: inherit; text-decoration: inherit; cursor: default } a[href] { color: blue; text-decoration: underline; cursor: pointer } img.sgc-1 {height: 100%} /*SG DO NOT MODIFY. This style is used by Sigil. It will be removed on export along with the "sigilChapterBreak" HR tags. SG*/ hr.sigilChapterBreak { border: none 0; border-top: 3px double #c00; height: 3px; clear: both; } /*]]>*/ </style> </head> <body> <div><img alt="cover" class="sgc-1" src="../images/img0002.jpg" /></div> <div> <hr class="sigilChapterBreak" /> </div> <p class="calibre1"><img class="calibre2" src="../images/img0001.jpg" /></p> <div> <hr class="sigilChapterBreak" /> </div> <pre class="calibre3"> Jay |
|
03-31-2010, 07:59 AM | #22 | |
Zealot
Posts: 147
Karma: 56
Join Date: Dec 2009
Location: Antwerpen
Device: iPhone, Sony PRS-505, EPUBreader
|
Quote:
If this is not enough, change at least the first occurences of Code:
<pre class="calibre3">bla bla </pre> Code:
<p>bla bla </p> If you use "pre" all line breaks of the source code are literally followed. Is that what you want to occur? Last edited by paulpeer; 03-31-2010 at 08:05 AM. Reason: some stuff added |
|
03-31-2010, 08:13 AM | #23 | |
Connoisseur
Posts: 94
Karma: 538
Join Date: Nov 2009
Device: iPad
|
Quote:
Really appreciate your help, Using Sigil 0.19 in split view and did as you say and took out the line "white-space: pre" but nothing changed, still the same... Could I send you the epub to look at in your Sigil Jay |
|
03-31-2010, 08:23 AM | #24 | |
Zealot
Posts: 147
Karma: 56
Join Date: Dec 2009
Location: Antwerpen
Device: iPhone, Sony PRS-505, EPUBreader
|
Quote:
Changing one or two of them is enough. If it works, change all of them. |
|
03-31-2010, 09:36 AM | #25 | |
Connoisseur
Posts: 94
Karma: 538
Join Date: Nov 2009
Device: iPad
|
Quote:
That did the trick, will save that for future use Many thanks for your help Jay |
|
03-31-2010, 10:12 AM | #26 |
Zealot
Posts: 147
Karma: 56
Join Date: Dec 2009
Location: Antwerpen
Device: iPhone, Sony PRS-505, EPUBreader
|
|
01-06-2013, 05:41 AM | #27 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Jan 2013
Device: Pc - Linux - Calibre
|
Hi guys,
I'm desperately looking for a regex which would automatically search in my eBooks' titles the string "2012" (for example) and put it in my pubdate field. And, once this is done, I would also like it to replace some other fields like this, but the pubdate is the hardest for me. Let me show you an example : The pdf file is : TitleOfTheSerie Volume1 Number1 (out of 3) (2012) I would like to use the Search&Replace function of Calibre to extract those informations and put them in the correct place. So : 2012 -> pubdate (I'll use january everytime) TitleOftheSerie -> Serie Number -> Serie[X] Quote:
Search in : title For : ([0-2][0-9][0-9][0-9]) And replace it by : janv. \1 In : pubdate But I get an error : Code:
unknown string format calibre, version 0.9.11 ERREUR : Echec: unknown string format Traceback (most recent call last): File "/usr/lib/calibre/calibre/gui2/dialogs/metadata_bulk.py", line 125, in do_one_safe self.do_one(id) File "/usr/lib/calibre/calibre/gui2/dialogs/metadata_bulk.py", line 290, in do_one self.s_r_func(id) File "/usr/lib/calibre/calibre/gui2/dialogs/metadata_bulk.py", line 851, in do_search_replace setter(id, val, notify=False, commit=False) File "/usr/lib/calibre/calibre/library/database2.py", line 2613, in set_pubdate dt = parse_only_date(dt) File "/usr/lib/calibre/calibre/utils/date.py", line 94, in parse_only_date ans = parse_date(raw, default=default, assume_utc=assume_utc) File "/usr/lib/calibre/calibre/utils/date.py", line 80, in parse_date dt = parse(date_string, default=default, dayfirst=parse_date_day_first) File "/usr/lib/python2.7/dist-packages/dateutil/parser.py", line 697, in parse return DEFAULTPARSER.parse(timestr, **kwargs) File "/usr/lib/python2.7/dist-packages/dateutil/parser.py", line 303, in parse raise ValueError, "unknown string format" ValueError: unknown string format 1-1-\1 01/01/\1 01 janv. \1 but none of them had worked Could you help me? Thanks in advance, Snipe Last edited by snipe2004; 01-06-2013 at 05:45 AM. |
|
01-06-2013, 08:53 AM | #28 |
A Hairy Wizard
Posts: 3,178
Karma: 18843349
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
|
If I understand correctly you are only looking for "2012". If that is so, then there is no need for regex, just a simple search and replace. Try:
Find: 2012 Replace: Janv. 2012 if you are looking for ANY year then you can try this Regex: Find: ([0-9]{4}) Replace: Janv. \1 I'm not sure what flavor of regex Calibre uses. You may have better luck if you check in their forum. This one is for the Sigil software. Last edited by Turtle91; 01-06-2013 at 08:58 AM. |
01-06-2013, 09:57 AM | #29 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Jan 2013
Device: Pc - Linux - Calibre
|
Quote:
Code:
calibre, version 0.9.11 ERREUR : Echec: unknown string format Traceback (most recent call last): File "/usr/lib/calibre/calibre/gui2/dialogs/metadata_bulk.py", line 125, in do_one_safe self.do_one(id) File "/usr/lib/calibre/calibre/gui2/dialogs/metadata_bulk.py", line 290, in do_one self.s_r_func(id) File "/usr/lib/calibre/calibre/gui2/dialogs/metadata_bulk.py", line 851, in do_search_replace setter(id, val, notify=False, commit=False) File "/usr/lib/calibre/calibre/library/database2.py", line 2613, in set_pubdate dt = parse_only_date(dt) File "/usr/lib/calibre/calibre/utils/date.py", line 94, in parse_only_date ans = parse_date(raw, default=default, assume_utc=assume_utc) File "/usr/lib/calibre/calibre/utils/date.py", line 80, in parse_date dt = parse(date_string, default=default, dayfirst=parse_date_day_first) File "/usr/lib/python2.7/dist-packages/dateutil/parser.py", line 697, in parse return DEFAULTPARSER.parse(timestr, **kwargs) File "/usr/lib/python2.7/dist-packages/dateutil/parser.py", line 303, in parse raise ValueError, "unknown string format" ValueError: unknown string format |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
What a regex is | Worldwalker | Calibre | 20 | 05-10-2010 05:51 AM |
using wildcards for conversion ? | Riiyachan | Calibre | 7 | 04-20-2010 10:16 PM |
Help with a regex | A.T.E. | Calibre | 1 | 04-05-2010 07:50 AM |
wildcards in sigil | bobcdy | Sigil | 2 | 12-18-2009 10:19 PM |
Regex help... | Bobthebass | Workshop | 6 | 04-26-2009 03:54 PM |