baskerville / plato

Document reader
Other
1.26k stars 105 forks source link

[feature request] Override text-align for p elements wrapped in other elements #243

Open darukaru opened 2 years ago

darukaru commented 2 years ago

Version tested: Plato 0.9.27

Problem: I have a commercial epub on my device (Sage) which wraps an entire chapter's worth of paragraphs inside a

element. A shortened example of the markup and the relevant bit of the stylesheet follows.

<body>
<div class="galley-rw">
<section class="body-rw Chapter-rw auto-rw page-open-left-rw" epub:type="bodymatter chapter" id="chapter001">
<p>elided</p>
<p>Repeat for many such paragraphs</p>
</section>
</div>
</body>

The epub stylesheet contains these relevant selectors:

p
{
display: block;
margin-top: 0em;
margin-bottom: 0em;
margin-left: 0em;
margin-right: 0em;
text-indent: 20pt;
}

.galley-rw
{
font-family: serif;
font-size: 1em;
font-weight: normal;
letter-spacing: 0em;
line-height: 1.2em;
margin: 0em;
orphans: 1;
padding: 0em;
text-align: justify;
widows: 1;
word-spacing: 0em;
}

Long story short, <p> elements on their own have no specified alignment, but the .galley-rw class on the wrapper div enforces them to be fully justified.

Expected behavior: The text alignment widget in Plato should allow me to alter the alignment of the paragraphs, as if I had applied the "Left align most text" style tweak in KOReader, or changed the document text alignment while reading a KFX document on a Kindle. Essentially <p> elements would be treated as if they'd gained "text-align: <option> !important"

Actual behavior: Selecting different options for text alignment doesn't work; all paragraphs remain fully justified, presumably the alignment selected doesn't override that of the container.

I know I can toggle off publisher-supplied styles entirely by editing the config file, but I'd prefer not to lose the rest of the formatting nor have to constantly edit the config to toggle styles back on again for a book without wrappers like this.

If overriding styles to this degree isn't within the scope of Plato's CSS parsing then I fully understand.