-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Syntax highlighting broken in Apple Books v2.4 (1923) #6242
Comments
Can't reproduce this with iBooks 2.2. (Though I do note that the end of the comment disappears -- this is actually due to the size of the enclosing box, and if you highlight the text you can see that it's really there and will scroll. Are you sure that isn't the situation in your case?) |
Also try unzipping the epub (use |
Also I checked produced epub in Calibre and it is ok, so this is most likely a problem of Apple Books or something, but I really need to view my epubs on iOS devices |
Sounds like a problem on Apple's end. Hm. You can experiment with the epub and see if you can fix things by twiddling HTML or CSS -- maybe this would point to a workaround. |
You might report this to apple. The epub, xhtml, and css pass validation tests. I don't see a problem on pandoc's side. |
I just noticed this as well on my own epub. Disabling syntax highlighting means at least the code shows up, though of course without highlighting! No other reader exhibits this issue - tested in Calibre and in various web browsers. I suspect it has something to do with the inline style block used by Pandoc and Apple Book's renderer (which, IDK, what does it use? Safari?). This is not necessarily a Pandoc issue but it's possible it could be mitigated on Pandocs side. |
OK, I have no idea why, but removing the follow CSS rule fixes the issue in Apple Books 2.4/1923: @media screen {
div.sourceCode { overflow: auto; }
} This doesn't really make any sense. I confirmed this by editing the generated CSS in the EPUB archive and just kind of binary searching through the CSS until I removed the rule that caused the problem. |
So, the workaround is to add the following in your EPUB CSS: /* Apple Books 2.4+ doesn't like overflow:auto on syntax highlighting generated by skylighting */
@media screen {
div.sourceCode { overflow: visible !important; }
} |
Yes, I confirm, this fixes the issue, thank you /* Apple Books 2.4+ doesn't like overflow:auto on syntax highlighting generated by skylighting */
@media screen {
div.sourceCode { overflow: visible !important; }
p, span, pre, code, blockquote {
overflow: visible !important;
}
} Or in more general way: /* Apple Books 2.4+ doesn't like overflow:auto on syntax highlighting generated by skylighting */
@media screen {
.sourceCode { overflow: visible !important; }
} Add this to the end of your EPUB CSS file |
nice find! so should just add this to https://github.com/jgm/pandoc/blob/master/data/epub.css ? |
Adding this means that code will overflow the box in all EPUBs, correct? |
Hmmm, maybe I can try overflow:hidden later. |
Have you tried reporting this as a bug to Apple, by the way? It does seem a problem on their end, and it seems a shame to eliminate scrollbars from overflowing code blocks on ALL epubs just because of a problem with a specific version of iBooks. But that might be the thing to do until they fix the issue... |
Overflow hidden does not work. I'll report to Apple. |
I already created a ticket to them 3 weeks ago, but it just disappeared after 3 weeks, maybe such a policy, I don’t know |
I'm also seeing this - I've worked around it by disabling syntax highlighting with |
I also ran into this issue in the wild in my previously-published book. I can confirm that adding the following CSS (suggested by @vlad-goshko) resolved the issue: /* Apple Books 2.4+ doesn't like overflow:auto on syntax highlighting generated by skylighting */
@media screen {
.sourceCode { overflow: visible !important; }
} |
@ageitgey I get code overflowing my listing boxes using that CSS so it doesn't resolve it for me I am afraid. :( |
I ended up doing the following: @media screen {
.sourceCode {
overflow: visible !important;
white-space: pre-wrap !important;
}
} Wrapping was necessary because Books.app would cut off text otherwise. |
Should we change the default CSS to the one @rauschma used? That would change behavior in all readers, not just ibooks. In general I prefer the scrollbar to wrapping, but until ibooks is fixed it might make sense to do something that works for everything. (Or: is there a way to make the CSS rule conditional so it only affects ibooks?) |
This issue is still happening with the updated CSS; I found it was necessary to remove this line to get code blocks to be visible in iBooks: white-space: pre-wrap !important; So the CSS that works for me is: @media screen {
/* Workaround for iBooks issue; see #6242 */
.sourceCode {
overflow: visible !important;
}
}``` |
@bitfield, it should work fine out of the box (without custom css) in the latest pandoc release. |
With pandoc 2.10.1, and the following command line:
and the following CSS: /* This defines styles and classes used in the book */
body {
margin: 5%;
text-align: justify;
font-size: medium;
font-family: SourceSerifPro;
src: url("fonts/SourceSerifPro-Regular.ttf");
}
code {
font-family: monospace;
}
h1 {
text-align: left;
font-family: RobotoSlab;
src: url("fonts/RobotoSlab-VariableFont_wght.ttf");
}
h2 {
text-align: left;
}
h3 {
text-align: left;
}
h4 {
text-align: left;
}
h5 {
text-align: left;
}
h6 {
text-align: left;
}
/* For title, author, and date on the cover page */
h1.title {}
p.author {}
p.date {}
nav#toc ol, nav#landmarks ol {
padding: 0;
margin-left: 1em;
}
nav#toc ol li, nav#landmarks ol li {
list-style-type: none;
margin: 0;
padding: 0;
}
a.footnote-ref {
vertical-align: super;
}
em, em em em, em em em em em {
font-style: italic;
}
em em, em em em em {
font-style: normal;
}
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%;
}
div.hanging-indent {
margin-left: 1.5em;
text-indent: -1.5em;
} the code blocks are not visible in iBooks: With the same pandoc version and command line, if I add the following block of custom CSS: @media screen {
/* Workaround for iBooks issue; see #6242 */
.sourceCode {
overflow: visible !important;
white-space: pre-wrap !important;
}
} the code samples are visible: Here's the relevant Markdown source:
|
I'm delighted to hear it! But you said that you thought the issue should be fixed with the latest pandoc, and I have confirmed that it isn't. You asked for the exact command line, input, and style files I'm using. I've supplied them. If I can supply any further information to help you diagnose and fix the issue, please let me know. |
I can't fix the issue if I can't reproduce it.
Save the CSS as 6242.css:
Then
and open 6242.epub in ibooks. If you get the same result I did, that would be helpful to know. |
The idea is to prune things down so you have a minimal case -- just enough to show the problem, without anything extraneous. |
No, your 6242.md file does not reproduce the problem for me. Here is one that does:
Here's the result: You can see that the first two code samples are now showing, but the subsequent ones are not. I feel like this is related to the (non-Go) backtick-delimited blocks; if I remove the first one, so that the test document starts at "It also tells you what the problem was...", the first missing code sample becomes visible, but the second one is still invisible. I hope this helps! |
Good. I can reproduce the issue with this input. |
But adding the extra CSS noted above to the end of the CSS didn't seem to help.
|
Using this workaround seems to work for me. I'm yet to see if this breaks rendering in other devices... @media screen {
.sourceCode {
overflow: visible !important;
white-space: pre-wrap !important;
}
} Using |
I don't know if this is really an issue any more. I just tried to create an EPUB using the latest version of pandoc (2.19.2), using the text from @bitfield's comment above, and the code blocks all displayed properly without any special tweaking. I think this issue should be closed, then, unless someone can reproduce the issue using the latest version of pandoc. |
It just goes to show how effective masterly inactivity can be as a bug-fixing strategy! |
Hi, recently I'm recompiled my markdown ebook and found that is all blocks of code are invisible in Apple Books.
I don’t know which update broke this OSX or Pandoc itself, but digging deeper I found a simple example that breaks it.
Info:
File:
test_case.md
Runs:
pandoc -t epub3 -o test_case.epub test_case.md
- second block of code is invisiblepandoc -t epub3 -o test_case.epub test_case.md
- test_case.md without 16 line, everything is finepandoc --no-highlight -t epub3 -o test_case.epub test_case.md
- original test_case.md with 16 line, everythins is fineThe text was updated successfully, but these errors were encountered: