Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 04-10-2021, 11:12 AM   #1
Dekker500
Junior Member
Dekker500 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2019
Device: Web + Pixel(Android)
Custom CSS for TXT -> EPUB conversion

Hi there.
I'm working with numerous documents which, for ease of mass-editing, I'd like to keep in .TXT format.

I have no problems converting them to EPUB format. Everything seems fine.

HOWEVER

I'd like to modify (or even replace) the default CSS that gets embedded into the .EPUB. When I use epub-convert with the --extra-css "blah.css", the contents are added to the "contents.xhtml" in a style block, but no-where else!

Is it possible to embed contents into the "stylesheet.css", or add a new "style.css" to be loaded alongside it, for the entire "book"? Maybe I am missing something in the command line arguments - ideas?

Code:
ebook-convert '.\input.txt' '.\output.epub' --formatting-type markdown --input-encoding UTF-8 --markdown-extensions=footnotes,tables,toc,smarty,nl2br --paragraph-type=single --epub-inline-toc --extra-css "./custom.css"
Dekker500 is offline   Reply With Quote
Old 04-10-2021, 12:55 PM   #2
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: 45,339
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
All style rules are merged and flattened during conversion. Including extra css. If you want to override the styles applied by the markdown input plugin give your custom css higher precedence, the most foolproof way to do that is by using !important in your css properties.
kovidgoyal is offline   Reply With Quote
Advert
Old 04-10-2021, 01:43 PM   #3
Dekker500
Junior Member
Dekker500 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2019
Device: Web + Pixel(Android)
But that is what I don't understand...

I use the ebook-convert with the following arguments:
Code:
ebook-convert '.\Pathless Trail - Manual Edit.txt' .\PT.epub --formatting-type markdown --input-encoding UTF-8 --markdown-extensions=footnotes,tables,toc,smarty,nl2br --extra-css "./custom.css"
and the custom.css is thus:
Code:
.mytitle {
    display: block;
    font-size: 1.41667em;
    font-weight: bold;
    line-height: 1.2;
    margin: 0.83em 0;
	text-align:center
    }
.mysubtitle {
    display: block;
    line-height: 1.2;
    text-align:center;
    color:blue
    }
The conversion seems to happen OK:
Code:
Conversion options changed from defaults:
  extra_css: './custom.css'
  markdown_extensions: 'footnotes,tables,toc,smarty,nl2br'
  formatting_type: 'markdown'
  input_encoding: 'UTF-8'
...
but when I explode the .epub file I can find no instance of "mytitle". Where should it be located in the final epub file?
Dekker500 is offline   Reply With Quote
Old 04-10-2021, 10:23 PM   #4
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: 45,339
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
class names are not guaranteed to be preserved by coversion. Only final styles. Look for the styles.
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
TXT to EPUB conversion issue rockeh Conversion 2 03-18-2011 10:50 AM
Preserving <br /> on epub -> txt conversion billingd Calibre 1 08-11-2010 06:24 AM
ePub with custom .css on a 505 dicknskip Sony Reader Dev Corner 3 06-09-2010 11:34 PM
Conversion: EPUB to TXT Starson17 Calibre 11 05-29-2010 12:31 PM
ePub conversion: override existing css with a custom one sbin Calibre 1 01-09-2010 04:03 AM


All times are GMT -4. The time now is 04:43 PM.


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