Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 12-06-2014, 09:24 AM   #1
odedta
Addict
odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.
 
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
Empty space in Paragraph

Sometimes I see writers do this(after conversion to epub):
Code:
<p class="normal">Lorem ipsum dolor sit amet             </p>
A lot of the paragraphs have those silly empty spaces at the end because the writer decided to add them instead of actually styling his/her text in MS Word.

Is there any script / regex to get rid of those?
odedta is offline   Reply With Quote
Old 12-06-2014, 09:27 AM   #2
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 74,027
Karma: 129333114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
All you need do is search for a space in front of the </p> and replace with </p>. And just keep doing that over and over until there is no more space in front of </p>.
JSWolf is offline   Reply With Quote
Advert
Old 12-06-2014, 10:11 AM   #3
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
PeterT's Avatar
 
Posts: 12,171
Karma: 73448616
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Clara, Touch, Tolino EPOS
Why not just search for multiple spaces </p>, in other words [ ]*</p> or even [ ]*</ to look for all occurences of spaces directly before the closing of any tag?
PeterT is offline   Reply With Quote
Old 12-06-2014, 10:45 AM   #4
odedta
Addict
odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.
 
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
Quote:
Originally Posted by PeterT View Post
Why not just search for multiple spaces </p>, in other words [ ]*</p> or even [ ]*</ to look for all occurences of spaces directly before the closing of any tag?
Yeah, I didn't know how spaces are represented in regex, that's why I asked

@JSWolf, nice new profile pic :P

Thanks guys.
odedta is offline   Reply With Quote
Old 12-06-2014, 12:26 PM   #5
signum
Zealot
signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.signum calls his or her ebook reader Vera.
 
Posts: 119
Karma: 64428
Join Date: Aug 2011
Device: none
The only gotcha is that if you use a space character inside square brackets, it has to be the last character.
signum is offline   Reply With Quote
Advert
Old 12-06-2014, 09:19 PM   #6
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,812
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Why not \s{1,}</p>
theducks is offline   Reply With Quote
Old 12-07-2014, 03:32 AM   #7
odedta
Addict
odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.
 
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
Quote:
Originally Posted by theducks View Post
Why not \s{1,}</p>
Okay, now, that requires some explanation
odedta is offline   Reply With Quote
Old 12-07-2014, 05:29 AM   #8
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
Quote:
Originally Posted by odedta View Post
Quote:
Originally Posted by theducks View Post
Why not \s{1,}</p>
Okay, now, that requires some explanation
Why? It's the same as:

Code:
\s+</p>
Doitsu is offline   Reply With Quote
Old 12-07-2014, 06:15 AM   #9
rubeus
Banned
rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.
 
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
None of those catches &nbsp;

Code:
(\s+|(&nbsp;)*)</p>

Last edited by rubeus; 12-07-2014 at 06:16 AM. Reason: mask smileys
rubeus is offline   Reply With Quote
Old 12-27-2014, 07:10 AM   #10
odedta
Addict
odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.odedta read the news today, oh boy.
 
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
Quote:
Originally Posted by Doitsu View Post
Why? It's the same as:

Code:
\s+</p>
This \s{1,} method worked well.
Could you explain the different parts of the that expression?

\s = search for a string
{1,} = placeholder for empty space

Is this correct? could you elaborate on what other searches you could possibly do using these operators/placeholders? e.g. what would {2,} mean? what would \n or \r mean?

Thanks
odedta is offline   Reply With Quote
Old 12-27-2014, 07:21 AM   #11
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
@odeta: For a short Regex summary, see this site. BTW, there are slightly different Regex flavors; Sigil uses PCRE (=Perl-compatible regular Expressions.)

Quote:
Originally Posted by odedta View Post
This \s{1,} method worked well.
Could you explain the different parts of the that expression?
\s = any whitespace character
{1,} = number of preceding characters to be found (in this case at least one)
\n = line-break
\r = carriage-return

I used the + operator, because it's shorthand for {1,}.
Doitsu is offline   Reply With Quote
Old 12-27-2014, 09:18 AM   #12
dgatwood
Curmudgeon
dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.
 
dgatwood's Avatar
 
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
Quote:
Originally Posted by rubeus View Post
None of those catches &nbsp;

Code:
(\s+|(&nbsp;)*)</p>

I think you meant

Code:
(\s|&nbsp;)*</p>
to catch any combination of whitespace or non-breaking space entities in any order.
dgatwood is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Empty line between paragraph in epub on Pocketbook 626 nickie_twisp Calibre 2 11-30-2014 12:59 PM
How detelete empty paragraph? cyttorak Recipes 2 11-27-2014 02:41 AM
Space before paragraph not coming through in epub steve2112 ePub 15 06-06-2012 07:26 AM
Paragraph/line space - "n" added NormalJoe Conversion 6 01-25-2011 11:28 AM
How much empty space I should leave on SD card for 505? alxwang Sony Reader 7 05-13-2009 10:31 PM


All times are GMT -4. The time now is 01:47 AM.


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