06-26-2011, 08:57 PM | #1 |
Wannabe Connoisseur
Posts: 425
Karma: 2516674
Join Date: Apr 2011
Location: Geelong, Australia
Device: Kobo Libra 2, Kobo Aura 2, Sony PRS-T1, Sony PRS-350, Palm TX
|
Tool to centralise css styles?
Hi folks,
I've got an epub that seems to have been created with or via Microsoft Word, and it has no single common CSS stylesheet. I'd like to edit some of the CSS but this is obviously a bit of a pain if you need to do it in a couple of dozen files. In this particular case, all the html files (with the exception of the cover page file) have the same identical 732 lines at the top of each file. Is there a tool available that can take the common styles of multiple html files in an epub and "commonise" them into a single stylesheet and then insert a reference to that stylesheet into each html file? I've also idly wondered about converting the epub to a different format (maybe mobi?) and then back to epub to see if that "fixes" things... Thanks, Simon. |
06-26-2011, 10:45 PM | #2 |
Addict
Posts: 351
Karma: 70000
Join Date: Jul 2010
Location: Australia
Device: ADE, iPad
|
Not sure what you mean here?
If you're talking about renaming styles in a text editor which does "regular expressions" would work Find: <p class="Somestylename">(.*?)</p> Replace <p class="anotherstylename">\1</p> |
Advert | |
|
06-26-2011, 11:06 PM | #3 |
Wannabe Connoisseur
Posts: 425
Karma: 2516674
Join Date: Apr 2011
Location: Geelong, Australia
Device: Kobo Libra 2, Kobo Aura 2, Sony PRS-T1, Sony PRS-350, Palm TX
|
The particular problem I want to start with is that the css in each html file has this sort of thing:
Code:
span.sgc-7 {font-size: 10.0pt;mso-ansi-language:EN-AU} span.sgc-6 {font-size:10.0pt;mso-ansi-language:EN-AU} span.sgc-4 {font-size:16.0pt} span.sgc-3 {font-size:10.0pt} span.sgc-1 {font-size:18.0pt} Code:
span.sgc-7 {font-size: 1em;mso-ansi-language:EN-AU} span.sgc-6 {font-size: 1em;mso-ansi-language:EN-AU} span.sgc-4 {font-size: 1.6em} span.sgc-3 {font-size: 1em} span.sgc-1 {font-size: 1.8em} I can obviously use find/replace on all files in something like Sigil or notepad++. That however got me thinking that there might be a general solution of removing all the duplicate CSS in every html file and putting it in a single stylesheet. Cheers, Simon. |
06-26-2011, 11:35 PM | #4 |
Addict
Posts: 351
Karma: 70000
Join Date: Jul 2010
Location: Australia
Device: ADE, iPad
|
Oh...Ok
I guess you could run a search and replace on joust the Font size line" Search font-size: (.*?) Replace font-size: 1em I don't know of another way, sorry |
06-27-2011, 02:47 AM | #5 |
Media Bloke
Posts: 2,381
Karma: 113956855
Join Date: Sep 2010
Location: NSW - Australia
Device: iOS
|
Lucky they are identical in each file. If I had that problem I would open one of the files and copy the opening CSS and paste it into the find field and write the link to the new CSS file in the replace field in notepad++ You can find and replace in all files in a directory. Brows to the package and replace. Make a new CSS file and update the manifest.
|
Advert | |
|
06-27-2011, 11:59 AM | #6 | |
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:
Open the CSS files in Sigil and copy and paste contents into the master CSS and then use the code view to update the CSS entry in the top of the xhtml files to point to the master. Sigil multiple files replace can be used to do this all at once. You can then remove the uneeded CSS files and then save the ePUB. All the manifest stuff will be fixed automatically. Dale Last edited by DaleDe; 06-27-2011 at 12:02 PM. |
|
06-27-2011, 02:24 PM | #7 |
Connoisseur
Posts: 61
Karma: 12096
Join Date: Sep 2010
Location: Tasmania
Device: Sony PRS 650
|
In Sigil, Code View:
First in one of the html files that has the CSS code, copy the code and paste into notebook. Paste the following at the top of the notebook file: Code:
@namespace h "http://www.w3.org/1999/xhtml"; Right click the Styles panel - Styles folder and select Add Existing items. Browse to and open stylesheet.css you've just created. Back into Code View: Select and copy the style information of the cover page file. Paste into notebook temporarily. Use Find/Replace as follows: Look in 'All HTML files' Check 'Regular expression' and 'All'. Code:
Find: (<style)[^</style>].*(</style>) Repl: <link href="../Styles/stylesheet.css" rel="stylesheet" type="text/css" /> |
07-01-2011, 04:08 AM | #8 | |
Wizard
Posts: 1,196
Karma: 1281258
Join Date: Sep 2009
Device: PRS-505
|
Quote:
This is completely unnecessary, you're merely using it to define a namespace prefix that isn't used and is the same as the default namespace. There's no point adding in code that's nothing more than padding. |
|
Tags |
common css microsoft |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Override ePub CSS with userStyle.css? | barium | Sony Reader Dev Corner | 11 | 07-16-2011 03:25 PM |
CSS styles not displaying in some eReader apps?? | jttraverse | Sigil | 12 | 05-23-2011 05:31 AM |
epub CSS versus "Regular" CSS | konrad | ePub | 4 | 02-18-2011 09:29 AM |
css pseudo elements and adjacent combinators in extra css? | ldolse | Calibre | 2 | 12-21-2010 05:09 PM |
Sigil styles and CSS | View[+]Finder | Sigil | 4 | 05-27-2010 05:39 PM |