Skip to content

Fix/insert picture empty line - #41

Closed
084intheImpala wants to merge 8 commits into
trojsten:masterfrom
084intheImpala:fix/insert-picture-empty-line
Closed

084intheImpala wants to merge 8 commits into
trojsten:masterfrom
084intheImpala:fix/insert-picture-empty-line

Conversation

@084intheImpala

Copy link
Copy Markdown
Contributor

No description provided.

084intheImpala and others added 8 commits September 30, 2026 14:57
The mechanism, with nothing converted yet. A figure's file and size move into the
meta and the call site keeps only the caption, which is prose and translated, and
the position, which a translator may move:

    pictures:
      hanging:
        file: hanging.png
        height: 40mm

    (§ pictures.hanging §)                     (§ pictures.hanging('Lano') §)
    (§ pictures.hanging(height='55mm') §)      -- hu needs the room, visibly

**The key is the label**, which is the whole bargain and is worth more here than
on the equation side: 440 of the repository's 869 hand-written figure labels do
not follow `fig:<pid>:<key>`, one does not even match its own problem id, and a
wrong figure label is silent until a crossref resolves to nothing.

**Whether a figure is captioned is the file's decision**, declared by the module
in both directions as `equation_numbering` is, because a caption is what makes
pandoc emit a `figure` at all -- and so what gives the drawing a number and a
`\label`. Those are one decision, not two. A statement never captions its
figures, and nothing is lost: of the 169 figure labels written into statements,
not one is referenced from anywhere. A solution always does, empty caption
included, which is what stops a figure being referenceable in one language and
not another -- `18/firework-bee/en` prints `??` today for exactly that reason.

Three things the end-to-end run turned up that reading could not:

- **`![]` and `![ ]` do not make a figure.** Pandoc needs the alt text to have
  content, so both come out as a bare `\includegraphics` with no number and no
  label. `![<!-- -->]` is a comment to the parser and nothing on the page, and is
  what an empty caption is written as.
- **`convertor.py` deleted `\caption{}` and its `\label` with it.** That rule put
  the figure straight back to unnumbered, which is the defect this exists to end,
  so it is gone -- inert for everything that exists, since no source writes an
  empty alt and nothing under `build/` carried a `\caption{}`.
- **The tag is block material and has to own its line.** `(§ pictures.x §)` mid
  sentence makes an *inline* image, losing the figure, its caption and its number
  with no error anywhere, so `RE_DISPLAY_TAG` now matches it and
  `settle_display_tags` splits the line as it does for `|disp`.

`label_prefix` is a module hook rather than `meta_path.parent.name` outright,
against seminar, whose problems are numbered `01`, `02` per round: its labels are
hand-written in four incompatible spellings today -- 228 of 601 off the house
rule -- with seven names defined in more than one problem directory. naboj takes
the default and nothing moves.

11 new tests, both halves each. Also fixes `test_the_version_follows_the_files`,
which assumed `app.js` was the newest of the three cache-busted assets and so
failed on any tree where `highlight.js` had been touched more recently.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
It was the wrong way round. The converter encoded a multi-line caption's break as
a `\n` in the Jinja string, which put the break in the rendered output -- where it
does nothing, a newline inside `![…]` being a space to pandoc -- and the long line
in the source, where it costs the 120-character limit and a readable diff. 21 call
sites came out over 120 characters and the longest at 249.

`Picture` collapses the caption's internal newlines now, so the wrapping is the
source's business and the break is free. The sources keep their original wrapping,
written with real newlines, which Jinja takes inside a string literal.

Proven neutral rather than assumed: `\caption{first line\nsecond line}` and
`\caption{first line second line}` are the same to TeX, and the 42 affected files
convert to byte-identical TeX once whitespace is normalised.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The one thing a call-site caption cannot do. A caption is passed as a string
argument, and a `(§ … §)` inside a string literal ends the enclosing tag at its
first `§)` -- so `(§ pictures.x('… $(§ Imax §)$') §)` does not parse at all, and
four call sites in `25/czechlights` and `25/public-transport` had to stay literal.

`caption:` in the entry takes it instead, per language or as a bare string where
every language shares one, resolved the way a `words:` term is. Nothing lexes it
there, so it needs no quoting: the text is emitted as written and the next render
pass expands whatever tags it holds, which is how `blocks:` has always worked and
is why `render_to_fixpoint` keeps going until the output stops changing.

The call site stays the normal place for a caption and wins where both are given.
It is prose, only 5 of 386 read the same in every language, and a translator may
want it to read differently; this is the exception, not a second home.

Also strips the caption as well as joining it, because a `|` block scalar keeps
its final newline and that arrived as a space before the closing `]`.

Four new tests, and the four call sites convert: the TeX is identical modulo
whitespace, so `picture-literal` is now silent across the whole of naboj.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
graphicx's scaling is not exact, so a picture bound by `width=\linewidth`
can come out a hundredth of a point wider than the line -- under \hfuzz,
so nothing warns -- and then no longer fits beside `center`'s empty \item
label. TeX breaks after the label and an empty centred line, a whole
\baselineskip, opens above the drawing. 29/amusement-speed lost 5 mm to it
and ran off its pt tear-off page; 29/chopper had the same gap.

The picture now sits in a \makebox exactly \linewidth wide, so it can never
be wider than the line. Pictures bound by their height are unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The venue builder joined source/naboj onto a launch directory that already
is source/naboj, so instructions-inner was silently skipped. The make rules
now look for instructions-inner.jtex (not .md) and rebuild the venue when it
changes, and the venue keeps its own start time instead of the volume's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants