Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 03-27-2015, 08:27 PM   #1
hikerguy
Member
hikerguy began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Mar 2015
Device: Kindle
Help with stylesheets in Calibre

I'm still learning Calibre and have very minimal knowledge of stylesheets. My take on css styles is that they kind of work like Word's Styles. With Word's Styles, you assign attributes (like Heading1, Heading2 etc.) and any text that has, say, Heading1 applied to it can be changed "en masse" by changing the Heading1 attributes. Am I somewhat close on this?

My issue right now is I'm cleaning up a lot of the "garbage" that Calibre brings into the book when it's first converted for editing (e.g. <p class="xxxxx" </p>.

I noticed during the course of my cleanup that I seemed to have blown out all of the info in the stylesheet.css. I tried adding one piece of info to it as a test. So, here's what's in the titlpage.xhtml file:

====================

<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<meta name="calibre:cover" content="true"/>
<title>Cover</title>
@page {
padding: 0;
margin: 0;
}
body {
text-align: center;
padding: 0;
margin: 0;
<link rel="stylesheet" href="stylesheet.css">
</style>
</head>

<body>

<div>

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" height="100%" viewBox="0 0 1200 1600" preserveAspectRatio="none">
<image width="1200" height="1600" xlink:href="cover_image.jpg"/>
</svg>

</div>

</body>

</html>

=====================


As I was playing around, I added the following line to the above:

<link rel="stylesheet" href="stylesheet.css">

I then went into the stylesheet.css and added this line:

p {
color: green;
}


I expected all of my text with the paragraph tag to turn green, but they didn't. What am I doing wrong here?

Ultimately, I want to create a stylesheet so I can tweak the heading, body, paragraph, etc. tags. Can someone help with this, or should I break down and learn HTML before I attempt to edit the html? I don't need to make major changes, so I'm hoping I can just get by with minimal html/css knowledge. I can look at basic html info and pretty figure out what's going on. CSS is new to me though.

Thanks,

Andy
hikerguy is offline   Reply With Quote
Old 03-27-2015, 08:37 PM   #2
hikerguy
Member
hikerguy began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Mar 2015
Device: Kindle
I was just tinkering some more and noticed that if I put the following just before the <body> tag of each file that I can control the font color:

<style>
p {color:green}
</style>

<body>


I know there must be a way to put this and other info I want used throughout all of the files created by Calibre into a stylesheet, then somehow reference that style sheet. And I'm guessing there must be some way to make this a global thing without having to reference the stylesheet in every file. So, that's what I really need help with I guess.
hikerguy is offline   Reply With Quote
Old 03-27-2015, 10:14 PM   #3
Section8
Addict
Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.
 
Section8's Avatar
 
Posts: 254
Karma: 2092424
Join Date: Oct 2011
Location: Arlington, TX
Device: Kindle PW4, Moon+ Reader on a cheap Android tablet
To link text file(s) to a stylesheet in the editor, select the ones you want to link in the Files Browser, right-click, and choose "Link stylesheets".
Section8 is offline   Reply With Quote
Old 03-28-2015, 08:26 AM   #4
hikerguy
Member
hikerguy began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Mar 2015
Device: Kindle
Section8,

Thank you VERY much!! That was a big help. The more I use Calibre, the more I like it. Pretty amazing app.

Andy
hikerguy is offline   Reply With Quote
Old 03-29-2015, 08:54 PM   #5
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Note: calibre's Edit E-Book can open DOCX files and convert them into EPUB for editing -- this is to be preferred over converting in the library and then editing the resulting EPUB, since standard conversion will "flatten CSS" and the Open DOCX as new book option in the editor does not.

Flatten CSS is the thing that changes all the style names.
eschwartz is offline   Reply With Quote
Old 03-31-2015, 04:31 PM   #6
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
Small side issue:

When I try to "save as" a file in Libre Office, I have a choice of two different .docx's (both extensions spelled the same): 1) Microsoft Word 2007/2010 XML (.docx) and 2) Open Office XML Text (.docx). Which format should I choose if my intent is to convert it to an epub? What are the relative advantages and disadvantages of each? I'm assuming there's *some* difference between the two.
signum is offline   Reply With Quote
Old 03-31-2015, 07:08 PM   #7
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,565
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by signum View Post
Small side issue:

When I try to "save as" a file in Libre Office, I have a choice of two different .docx's (both extensions spelled the same): 1) Microsoft Word 2007/2010 XML (.docx) and 2) Open Office XML Text (.docx). Which format should I choose if my intent is to convert it to an epub? What are the relative advantages and disadvantages of each? I'm assuming there's *some* difference between the two.
Word 2007 & 2010 do not conform 100% to the ECMA Open Office XML standard (even though MS wrote the draft), see Office Open XML

I doubt that the differences are very significant, for what its worth I convert several Word 2007 DOCX's every day - albeit most are simple. So, I'd go with the 2007/2010 format because I know it works.

If you're inclined, then save both, unzip the two DOCX files, and then do a file compare on the contents with something like WinDiff or Beyond Compare.

Kovid is the only person who can give a definitive answer on what calibre handles best.

BR

Last edited by BetterRed; 03-31-2015 at 07:14 PM.
BetterRed is offline   Reply With Quote
Old 03-31-2015, 07:40 PM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,850
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I have no idea, I developed calibre's docx engine from reading the spec and looking at docx files created by Word 2007. I've never really investigated *Office's docx output.
kovidgoyal is online now   Reply With Quote
Old 04-01-2015, 02:30 AM   #9
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
Thank you both for your replies. Since the docx engine was developed from Word 2007 specs and examples, looks to me like that's my best choice when using Libre Office.
signum is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom CSS Stylesheets for Calibre's Viewer Ralob Viewer 373 08-21-2023 03:24 PM
Stylesheets Phylis Sophical Sigil 10 10-28-2014 03:56 PM
error in linking stylesheets eschwartz Editor 3 01-09-2014 02:25 AM
Validate Stylesheets opens with ADE Moonraker Sigil 3 11-05-2012 09:56 AM
Alternate stylesheets Jellby ePub 1 08-19-2011 06:44 PM


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


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