Skip to content

Preserve repeated spaces in badge text#11910

Open
puneetdixit200 wants to merge 1 commit into
badges:masterfrom
puneetdixit200:fix-preserve-badge-spaces
Open

Preserve repeated spaces in badge text#11910
puneetdixit200 wants to merge 1 commit into
badges:masterfrom
puneetdixit200:fix-preserve-badge-spaces

Conversation

@puneetdixit200

Copy link
Copy Markdown

Summary

  • Preserve consecutive whitespace in badge SVG text nodes by adding xml:space="preserve" only when the rendered text contains repeated whitespace.
  • Add a regression test for labels like foo bar, where width calculation already accounts for the spaces but browser SVG rendering collapsed them.

Fixes #6510

Tests

  • npm_config_cache=/tmp/shields-6510-npm-cache npx mocha badge-maker/lib/make-badge.spec.js (failed before the renderer change, passed after)
  • npm_config_cache=/tmp/shields-6510-npm-cache npx mocha --timeout 10000 "badge-maker/**/*.spec.js"
  • npm_config_cache=/tmp/shields-6510-npm-cache npm run check-types:package
  • npm_config_cache=/tmp/shields-6510-npm-cache npx prettier --check badge-maker/lib/badge-renderers.js badge-maker/lib/make-badge.spec.js
  • npm_config_cache=/tmp/shields-6510-npm-cache npx eslint badge-maker/lib/badge-renderers.js badge-maker/lib/make-badge.spec.js
  • git diff --check

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 ✨ Thanks for your contribution to Shields, @puneetdixit200!

Generated by 🚫 dangerJS against c356f9a

@PyvesB

PyvesB commented Jun 7, 2026

Copy link
Copy Markdown
Member

Hello @puneetdixit200 👋🏻 Could you clarify why you're submitting changes authored by @pratyushjaiswal0806-dot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

When multiple spaces are present, label width is computed incorrectly

3 participants