Skip to content

Epub3 stylesheet link compatible with kindlegen - #5466

Merged
jgm merged 1 commit into
jgm:masterfrom
codingisacopingstrategy:patch-1
May 4, 2019
Merged

jgm merged 1 commit into
jgm:masterfrom
codingisacopingstrategy:patch-1

Conversation

@codingisacopingstrategy

Copy link
Copy Markdown
Contributor

It’s seems that the commit daamien@411119b removes the type="text/css" from both <style> and <rel="stylesheet"> elements in all templates. The rationale for the change is described in #5146 — the elements are optional and can cause HTML validators to complain.

However, this change causes Amazon’s Kindlegen (MAC OSX V2.9 build 1028-0897292) to not pick up the stylesheet when converting a Pandoc generated ePub3 to Mobi. No styles! This is probably a bug on Amazon’s end 😳—Epub3 uses XHTML5, so I think the type attribute should indeed be optional. But it is probably much easier reverting the change at Pandoc’s end, at least for the epub3 template.

One can verify the issue by running the Toy example from Pandoc’s documentation, then running kindlegen mybook.epub and then use kindleunpack.py mybook.mobi. You will find the default pandoc stylesheet not to be included. I could work around the issue by copying pandoc’s epub3 template and adding the attribute to the link tag. I suggest doing this change in the default template.

Whether or not I added the type attribute had no effect on the inline <style> tag which Pandoc places in the header by default—these get added regardless, as separate stylesheets for each page. Since the validators mentioned by @crystalfp in #5146 complained only about the <style> tag, and only in the context of standalone HTML5, it seems save to suggest that adding the type attribute only to the link tag of the epub3 template is not very intrusive.

BTW I wonder why is there an inline style tag in the epub template, these could be part of the default css right?

daamien/pandoc@411119b removes `type="text/css"` from both `<style>` and `<rel="stylesheet">` elements in all templates. However, Amazon’s kindlegen software relies on this attribute on `<link>` elements when detecting stylesheets to include.
@jgm
jgm merged commit 63254ae into jgm:master May 4, 2019
@jgm

jgm commented May 4, 2019

Copy link
Copy Markdown
Owner

Thanks. I think it would make sense to move the inline style to the default stylesheet, too.

jgm added a commit that referenced this pull request May 4, 2019
Those who use a custom CSS stylesheet with EPUB should
add these lines:

```css
code{ white-space: pre-wrap; }
span.smallcaps{ font-variant: small-caps; }
span.underline{ text-decoration: underline; }
q { quotes: "“" "”" "‘" "’"; }
div.column{ display: inline-block; vertical-align: top; width: 50%; }
```

See #5466.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants