Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple stylesheets to be specified with --epub-stylesheet #847

Closed
adiabatic opened this issue May 5, 2013 · 6 comments
Closed

Comments

@adiabatic
Copy link

I was hoping to put multiple stylesheets in my ePub file so that I can add in an ePub-only stylesheet to pair with a webpage-only stylesheet, but as it turns out, --epub-stylesheet doesn't quite work like --css. I tried the following, and italics, but not green text:

printf "# Level-One Heading\n\nThis text should be green and italicized.\n" > test.markdown
printf "html { color: green; }" > all.css
printf "html { font-style: italic; }" > ebook.css
pandoc --epub-stylesheet=all.css --epub-stylesheet=ebook.css -o test.epub test.markdown
unzip -d test.d test.epub

Evidently the only thing that goes into the ePub's stylesheet.css is the final file specified. Could this be fixed to allow multiple invocations like --css?

@danmichaelson
Copy link

We do currently need to insert multiple stylesheets in order to support media queries. Example of the second stylesheet:

<link rel="stylesheet" type="text/css" href="iphone.css" media="only screen and (min-device-width : 320px) and (max-device-width : 568px)" />

So that suggests an even further enhancement, to support the media query. iBooks supports this well.

It may be possible to do the media query within the main stylesheet.css– I'll try that. Not quite as nice though.

@danmichaelson
Copy link

All that said..... It could be that the most flexible solution is to allow rewriting the <head> entirely or inserting arbitrary code into it (which I think is already possible?) and then adding arbitrary assets as in the discussion at #1170.

@danmichaelson
Copy link

Confirmed that multiple separate stylesheets are not strictly necessary to accomplish a media query in iBooks.

@jgm jgm changed the title pandoc 1.11.1: only the last --epub-stylesheet specified works Allow multiple stylesheets to be specified with --epub-stylesheet Mar 24, 2014
@elmimmo
Copy link

elmimmo commented Jul 1, 2014

Multiple stylesheets is indeed required for media queries that work in modern ereaders such as iBooks AND remaining compatible with less advanced but very widespread ereaders based on Adobe's RMSDK (99% of e-ink EPUB ereaders I’d say), due to a nasty bug that the latter has of ignoring any whole stylesheet that contains a media query.

A common solution to overcome that is to provide a baseline CSS stylesheet that all ereaders will support, and then a separate additional one with media queries RMSDK will ignore but non RMSDK-based ones will not. That way RMSDK-based ereaders will still apply basic styles even if they ignore the extra ones based on media queries.

Adobe Digital Editions for Mac and Windows are also RMSDK-based, so this bug and its "solution" can be easily tested on a desktop computer too.

If multiple stylesheets support is to be added, please allow doing so in the EPUB metadata block of a pandoc markdown file in addition to the --epub-stylesheet command-line option.

@cortopy
Copy link

cortopy commented Mar 10, 2016

+1

@jgm
Copy link
Owner

jgm commented Feb 26, 2017

Closing in favor of #3472

@jgm jgm closed this as completed Feb 26, 2017
jgm added a commit that referenced this issue Feb 27, 2017
* Removed writerEpubStylesheet in WriterOptions.
* Removed `--epub-stylesheet` option.
* Allow `--css` to be used with epub.
* Allow multiple stylesheets to be used.
* Stylesheets will be taken both from `--css` and from
  the `stylesheet` metadata field (which can contain either
  a file path or a list of them).

Closes #3472, #847.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants