Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single-section volumes #26

Open
PaulRambags opened this issue Nov 20, 2019 · 9 comments
Open

Single-section volumes #26

PaulRambags opened this issue Nov 20, 2019 · 9 comments
Labels
enhancement New feature or request Low Prio

Comments

@PaulRambags
Copy link
Contributor

As Dedicon, I would like to have an option to indicate that each volume of the generated PEF will have exactly one section, so that there won't be empty white pages between sections in a duplex pagination.

In the current implementation, a volume can have several sections. The PEF specification is such that in duplex mode a section always starts on a recto page. For instance, if the PEF has this structure:

<pef>
  <head>...</head>
  <body>
    <volume duplex="true">
      <section>
        <page>...</page>
      </section>
      <section>
        <page>...</page>
      </section>
    </volume>
  </body>
</pef>

then there will be an empty page inserted in between the two <page>s when this PEF is printed. Also if both sections use the same page number counter, Dotify will assign page numbers 1 and 3, respectively.

As Dedicon I would like to be able to remove those empty pages between sections, such that the above example becomes:

<pef>
  <head>...</head>
  <body>
    <volume duplex="true">
      <section>
        <page>...</page>
        <page>...</page>
      </section>
    </volume>
  </body>
</pef>

The page numbers should be corrected as well.

Implementation detail:
A volume consists of a pre-content, a body, and a post-content, which are section lists. The pre-content and the post-content can be empty, the body will always have at least one section. Each section has section properties and these may differ per section. The implementation should generate a single section for every volume with the section properties of the first body section.

@bertfrees
Copy link
Contributor

bertfrees commented Nov 21, 2019

Adding an option to do this within Dotify is in theory possible, because OBFL doesn't mention anywhere that a sequence or toc-sequence or dynamic-sequence needs to start on a new sheet (I think, we'd have to check to be sure). However OBFL does have the concept of sheets, and when generating pages, Dotify must know whether it is currently generating a left- or a right-hand page. At first I thought this was not so trivial to implement without starting a new section after the pre-content, but maybe it's just a matter of storing the size of the pre-content in the CrossReferenceHandler (something similar is already done, see the Overhead class).

A very simple workaround that does not require any changes in Dotify is to simply not select duplex, and then post-process the PEF before sending it to the printer. The downside if of course that some sheet-related things will not work, like e.g. break-before="sheet", or breaking a volume on a left-hand page.

Related issue: braillespecs/obfl#23

@PaulRambags
Copy link
Contributor Author

OBFL doesn't mention anywhere that a sequence or toc-sequence or dynamic-sequence needs to start on a new sheet (I think, we'd have to check to be sure

Yes, OBFL mentions that. Quoted from the OBFL specification:

Duplex
In a sequence where duplex is enabled, both sides of sheets are counted and paginated. However, if the last sheet of a duplex sequence only has content on the front side, the back side is counted, but not paginated.

In other words, in duplex mode a sequence with an odd number of pages will have an additional empty page, which is counted.

@bertfrees
Copy link
Contributor

Hmm, so this means that this new Dotify option would either overwrite what is specified in the OBFL file (which is a bit risky), or we need to change the spec?

The more I think about it the more I think the spec should support this. What do you think about the following proposal?

We already introduced the break-before attribute on sequence to support forced volume breaks (value "volume"). Why not add the new values "page" and "sheet" (the latter being the default and equivalent to "auto")? In addition we add a break-before attribute on dynamic-sequence and toc-sequence, and also a break-after attribute on sequence, dynamic-sequence and toc-sequence.

@PaulRambags
Copy link
Contributor Author

The point is that the PEF format is such that when a volume has more than one section, and a section has an odd number of pages, there will be an empty page inserted. So I need a solution that guarantees that a volume will have no more than one section.

@bertfrees
Copy link
Contributor

Yes I understand. But OBFL does not say anything about what the produced PEF should look like (in fact it does not even require that the output is PEF). Dotify can choose whether it creates new sections or not. Your only guarantee is that the document will be rendered as specified in the OBFL file, and that is all that matters.

@bertfrees
Copy link
Contributor

bertfrees commented Dec 3, 2019

I'm adding a few examples to clarify things (click to expand).

When a toc-sequence is followed by a regular sequence, both are duplex, and we want no new sheet after the TOC:
<obfl>
   <layout-master name="default" duplex="true">
      ...
   </layout-master>
   <volume-template>
      <pre-content>
         <toc-sequence master="default">
            ...
         </toc-sequence>
      </pre-content>
   </volume-template>
   <sequence master="default" break-before="page">
      ...
   </sequence>
</obfl>

This could result in the following PEF:

<pef>
   <body>
      <volume duplex="true">
         <section>
            <page>
               <!-- toc -->
            </page>
            <page>
               <!-- body -->
            </page>
         </section>
      </volume>
   </body>
</pef>
If you set break-before="sheet" (or you omit break-before), the behavior is as before, i.e. a new PEF section is created for every new sequence:
<obfl>
   <layout-master name="default" duplex="true">
      ...
   </layout-master>
   <volume-template>
      <pre-content>
         <toc-sequence master="default">
            ...
         </toc-sequence>
      </pre-content>
   </volume-template>
   <sequence master="default" break-before="sheet">
      ...
   </sequence>
</obfl>
<pef>
   <body>
      <volume duplex="true">
         <section>
            <page>
               <!-- toc -->
            </page>
         </section>
         <section>
            <page>
               <!-- body -->
            </page>
         </section>
      </volume>
   </body>
</pef>

But another option could be to insert empty page elements. This PEF and the one above are equivalent:

<pef>
   <body>
      <volume duplex="true">
         <section>
            <page>
               <!-- toc -->
            </page>
            <page/>
            <page>
               <!-- body -->
            </page>
         </section>
      </volume>
   </body>
</pef>
If there is a transition from duplex to simplex or visa-versa, we have to create a new section in the PEF, so the break-before="page" has no effect:
<obfl>
   <layout-master name="duplex" duplex="true">
      ...
   </layout-master>
   <layout-master name="simplex" duplex="false">
      ...
   </layout-master>
   <volume-template>
      <pre-content>
         <toc-sequence master="duplex">
            ...
         </toc-sequence>
      </pre-content>
   </volume-template>
   <sequence master="simplex" break-before="page">
      ...
   </sequence>
</obfl>
<pef>
   <body>
      <volume duplex="true">
         <section>
            <page>
               <!-- toc -->
            </page>
         </section>
         <section duplex="false">
            <page>
               <!-- body -->
            </page>
         </section>
      </volume>
   </body>
</pef>

@PaulRambags
Copy link
Contributor Author

@bertfrees I like your concept of break-before="page". 👍
At your last example, you probably mean "break-before="page" instead of break-before="sheet".
By the way, this discussion should have been at the OBFL repository, not here.

@bertfrees
Copy link
Contributor

At your last example, you probably mean "break-before="page"

Correct

@kalaspuffar kalaspuffar transferred this issue from mtmse/dotify.formatter.impl Aug 20, 2021
@bertfrees
Copy link
Contributor

The solution that was proposed here was added to OBFL: mtmse/obfl#26. Now we need to implement it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Low Prio
Projects
None yet
Development

No branches or pull requests

3 participants