HTML drops a division's blocks when its only specialized division is a "worksheet" or "handout"

Open
#3,299 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
56/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
xml
Domain
backend

Research direction

Start by reading the "is-leaf" template in xsl/pretext-common.xsl and the "intermediate" template in xsl/pretext-html.xsl; the issue identifies how they interact. Build the supplied reproduction as HTML with a publication file containing only <publication/> and inspect the generated chapter pages. Done means the preceding paragraph and listing appear on a page, or the schema rejects this placement, with no silent loss.

Written by the indexing model from the issue text.

Description

A division may hold paragraphs and other blocks followed by specialized divisions, and the schema accepts a worksheet or handout among those. When a worksheet or handout is the only specialized division, the HTML conversion puts the blocks ahead of it on no page, and reports nothing.

The Guide shows it. The Basics Reference chapter "Worksheets" (basics-ch-worksheets in doc/guide/basics/basics-part.xml) opens with a paragraph and Listing 17.0.1, "Structure of worksheet", followed by its worksheet. The chapter's HTML page has only a link to the worksheet. The paragraph and the listing are on no page: cross-references to the listing point to basics-ch-worksheets.html#basics-l-worksheet, which has no such element, and only their knowls show it. The Guide validates with no message about this chapter.

This book reproduces it, and validates with no messages:

<?xml version="1.0" encoding="UTF-8"?>
<pretext>
    <book xml:id="repro">
        <title>Worksheet Reproduction</title>
        <chapter xml:id="ch-worksheet" label="ch-worksheet">
            <title>Paragraph Then Worksheet</title>
            <p>PARAGRAPH-BEFORE-WORKSHEET</p>
            <worksheet xml:id="ws-one" label="ws-one">
                <title>The Worksheet</title>
                <p>INSIDE-WORKSHEET</p>
            </worksheet>
        </chapter>
        <chapter xml:id="ch-introduction" label="ch-introduction">
            <title>Introduction Then Worksheet</title>
            <introduction>
                <p>PARAGRAPH-IN-INTRODUCTION</p>
            </introduction>
            <worksheet xml:id="ws-two" label="ws-two">
                <title>Another Worksheet</title>
                <p>INSIDE-SECOND-WORKSHEET</p>
            </worksheet>
        </chapter>
        <chapter xml:id="ch-handout" label="ch-handout">
            <title>Paragraph Then Handout</title>
            <p>PARAGRAPH-BEFORE-HANDOUT</p>
            <handout xml:id="ho-one" label="ho-one">
                <title>The Handout</title>
                <p>INSIDE-HANDOUT</p>
            </handout>
        </chapter>
        <chapter xml:id="ch-exercises" label="ch-exercises">
            <title>Paragraph Then Exercises</title>
            <p>PARAGRAPH-BEFORE-EXERCISES</p>
            <exercises xml:id="ex-one" label="ex-one">
                <title>The Exercises</title>
                <exercise><statement><p>INSIDE-EXERCISES</p></statement></exercise>
            </exercises>
        </chapter>
    </book>
</pretext>

Built as HTML on current master, with a publication file that is only <publication/>, the build reports nothing, and the contents land here:

Chapter Its paragraph Its specialized division
Paragraph, then worksheet on no page its own page
introduction, then worksheet the introduction's own page, linked from the chapter's page its own page
Paragraph, then handout on no page its own page
Paragraph, then exercises the chapter's page the chapter's page

The "is-leaf" template in xsl/pretext-common.xsl answers false for a division that has a worksheet or handout and no other specialized division. Its comment speaks of "a division full of only "worksheet" or "handout"", but the test does not look for blocks. Such a division becomes a summary page, and the "intermediate" template in xsl/pretext-html.xsl writes the heading and links to the subdivisions only: "everything else on a summary page gets dropped". The same test serves every division; the reproduction uses chapters.

Either the conversion places those blocks, or the schema stops accepting them ahead of a worksheet or handout that is the only specialized division. For the Guide's chapter, an introduction around the paragraph and the listing would put them on a page now.

Claude Opus 5.5, acting as a coding assistant for Rob Beezer

Dominant language
XSLT
Stars
466
Forks
251
Avg merge
4m
Merged PRs (30d)
13

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PreTeXtBook/pretext

All issues in PreTeXtBook/pretext

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.