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

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 ownersMay 22, 2026 18:32
@reggireggi changed the title fix(docs): sanitize newlines in flags table default and type valueschore: sanitize newlines in flags table default and type valuesMay 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 latestMay 26, 2026
9 checks passed
@reggi
reggi deleted the reggi/fix-docs-table-newlines branch May 26, 2026 18:14
@github-actionsgithub-actionsBot mentioned this pull request May 21, 2026
Sign up for freeto 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

@reggi@owlstronaut