-
Notifications
You must be signed in to change notification settings - Fork 162
Fix page breaks in reflowable Epub books #229
base: develop
Are you sure you want to change the base?
Fix page breaks in reflowable Epub books #229
Conversation
That's a great use of Do you think that the replacement of https://github.com/readium/readium-sdk/pull/229/files#diff-639376f74408a17718d6668606828a45R29 static REGEX_NS::regex CSSMatcher("page\\-break\\-(after|before|inside) *\\: *(always|avoid|left|right)", regexFlags);
...
static const std::string PageBreakReplacement = "-webkit-column-break-$1: $2; column-break-$&: $2"; |
@danielweck I haven't been able to find up-to-date information on the support of column breaks across webviews. It'll work with webkit-based webviews, but I can't say for sure for the rest. |
Another comment: this renames Also, this only works with standalone stylesheet files, not inline CSS styles. |
@danielweck It works with both standalone stylesheet files and inline CSS styles: it replaces You're right though, it does replace regardless of the context. I agree that having column breaks in a non-columnized view is not the most rigorous, but it's worth checking if it has any consequences on the rendering. I just tested on iOS: in scroll view mode, the I will do with more testing. |
Thank you for the correction (stylesheet files AND inline CSS). |
I tested on several platforms: works on iOS, OS X, Android and it would work with MSEdgeIEView as it supports webkit prefixed statements for |
Thanks for creating and testing this @olivierkorner @danielweck I am OK with it, If you are OK with this, please go ahead and merge it. |
Note: this PR incorrectly targets the |
// auto mediaType = item->MediaType(); | ||
// return (mediaType == "audio/mp4" || mediaType == "audio/mpeg" || mediaType == "video/mp4" || mediaType == "video/mpeg"); | ||
auto mediaType = item->MediaType(); | ||
return (mediaType == "application/xhtml+xml" || mediaType == "text/html" || mediaType == "text/css"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change intentional? To me it looks like an unintentional commit, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thank you!
Yes, I'll fix it along with the target branch.
I added an inline code comment. Also, for
...which means Android should compile without any modifications in the build configuration. @olivierkorner is that your experience as well? |
|
||
void CSSPreprocessor::Register() | ||
{ | ||
FilterManager::Instance()->RegisterFilter("CSSPreprocessor", ValidationComplete, CSSFilterFactory); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is ValidationComplete
the most adequate Content Filter priority? I think so, but just double-checking (must be after decryption).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked: ValidationComplete is the lowest priority, the filter is applied last.
when merged, this will have to be documented here: https://github.com/readium/readium-shared-js/wiki/ContentModifications |
@danielweck I compiled a clean SDKLauncher-Android: no need to modify the build configuration. |
I think the iOS / OSX compile error is because of one of my previous Android fixes. It's a simple code patch (misplaced preprocessor directive) in ObfuscatedFonts ContentFilter, related to OpenSSL. |
Hello, can this PR be "updated" to target the develop branch? |
@danielweck So much easier now that GitHub allows to change the base branch! |
Yes, that's great! :) |
Sorry for being so late to the party, but I can give further details about that. IntroTo put it simply, this has evolved significantly and is now part of the CSS Fragmentation Module. UA are even required to alias There’s an intent to implement from Chromium back to 2016. I thought Webkit aliased as well but I’m apparently wrong. Anyway, what’s important is that the spec doesn’t alias the super old Which brings me to the iOS UIWebView And, to quote Quirksmode:
Which is consistent with my personal experience. BugsNow to the fun parts… Issue 1: at some point in time on iOS/MacOS, if a stylesheet had both, none would be taken into account – that’s a bug I reported myself ± 18 months ago. Issue 2. fragmentation is not necessarily updated in some contexts (e.g. Issue 3. SupportYou won’t find those properties in CanIUse break feature, but you’ll find the mention to The biggest pain point is But to sum things up, this probably should be fixed in browsers because bugs can arise pretty quickly, and from personal experience, actually supporting it can do more harm than good. I’ve been very very cautious when using those properties when authoring EPUB files because of the amount of rendering issues some can trigger. [edit] There’s also a weird mention in the iBooks guidelines:
It won’t be unreasonable to think Webkit has issues with that, considering the CSS multicol implementation is quite terrible in all browsers. |
CSS properties
page-break-inside/after/before
with valuesalways/auto/avoid
are sometimes used in Epub books to force or prevent text to the next page. This is a print-only CSS property and as such it's rendered in the webview.By adding a CSS preprocessor content filter in the SDK, all occurences of
page-break-*
in CSS stylesheets and style elements and attributes in HTML content are replaced by matchingcolumn-break-*
, enforcing or preventing the page breaks accordingly in the reader.readium/readium-shared-js#127