Skip to content

fix(theme): disable text-autospace in <code>, <kbd>, and <samp>#3254

Merged
SoonIter merged 1 commit intoweb-infra-dev:mainfrom
tats-u:no-autospace-code
Mar 24, 2026
Merged

fix(theme): disable text-autospace in <code>, <kbd>, and <samp>#3254
SoonIter merged 1 commit intoweb-infra-dev:mainfrom
tats-u:no-autospace-code

Conversation

@tats-u
Copy link
Copy Markdown
Contributor

@tats-u tats-u commented Mar 24, 2026

Summary

I get Qiita (a Japanese large technical knowledge-sharing platform for programmers, similar to China's CSDN or Juejin but focused on short, practical coding articles) adopt text-autospace like Rspress, but I noticed that text-autospace is not so welcomed in not only <pre> but also <code>:

image image

increments/qiita-discussions#1049 (comment) (Japanese)

These extra spaces cause the loss of cohesion between characters in the Japanese function name mixed with English test_関数getRandomは1以上100以下の値を返す (meaning: test_函数getRandom返回1到100之间的值).

VitePress has been turned off text-autospace in not only <pre> but also <code>, <kbd>, and <samp>: vuejs/vitepress@21a5fb6

In the first place, CSS also does not recommend us to apply text-autospace there: https://drafts.csswg.org/css-text-4/#default-stylesheet

/* preserve character grid in preformatted text */
pre, code, kbd, samp, tt { text-spacing: none; }

Note: <tt> is deprecated. text-spacing = text-autospace + text-spacing-trim

Related Issue

<pre>: #3110 #3131

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings March 24, 2026 13:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the default theme CSS so CJK/Latin autospace behavior doesn’t disrupt inline/semantic code-like elements, aligning Rspress’ styling with emerging CSS default stylesheet guidance and behavior seen in other doc tools (e.g., VitePress).

Changes:

  • Disable text-autospace for code, kbd, and samp (in addition to pre) in the base theme stylesheet.
  • Add autospace to the project dictionary.
  • Add a changeset to publish a patch release of @rspress/core.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
scripts/dictionary.txt Adds “autospace” to custom dictionary to avoid lint/spellcheck noise.
packages/core/src/theme/styles/base.css Extends the text-autospace: no-autospace exception rule to code, kbd, samp.
.changeset/beige-parrots-slide.md Declares a patch changeset for @rspress/core covering the theme fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tats-u tats-u force-pushed the no-autospace-code branch from 5c7fe1b to 954ea96 Compare March 24, 2026 13:14
@tats-u
Copy link
Copy Markdown
Contributor Author

tats-u commented Mar 24, 2026

Reformatted

@SoonIter SoonIter enabled auto-merge (squash) March 24, 2026 13:36
Copy link
Copy Markdown
Member

@SoonIter SoonIter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! hugely thanks ❤️️~ :D

@SoonIter SoonIter merged commit 7381b46 into web-infra-dev:main Mar 24, 2026
4 checks passed
@tats-u tats-u deleted the no-autospace-code branch March 24, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants