mwoffliner
mwoffliner copied to clipboard
summary and details tag are no longer supported
Before mobile-section
deprecation mwoffliner used related JSON response to generate collapsible sections using Swig templates (see res/templates/section_wrapper.html file). Since page/html
and page/mobile-html
are responsible for outputting HTML content, no collapse sections are available. The symptom of this issue is mentioned in https://github.com/openzim/mwoffliner/issues/1860 and https://github.com/openzim/mwoffliner/issues/1866
There are multiple ways to bring these sections to work:
- Apply
page/html
output and related transformations from mobileapps in mwoffliner. - Create our own collapsible sections but on top of
page/mobile-html
@VadimKovalenkoSNF I'm not quite sure how substitution happens in mwOffliner, but I've found that the following two steps easily restore the previous behaviour:
- Replace the
<section data-mw-section-id="...">...</section>
blocks with<details data-mw-section-id="...">...</details>
; -
Wrap* (not replace) the
<h[2-5]>...</h>
blocks inside the new<details>
blocks with<summary class="section-heading collapsible-heading">...</summary>
.
I can provide a one-line regular expression JS replacement that does this if you operate on the html as a string, though I suspect you might prefer to use DOM methods to select and replace/wrap the elements.
I have a working solution in prototype code for the Kiwix JS PWA, but it would be much better to fix in the ZIM. Happy to give details if it's helpful.
Thanks, @Jaifroid . I'll probably use DOM methods for this indeed, but your idea seems valid.