Skip to content

Accept emboldened man page overstrikes - #473

Merged
walles merged 15 commits into
masterfrom
fix-multi-overstrike-bold
Oct 16, 2026
Merged

walles merged 15 commits into
masterfrom
fix-multi-overstrike-bold

Conversation

@walles

@walles walles commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Fixes #472.

Old pod2man man pages ask for artificial emboldening with .bd B 3. groff 1.22.4 (Ubuntu 22.04) then repeats each overstruck cell, separated by a backspace, for example x<x<x<x for a bold x (< is backspace). moor only accepted the plain forms, so the extra backspaces showed up on screen as red <. groff 1.23 doesn't do this, which is why newer systems don't see the problem.

Changes:

  • New consumeEmboldened() wraps each overstrike consumer (bold, underline, bold underline, bullet) and swallows backspace separated repeats of the same cell. Repeats render just like the plain cell.
  • _<_<_<_ (an emboldened bold underscore, as in "system_var" in the getconf page) is parsed as bold. A plain bold underlined _<_<_ still parses as bold underline.
  • Man page headings are now parsed using the same consumers as the tokenizer, replacing the separate state machine. Headings and search now always agree on what's an overstrike. An up-front check makes non-heading lines faster to reject. Heading lines are slower to parse than before, but there are only a few of those on screen at a time, and BenchmarkRenderLines shows no change.

The test cases are exact byte sequences captured from groff 1.22.4 in an Ubuntu 22.04 container, rendering the reporter's getconf page plus a small test page using .bd on the B, I and BI fonts. The tests also check that search sees the same text as what's on screen.

🤖 Generated with Claude Code

walles and others added 7 commits October 15, 2026 21:32
Reproduces #472.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Old pod2man pages say ".bd B 3", and groff 1.22.4 then strikes bold
chars four times: 'x<x<x<x'. We used to only accept 'x<x', so the extra
backspaces showed up on screen.

Fixes #472.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Captured from an Ubuntu 22.04 container rendering .bd B/I/BI pages.
Replaces the made-up 3-5 strike loops with the real bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
grotty in groff 1.22.4 repeats the whole overstruck cell, separated by
a backspace, for fonts a man page emboldens using ".bd". Swallow such
repeats so they render like the plain cell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
'_<_<_<_' used to match bold underline first, leaving a trailing '<_'
unparsed. Seen in "system_var" in the getconf man page on Ubuntu 22.04.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
walles and others added 8 commits October 15, 2026 21:56
'x<x<x<x' is two 'x<x' cells separated by a backspace, which
consumeEmboldened() already handles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A flag does the job of the two extra states.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nment

The first two fail: the '_' guard in consumeBoldUnderline() breaks plain
bold underlined underscores, and the heading parser accepts odd strike
counts the tokenizer doesn't.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A plain bold underlined underscore lost its underline and got a stray
'<' since the guard also caught it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces the heading state machine with consumeEmboldened(consumeBold),
so headings accept exactly what the tokenizer accepts. This fixes odd
strike counts like 'N<N<N' being rendered as a heading while search
saw the backspaces, misaligning search hits.

An up front check makes non-heading lines faster to reject. Heading
lines are slower to parse than before since the consumers allocate,
but there are only a few of those on screen at a time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@walles
walles merged commit 5deca90 into master Oct 16, 2026
2 checks passed
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.

Weird output on some man pages

1 participant