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

Code samples rendering wrong in iBooks #49

Open
chriskrycho opened this issue Mar 27, 2015 · 8 comments
Open

Code samples rendering wrong in iBooks #49

chriskrycho opened this issue Mar 27, 2015 · 8 comments

Comments

@chriskrycho
Copy link

Throughout the ePub version, the monospace font for code samples is rendered incorrectly in iBooks if you choose any reading font besides "Original"—it appears the style sheet isn't overriding some of the classes. See here, for example (using Charter):

epub

As you can see, the bits that are wrapped in syntax highlighting spans (<span class="dt"> etc. in the XHTML source) are falling back to the main typeface instead of the monospace typeface.

@pbrisbin
Copy link
Collaborator

Thanks for reporting this. Strange, it looks like just the type signatures, not the function definitions are rendered in the wrong font.

@trevororeilly do you have any ideas?

@chriskrycho
Copy link
Author

It does kind of look that way, but that's just a function of what gets highlighted; note that the highlighted bits (User, <$>, "name", "email",=, and <*>) all have the same issue—it's not obvious, but you can tell because they're the wrong widths.

@pbrisbin
Copy link
Collaborator

Ah, right I do see that now.

@trevororeilly
Copy link

@pbrisbin Apologies for not getting back sooner, was on client work for most of the day. Let me investigate and see what I can find.

@chriskrycho
Copy link
Author

It looks like iBooks is doing something (Javascripty, maybe) that overrides these classes, possibly because they're span type elements. All the affected elements have custom attributes, __ibooks_font_override="true" and __ibooks_align_override="true"; it appears the former is what's causing the problem, and from what I can tell from reading up a bit, it looks like Apple applies this to all p, div, or span elements. And whatever Apple is doing there is making it so that no override I apply works; I've even tried getting as mind-boggling specific as a selector like code > span.kw[__ibooks_font_override="true"][__ibooks_align_override="true"] (and, for that matter, just setting a style attribute value on it directly in the inspector). Nothing works. 😕

Edit: amusingly, setting a <font> inside those span tags works… but I can't exactly recommend that as a solution. 😉

@chriskrycho
Copy link
Author

Per SO, you can retain styles using iBooks Author, so it may be worth seeing what output that generates for something like this. It'll certainly entail more than just the pandoc output, unfortunately.

@calebhearth
Copy link
Contributor

@pbrisbin @trevororeilly How's this looking?

@pbrisbin
Copy link
Collaborator

pbrisbin commented Oct 8, 2015

When I read via the Kindle app on my phone (Nexus 5), I also see non-monospaced font for the code samples -- it does look correct on my actual Kindle though.

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

No branches or pull requests

4 participants