sile-typesetter / sile

The SILE Typesetter — Simon’s Improved Layout Engine
https://sile-typesetter.org
MIT License
1.66k stars 98 forks source link

Refactor twoside package #683

Open alerque opened 5 years ago

alerque commented 5 years ago
  1. The use of a module variable is going to produce a stateful action that might trip us up later in the event two or more typesetters are working on different places in a document. Rather than wait for bugs to crop up in usage this should be moved into the current typesetter or class state to just avoid those surprises.

  2. As noted in comments the implementation reaches far too deep into other code for comfort.

Omikhleia commented 2 years ago

Instead of opening a new issue, I'll provide my experimenting results here, since it seems pretty well related with the issues I am facing and the things a refactor might need to address. I hesitated with #385, also somehow related, but which seems more specific.

I am trying to have 3 (two-side) master sections than can be switched anytime in the course of a book:

Expected layout design illustration: image

I can alleviate some constraints, for clarity:

This being said, I tried to make a MWE and encountered a number of issues. You'll find attached a "bare" class and example attached, where I annotated "HACK" each of the problem I somehow solved in weird ways.

image

Those "HACKS" don't feel very natural to me, but I eventually succeeded in having the one-column / two-column switching ok (pages 1-6). I am still failing with landscape switch (I just rotated here the content frame by a small angle, not 90°, to better see what happens)

I am stuck there - so may some other eyes can be involved and help making this work...

experiment-masters.zip

Omikhleia commented 2 years ago

My main next challenge since the two-column case somehow worked (with hacks but still) was to try: image

Where frame "title" is an insertion stealing from the top of both columns (with the undocumented "steal-position" option in the "insertions" package). I couldn't make it work satisfyingly. image

Perhaps we can't have insertions stealing on both the top and bottom of a frame? I don't know, there are no examples, no tests to check against, scarce documentation... Giving up for now. I'm attaching my attempt again, would someone want to have a look, maybe I missed something.

experiment-masters-2.zip

alerque commented 2 years ago

I think you're running in to bugs I ran into when I tried to refactor the class system from stdlib to Penlight. There are some really weird side effects going on and the current class / frame / package loading system uses them in unexpected ways. You end up with references being used in places you would not expect. I'll get back on that as soon as my current project goes to press. It's been really bugging me and holding back work on CaSILE too — which I'm using heavily but frustrated I can't expand to do what I actually want because the class inheritance is so screwy.