Koreader: Only first CSS class gets applied to element

Created on 2 May 2017  路  5Comments  路  Source: koreader/koreader

  • KOReader version: v2015.11-1024-g3b813c7
  • Device: Emulator

Issue

Only first CSS class gets applied to element.

All three lines should look exactly the same, as all three CSS classes should be applied. Instead only the first class gets applied.

koreader:
screen shot 2017-05-02 at 21 55 16

Sigil/ADE/iBooks/Calibre:
screen shot 2017-05-02 at 21 56 05

CSS:

p {
  margin-bottom: 0;
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  text-align: justify;
  text-indent: 1.2em;
}

p.margin {
  margin-bottom: 1em;
  margin-top: 1em;
}

p.noindent {
  text-indent: 0;
}

p.center {
  text-align: center;
}

HTML:

<p class="center margin noindent">This text gets centered</p>
<p class="noindent center margin">This text doesn't get indented</p>
<p class="margin center noindent">This text gets a margin</p>

Steps to reproduce

untitled.epub.zip

CREngine bug

Most helpful comment

I will create another PR for you guys to test. it totally removed the bad fix, I found another solution to support multi classes. also I found a way to fix css rules set with id names.
here it is https://github.com/koreader/crengine/pull/72

All 5 comments

Yeah, this one's pretty bad.

I noticed that some properties do get applied if specified as second or third class, for instance bold or underline formatting.
There has been a bad attempt at fixing this bug, which is the cause for this inconsistent behavior.
https://github.com/koreader/crengine/pull/13/commits/0930ec7230e720c148fd6f231d69558832b4d53a
Second and subsequent classes are applied by inserting spans into the markup.
Since spans are inline elements, block level properties such as margins, width, height, text-indent, etc. fail to be applied.

add support for html element that defined multiple classes
example: <p class="bold italic color"></p>
crengine will not match any css rules to the above example
* this patch add tags after those tags with more classes
* it turns the example into <p class="bold"></span class="italic"><span
class="color">example</span></span></p>
* it adds <div> after <div>,<span> after other tags
* it does not support <img> <tr> <table> but use the first class they
defined

Crengine used to support one class for each element. The patch for more than one class was not a good one. It does not really calculate the final css rules. If someone can do something about the css calculation, this one could be removed.

I will create another PR for you guys to test. it totally removed the bad fix, I found another solution to support multi classes. also I found a way to fix css rules set with id names.
here it is https://github.com/koreader/crengine/pull/72

Fixed in v2015.11-1074-g9b557ed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kwuik picture Kwuik  路  4Comments

AlanSP1 picture AlanSP1  路  3Comments

worldexplorer picture worldexplorer  路  4Comments

gbyl picture gbyl  路  3Comments

user655362020 picture user655362020  路  3Comments