![]() |
#1 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 355
Karma: 65460
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:
Last edited by ElMiko; 12-23-2011 at 08:54 AM. |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,344
Karma: 203719646
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?
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
♫
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 661
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. |
![]() |
![]() |
![]() |
#4 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,889
Karma: 59840450
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+ I stop there and leave the units alone 0em is valid ![]() you might need to do tricks for decimal points (\.* ) Last edited by Jellby; 12-23-2011 at 10:44 AM. Reason: fixed markup |
![]() |
![]() |
![]() |
#5 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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:
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,889
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
|
![]() |
![]() |
![]() |
#7 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
|
![]() |
![]() |
![]() |
#8 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 355
Karma: 65460
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. |
![]() |
![]() |
![]() |
#9 |
Nameless Being
|
Don't use calibre to create the mess and you won't need to replace so many instances.
|
![]() |
![]() |
#10 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 355
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
@shall1028 - I don't really have much in the way of other options for conversion...
|
![]() |
![]() |
![]() |
#11 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
|
![]() |
![]() |
![]() |
#12 |
Bookmaker & Cat Slave
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,503
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
|
![]() |
![]() |
![]() |
#13 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 355
Karma: 65460
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.
|
![]() |
![]() |
![]() |
|
![]() |
||||
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 |