Skip to content

chore: sanitize newlines in flags table default and type values#9393

Merged
reggi merged 1 commit into
latestfrom
reggi/fix-docs-table-newlines
May 26, 2026
Merged

chore: sanitize newlines in flags table default and type values#9393
reggi merged 1 commit into
latestfrom
reggi/fix-docs-table-newlines

Conversation

@reggi
Copy link
Copy Markdown
Contributor

@reggi reggi commented May 22, 2026

Problem

The generateFlagsTable function in docs/lib/index.js sanitizes description for newlines but does not do the same for defaultVal or typeVal. Some config definitions (like --access) have multi-line defaultDescription values, which breaks the markdown table — all subsequent columns/rows get collapsed into a single garbled line.

This is visible on the live docs: https://docs.npmjs.com/cli/v11/commands/npm-stage

Fix

Added .replace(/\n/g, ' ').trim() to both defaultVal and typeVal in generateFlagsTable, matching the existing sanitization already applied to desc.

The generateFlagsTable function was not stripping newlines from
defaultVal and typeVal, causing multi-line values (like --access's
defaultDescription) to break markdown table rows.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@reggi reggi requested review from a team as code owners May 22, 2026 18:32
@reggi reggi changed the title fix(docs): sanitize newlines in flags table default and type values chore: sanitize newlines in flags table default and type values May 26, 2026
reggi added a commit that referenced this pull request May 26, 2026
Backport of #9393 to release/v11.

The `generateFlagsTable` function in `docs/lib/index.js` sanitizes
`description` for newlines but not `defaultVal` or `typeVal`. Multi-line
`defaultDescription` values (like `--access`) break the markdown table
rendering.

Adds `.replace(/\n/g, ' ').trim()` to both `defaultVal` and `typeVal`,
matching the existing sanitization on `desc`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@reggi reggi merged commit 5fc9bc0 into latest May 26, 2026
9 checks passed
@reggi reggi deleted the reggi/fix-docs-table-newlines branch May 26, 2026 18:14
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