Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 06-26-2011, 08:57 PM   #1
snarkophilus
Wannabe Connoisseur
snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.
 
Posts: 248
Karma: 1009530
Join Date: Apr 2011
Location: Geelong, Australia
Device: Sony PRS-T1, Sony PRS-350, Palm TX
Question 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.
snarkophilus is offline   Reply With Quote
Advert
Old 06-26-2011, 10:45 PM   #2
Adjust
Addict
Adjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel is
 
Adjust's Avatar
 
Posts: 351
Karma: 70000
Join Date: Jul 2010
Location: Australia
Device: ADE, iPad
Quote:
Originally Posted by snarkophilus View Post
have the same identical 732 lines at the top of each file.
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>
Adjust is offline   Reply With Quote
Old 06-26-2011, 11:06 PM   #3
snarkophilus
Wannabe Connoisseur
snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.
 
Posts: 248
Karma: 1009530
Join Date: Apr 2011
Location: Geelong, Australia
Device: Sony PRS-T1, Sony PRS-350, Palm TX
Quote:
Originally Posted by Adjust View Post
Not sure what you mean here?
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}
and on my Sony Reader I get one font size regardless of the zoom level. I'm assuming that if I change the above to:

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}
or something similar I'll then get something that plays happier with my Sony.

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.
snarkophilus is offline   Reply With Quote
Old 06-26-2011, 11:35 PM   #4
Adjust
Addict
Adjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel isAdjust really knows where his or her towel is
 
Adjust's Avatar
 
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
Adjust is offline   Reply With Quote
Old 06-27-2011, 02:47 AM   #5
wannabee
Media Bloke
wannabee ought to be getting tired of karma fortunes by now.wannabee ought to be getting tired of karma fortunes by now.wannabee ought to be getting tired of karma fortunes by now.wannabee ought to be getting tired of karma fortunes by now.wannabee ought to be getting tired of karma fortunes by now.wannabee ought to be getting tired of karma fortunes by now.wannabee ought to be getting tired of karma fortunes by now.wannabee ought to be getting tired of karma fortunes by now.wannabee ought to be getting tired of karma fortunes by now.wannabee ought to be getting tired of karma fortunes by now.wannabee ought to be getting tired of karma fortunes by now.
 
Posts: 2,380
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.
wannabee is offline   Reply With Quote
Advert
Old 06-27-2011, 11:59 AM   #6
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: 10,697
Karma: 11050000
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2
Quote:
Originally Posted by wannabee View Post
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.
Or if you do the same thing in Sigil itself you can avoid some work. The SGC entries are a giveaway that these were done in Sigil.

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.
DaleDe is offline   Reply With Quote
Old 06-27-2011, 02:24 PM   #7
Faster
Connoisseur
Faster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of light
 
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";
Save the file as stylesheet.css.

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" />
Finally replace the original CSS into the cover page html.
Faster is offline   Reply With Quote
Old 07-01-2011, 04:08 AM   #8
charleski
Wizard
charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.
 
Posts: 1,196
Karma: 1281258
Join Date: Sep 2009
Device: PRS-505
Quote:
Originally Posted by Faster View Post
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";
Why????
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.
charleski is offline   Reply With Quote
Reply

Tags
common css microsoft

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 07:53 AM.


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