Skip to content

Keep dashes and ellipses with the words they cling to - #56

Merged
gitosaurus merged 1 commit into
mainfrom
fix/wrap-em-dash
Aug 13, 2026
Merged

Keep dashes and ellipses with the words they cling to#56
gitosaurus merged 1 commit into
mainfrom
fix/wrap-em-dash

Conversation

@gitosaurus

Copy link
Copy Markdown
Owner

An em dash written as --- joins two words into a single token, because the
wrapper breaks only on whitespace. That was safe but crude: the pair moved as
a unit and the dash never got a break of its own. Sweeping the cursor across
the margin against a fragment that opens with a dash turned up something
sharper — such a line could run to column 83 in an 80-column terminal.

A fragment starting with punctuation is granted SafetyMargin columns so that
a lone period is not stranded by itself. A hyphen is punctuation, so fifty
characters of prose beginning with a dash collected a concession meant for one
character. The terminal hides this behind the five columns PagedOutput holds
back; --width and the web driver do not.

Three rules, and an ellipsis wants all of them as much as a dash does

  • A break may fall on the far side of a run of two or more hyphens or
    periods — the one place inside a word where a line may end. The far side
    must be a word: breaking am I... from ? would strand the question mark,
    which is the fault being repaired rather than a second instance of it.
  • No break is chosen that would leave such a run at the head of a line.
    The mark belongs to the word behind it and travels with it.
  • The punctuation concession is for a stub of no more than SafetyMargin
    characters, not for any clause that merely opens with a mark.

A single hyphen is left alone. It belongs to the word it joins, and
lead-lined is not a place to break a line.

Where the second rule stops

It governs the break the wrapper chooses. It does not reach the case where
there is no room to choose anything — a fragment opening with a dash arriving
when the line is already full. That one goes down to the next line and starts
it with the mark, which is the same answer the wrapper has always given a word
too long to fit: hold the margin, and let the line begin with whatever had to
be moved.

Honouring the no-leading-dash rule in that case was written first, and it cost
fifteen lines of special handling and a soft margin. Relaxing the rule deleted
the special case and made the margin hard again. Overrunning the margin is the
fault that shows in a narrow window; a line that opens with a dash is not.

Verification

  • 18 test suites, 0 failures. Seven new cases in testClingingMarks_ at 20
    columns, covering both sides of a mark, the stranded ?, lead-lined, the
    forced case, and the lone period that the safety margin still rescues.
  • Starship and Gorreven produce byte-identical output across the change.
    Neither uses the unspaced forms yet, which is the point: this is inert on
    everything already written, and only changes what happens once --- starts
    appearing in game text.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Ui8UMgev1U8LW5iyQdSsJ

An em dash written as "---" joins two words into a single token, since the
wrapper breaks only on whitespace.  That was safe but crude: the pair moved
as a unit, and the dash never got a break of its own.  Sweeping the cursor
across the margin against a fragment that opens with a dash -- the shape the
navigation panel uses -- turned up something sharper.  Such a line could run
past the margin, to column 83 in an 80 column terminal.  A fragment starting
with punctuation is granted SafetyMargin columns so that a lone period is
not stranded by itself; a hyphen is punctuation, so fifty characters of
prose beginning with a dash collected a concession meant for one character.
The terminal hides this behind the five columns PagedOutput holds back.
--width and the web driver do not.

Three rules now, and an ellipsis wants all of them as much as a dash does:

  - A break may fall on the far side of a run of two or more hyphens or
    periods, which is the one place inside a word where a line may end.
    The far side must be a word: to break "am I..." from "?" would strand
    the question mark, which is the fault being repaired rather than a
    second instance of it.
  - No break is chosen that would leave such a run at the head of a line.
    The mark belongs to the word behind it and travels with it.
  - The punctuation concession is for a stub of no more than SafetyMargin
    characters, not for any clause that merely opens with a mark.

A single hyphen is left alone.  It belongs to the word it joins, and
"lead-lined" is not a place to break a line.

The second rule governs the break the wrapper chooses.  It does not reach
the case where there is no room to choose anything -- a fragment opening
with a dash, arriving when the line is already full.  That one goes down to
the next line and starts it with the mark, which is the same answer the
wrapper has always given a word too long to fit: hold the margin, and let
the line begin with whatever had to be moved.  Overrunning the margin is
the fault that shows in a narrow window.

Starship and Gorreven produce byte-identical output across the change.
Neither uses the unspaced forms yet, which is the point: this is inert on
everything already written.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Ui8UMgev1U8LW5iyQdSsJ
@gitosaurus
gitosaurus merged commit b830260 into main Aug 13, 2026
2 checks passed
@gitosaurus
gitosaurus deleted the fix/wrap-em-dash branch August 13, 2026 02:31
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