Skip to content

Fix unclosed style marker crash - #364

Open
benjaminking wants to merge 2 commits into
mainfrom
fix-unclosed-style-marker-crash
Open

Fix unclosed style marker crash#364
benjaminking wants to merge 2 commits into
mainfrom
fix-unclosed-style-marker-crash

Conversation

@benjaminking

@benjaminking benjaminking commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

This PR corrects a few different errors that could occur with marker placement, due to unmatched markers in the source, one of which was causing a crash, and the others leading to incorrect output:

  • An unclosed style marker in a non-verse paragraph would cause a crash
  • An unclosed style marker would cause the next occurring paragraph marker to be ignored
  • Only the first row of a verse range was being read
  • An element of type OTHER could cause markers to be placed out of order
  • Plus one corner case where end_note was behaving inconsistently in duplicated verses

This change is Reviewable

Ben King and others added 2 commits September 9, 2026 16:31
An unclosed character style is closed implicitly by the next paragraph
marker. end_char consumed tokens through state.index even on an implicit
close, so that paragraph marker was pulled into the block being closed and
dropped along with the removed style. In a non-verse paragraph it also left
the place markers handler holding a paragraph element marked for removal,
which satisfied the early-out guard but produced nothing to place, raising
IndexError.

- end_char only consumes tokens when the style is explicitly closed, as
  end_note and end_sidebar already did
- end_note mirrors start_note for duplicate verses, which end_char had been
  masking by consuming the end marker first
- the place markers early-out guard is derived from a single _is_placeable
  predicate so it cannot disagree with element collection, plus an explicit
  check for nothing left to place
- OTHER elements no longer count as content when locating end-of-verse
  paragraph markers, which was moving embeds past them
- TEXT elements are read in full: a verse range matched by several rows has
  one token per row, and reading only the first dropped the rest of the
  translation

Co-Authored-By: Claude Opus 5 (1M context) <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.

1 participant