Page MenuHomePhabricator

Simple CSS for ebooks on Wikisource (ePub, pdf)
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Open a book on WS.
  • Generate epub.
  • Open in e.g. Freada reader.

What happens?:

Images are not floated.

CSS doesn't contain styles for the images.

What should have happened instead?:

To be honest I think current CSS is far too complicated (added along with T51097). There were 8 selectors in previous CSS, and current one has much more. This is important because ebook readers limit number of supported CSS rules/selectors. Another problem is that CSS is very limited in ePub and Mobi and probably in PDF converter too. For example even if CSS variables would be used (to limit number of rules), then they still wouldn't work on e.g. Mobi (Amazon Kindle) and probably most ePub readers (Android and others). CSS support in Kindles.

Some simpler CSS version should be prepared and added in the ebook preparation tools.

Software version (skip for WMF-hosted wikis like Wikipedia): broken with figure rollout.

Other information (browser name/version, screenshots, etc.):

https://pl.wikisource.org/wiki/Dziecko_salonu/Wr%C3%B3%C5%BCba

Freda readerpdf
obraz.png (933×749 px, 116 KB)
obraz.png (349×692 px, 40 KB)

https://pl.wikisource.org/wiki/Dziecko_salonu/Pudel
HTML:

				<span class="dropinitial"
					style="float:left;line-height:1.00em;font-size:3.00em;margin:0.00em -0.4em 0.00em 0.00em;text-indent:0.00em">
					<figure class="mw-halign-left" typeof="mw:File"><a
							href="https://pl.wikisource.org/wiki/Plik:Dziecko_salonu-inicja%C5%82_S.png"
							class="mw-file-description"><img alt="S"
								src="images/c34_Dziecko_salonu_inicja__S.png_75px_Dziecko_salonu_inicja__S.png"
								decoding="async" style="width:75; height:64; "
								data-title="Dziecko_salonu-inicjał_S.png-75px-Dziecko_salonu-inicjał_S.png" /></a>
						<figcaption />
					</figure>
				</span><span
					style="position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px, 1px, 1px, 1px);">S</span>niło
				mi się, że jestem pudlem.<br />

Event Timeline

Soda subscribed.

This probably isn't ProofreadPage, WS Export looks like the proper project :)

Thanks for reporting this @Nux.

The example above looks to be Strona:Janusz Korczak - Dziecko salonu.djvu/57 and is producing the following HTML:

<figure class="mw-halign-left" typeof="mw:File"><a href="https://pl.wikisource.org/wiki/Plik:Dziecko_salonu-inicjał_D.png" class="mw-file-description"><img alt="D" resource="./Plik:Dziecko_salonu-inicjał_D.png" src="images/c1_Dziecko_salonu_inicja__D.png_70px_Dziecko_salonu_inicja__D.png" decoding="async" data-file-type="bitmap" style="width:70; height:68; " data-title="Dziecko_salonu-inicjał_D.png-70px-Dziecko_salonu-inicjał_D.png"/></a><figcaption/></figure><p about="#mwt6" typeof="mw:Transclusion"><span style="position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px, 1px, 1px, 1px);">D</span>woje oczu wielkich, czarnych, uparcie nieruchomych i smutnych. Wargi drżące w kurczowym półuśmiechu. Nad białem czołem koroną żałobną włosy bujne. Głos cichy, monotonny.<br/></p>

I'm not sure what happened to the .dropinitial wrapper. @Nux is the HTML you added above from a while ago maybe?

Anyway, it looks like WS Export is not handling the .mw-halign-left because it's not got that in its default stylesheet and nor is it in plwikisource's epub.css.

The quick fix here is to add the relevant styles to the wiki's epub.css, and we should look at adding them to the default stylesheet — or perhaps import all of content.media-common.less? We've looked into doing that in the past though haven't we? And it was going to be too complicated or break other things?

This bug looks like it's a duplicate of T272704: Vertical alignment of images broken with Parsoid on export.

@Samwilson Sorry, I assumed all letters are using it. The HTML is from this page:
https://pl.wikisource.org/wiki/Strona:Janusz_Korczak_-_Dziecko_salonu.djvu/11

The wrapper comes from Dropinitial template. I guess it would need to be modified too (currently using span and figure is a block element). It is used 4,710 times.
https://pl.wikisource.org/wiki/Szablon:Dropinitial

As I mentioned problem with content.media-common.less is that those styles are very complicated (as compared to previous ones). The number of rules alone is too big. As mentioned above, using many rules in eBooks is not advised. And also please note that what works in browsers not necessary works in eBook readers... Unfortunately.

Not sure why Parsoid is tagged here? @Arlolra might be able to offer some insight w/r/t the media styles; it's possible you can use a simplified version of the stylesheet if you are using *only* the "new style media" output; I think we currently have rules for both legacy media output and new media output enabled because there are transclusion scenarios which might cause 'legacy' markup to appear on 'new' pages.

I've made a PR for adding these new styles to the default WS Export stylesheet: https://github.com/wikimedia/ws-export/pull/450 (ready for review).

The only Wikisource I've found that has already added these is French: https://fr.wikisource.org/w/index.php?diff=13102335 (although English has added the valign ones).

I'm not 100% sure that all scenarios are covered, but the bug above is fixed:

Screenshot_20230315_155909.png (301×731 px, 49 KB)

The above CSS fixes are included in 2.11.1 which I just tagged. It'll be live on the site shortly.

Everything seems to be working now, thanks 🙂

Turns out I didn't notice that the new Parsoid only adds the figure tag when using left (or right) alignment. So if you use the simpler syntax, it still generates span elements (e.g. this generates inline elements: [[file:chateaubriand atala z.png|40px]]). So it's good and it's not as big a change as I thought 🙂

Okay great, thanks!

I think the only follow-ups here are to clean up the existing epub.css pages on wikis where those already have the styles. I've left comments on Epub.css at fr, en, pt, and hi (these are the Wikisources I could find that already have any of these styles).

MusikAnimal claimed this task.
MusikAnimal subscribed.

Resolving per T330949#8719861. Please re-open if anyone feels this shouldn't be closed yet.