Skip to content

Fix #2330: Escape angle brackets in man page output#2357

Open
rodionsteshenko wants to merge 1 commit intospf13:mainfrom
rodionsteshenko:fix-issue-2330
Open

Fix #2330: Escape angle brackets in man page output#2357
rodionsteshenko wants to merge 1 commit intospf13:mainfrom
rodionsteshenko:fix-issue-2330

Conversation

@rodionsteshenko
Copy link

Problem

Angle brackets in command Use, Short, Long, and flag Usage strings were stripped by md2man, which interpreted them as HTML tags. This caused placeholders like [<remote>:]<instance> to render as [:] in man pages.

Reported in #2330 by @stgraber (Incus project).

Fix

Added escapeAngleBrackets() which replaces < with \\< and > with \\> before the markdown is passed to md2man. Applied to:

  • cmd.UseLine() in SYNOPSIS
  • cmd.Short in NAME
  • Description (Long/Short) in DESCRIPTION
  • flag.Usage in OPTIONS

Test

Added TestGenManAngleBracketsPreserved that creates a command with angle-bracketed placeholders in Use, Short, and Long, generates a man page, and verifies the angle brackets survive in the rendered output.

  • Without the fix: test fails — output contains transfer [:] [:] (all placeholder names stripped)
  • With the fix: test passes — output preserves <remote>, <source>, <dest>

Tested locally on macOS ARM (Apple Silicon). Full test suite passes.

Angle brackets in command Usage, Short, Long, and flag Usage strings
were stripped by md2man which interpreted them as HTML tags. This caused
placeholders like [<remote>:]<instance> to render as [:] in man pages.

Fix: escape < and > with backslashes before passing to md2man.

Added TestGenManAngleBracketsPreserved to verify the fix.
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot added the area/docs-generation Generation of docs via Cobra label Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs-generation Generation of docs via Cobra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants