Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 12-23-2011, 08:51 AM   #1
ElMiko
Addict
ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.
 
ElMiko's Avatar
 
Posts: 320
Karma: 56788
Join Date: Jun 2011
Device: Kindle
Question: Find/Replace in css stylesheet

I'm trying to replace all margin values with 0. Is there any way to do this? I keep getting screwed up by the fact that the strings don't end consistently: sometimes the end in ";" (easy enough to search for and replace), but sometimes the string ends in "[\s]" or "}". One solution I considered would be to replace all numbers following the colon ("margin([^:]*): [0-9]+") with a zero ("margin\1: 0"), but the search gets hung up by the decimal point.

What am I doing wrong... besides everything?

Spoiler:

.calibre {
display: block;
font-size: 1em;
line-height: 1.2;
margin-bottom: 0;
margin-left: 5pt;
margin-right: 5pt;
margin-top: 0;
padding-left: 0;
padding-right: 0
}
.calibre1 {
display: block;
text-align: center
}
.calibre2 {
display: block;
font-size: 1.5em;
font-weight: bold;
line-height: 1.2;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
margin-top: 0.67em
}
.calibre3 {
display: block;
font-size: 1.375em;
font-weight: bold;
line-height: 1.2;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
margin-top: 0.83em
}
.calibre4 {
border: 1px inset;
color: gray;
display: block;
height: 2px;
margin-bottom: 0;
margin-left: auto;
margin-right: auto;
margin-top: 0.5em
}
.calibre5 {
display: block;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
margin-top: 1em
}
.calibre6 {
font-style: italic
}
.calibre7 {
display: block;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
margin-top: 1em;
text-align: right
}

Last edited by ElMiko; 12-23-2011 at 08:54 AM.
ElMiko is offline   Reply With Quote
Old 12-23-2011, 09:48 AM   #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
Is your stylesheet really massive enough that you can't easily step through it one instance at a time and verify each replacement?
DiapDealer is online now   Reply With Quote
Old 12-23-2011, 09:50 AM   #3
WS64
WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.
 
WS64's Avatar
 
Posts: 660
Karma: 506380
Join Date: Aug 2010
Location: Germany
Device: Kobo Aura / PB Lux 2 / Bookeen Frontlight / Kobo Mini / Nook Color
Probably much too complicated, but seems to work (in 0.4.903):
F: margin([-a-z]*:)?([^;^\n^}]*)([;\n}])
R: margin\1 0\3

Last edited by WS64; 12-23-2011 at 09:53 AM.
WS64 is offline   Reply With Quote
Old 12-23-2011, 09:53 AM   #4
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,782
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Margin can take many forms.
margin, margin-top, margin-bottom...

(not tested)
Code:
margin([\-.+])\:\s*\d+
what this is intended to find is all variants of margin followed by a colon followed by digits
I stop there and leave the units alone 0em is valid , so KISS

you might need to do tricks for decimal points (\.* )

Last edited by Jellby; 12-23-2011 at 10:44 AM. Reason: fixed markup
theducks is online now   Reply With Quote
Old 12-23-2011, 01:57 PM   #5
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
Quote:
Originally Posted by theducks View Post
Margin can take many forms.
margin, margin-top, margin-bottom...

(not tested)
Code:
margin([\-.+])\:\s*\d+
what this is intended to find is all variants of margin followed by a colon followed by digits
I stop there and leave the units alone 0em is valid , so KISS

you might need to do tricks for decimal points (\.* )
Actually 0 should not have any units.
DaleDe is offline   Reply With Quote
Old 12-23-2011, 02: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,782
Karma: 54830978
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 DaleDe View Post
Actually 0 should not have any units.
Interesting
I see it all the time: 0em, 0%, 0pt
flightcrew does not gripe
theducks is online now   Reply With Quote
Old 12-23-2011, 02:23 PM   #7
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,515
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by DaleDe View Post
Actually 0 should not have any units.
It need not have units, but it may.
Jellby is offline   Reply With Quote
Old 12-23-2011, 03:39 PM   #8
ElMiko
Addict
ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.
 
ElMiko's Avatar
 
Posts: 320
Karma: 56788
Join Date: Jun 2011
Device: Kindle
@ WS46 - Thanks so much! It does work, so I went through and deconstructed it through whole bunch of trial and to figure out why (thank you also for introducing me to the "\n" character... I'm sure that'll come in handy in the future!).

@theducks - That one didn't match anything, but maybe I was implementing it incorrectly. Thanks for giving it a shot, though.

@DiapDealer: Is this a real question? Just for fun, time yourself on how long it takes for you to manually replace all the margin values in the very small sample I gave you. And then multiply that by 800.... or don't! Multiply it by one! Why wouldn't you want to do something more efficiently if it's at all possible???

Last edited by ElMiko; 12-23-2011 at 04:47 PM.
ElMiko is offline   Reply With Quote
Old 12-23-2011, 04:46 PM   #9
shall1028
Nameless Being
 
Quote:
Originally Posted by ElMiko View Post
@DiapDealer: Is this a real question? Just for fun, time yourself on how long it takes for you to manually replace all the margin values in the very small sample I gave you. And then multiply that by 800.
Don't use calibre to create the mess and you won't need to replace so many instances.
  Reply With Quote
Old 12-23-2011, 05:35 PM   #10
ElMiko
Addict
ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.
 
ElMiko's Avatar
 
Posts: 320
Karma: 56788
Join Date: Jun 2011
Device: Kindle
@shall1028 - I don't really have much in the way of other options for conversion...
ElMiko is offline   Reply With Quote
Old 12-23-2011, 11:19 PM   #11
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
Quote:
Originally Posted by shall1028 View Post
Don't use calibre to create the mess and you won't need to replace so many instances.
or use calibre+ use the Extra CSS preferences to insert your own preferred values. works for me.
cybmole is offline   Reply With Quote
Old 12-24-2011, 03:43 AM   #12
Hitch
Bookmaker & Cat Slave
Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.
 
Hitch's Avatar
 
Posts: 11,460
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
Quote:
Originally Posted by ElMiko View Post
@shall1028 - I don't really have much in the way of other options for conversion...
What are you converting? I'm genuinely curious. I like many things about Calibre, but not the to → ePUB conversion.

Hitch
Hitch is offline   Reply With Quote
Old 12-25-2011, 06:29 AM   #13
ElMiko
Addict
ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.
 
ElMiko's Avatar
 
Posts: 320
Karma: 56788
Join Date: Jun 2011
Device: Kindle
I use calibre to convert between all formats except PDF. For PDF, I use MobiPocket Creator => PRC/MOBI, and then convert that file to EPUB in calibre for copy editing.
ElMiko is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question: find and replace with variables? veezh Recipes 4 12-21-2010 05:23 AM
ePub margins : @page vs stylesheet.css Agama Calibre 1 08-16-2010 04:37 PM
How to maintain a global CSS stylesheet amoroso Sigil 7 07-18-2010 08:37 PM
EPub conversion stylesheet.css problem nycaleksey Calibre 1 03-25-2010 11:42 PM
Where is the stylesheet.css? roger64 Sigil 4 03-23-2010 02:12 PM


All times are GMT -4. The time now is 05:58 PM.


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