diff --git a/.changeset/chilly-shoes-marry.md b/.changeset/chilly-shoes-marry.md new file mode 100644 index 0000000000..0e12cffa7b --- /dev/null +++ b/.changeset/chilly-shoes-marry.md @@ -0,0 +1,7 @@ +--- +'nextra-theme-blog': patch +'nextra-theme-docs': patch +'nextra': patch +--- + +To ensure consistent horizontal padding, set the default language as plaintext for code blocks. This prevents any loss of formatting for code blocks without a specified language. diff --git a/examples/blog/pages/posts/code-blocks.mdx b/examples/blog/pages/posts/code-blocks.mdx index 47e0773a3a..46dbd72adb 100644 --- a/examples/blog/pages/posts/code-blocks.mdx +++ b/examples/blog/pages/posts/code-blocks.mdx @@ -42,6 +42,16 @@ object Hello { hello world ``` +## Test with code block default language + +``` +const links = [ + { href: '/settings', label: 'Settings' }, + { href: '/support', label: 'Support' }, + { href: '/license', label: 'License' }, +] +``` + ## Test link in code Link to [`google`](https://google.com) diff --git a/packages/nextra/src/server/rehype-plugins/rehype.ts b/packages/nextra/src/server/rehype-plugins/rehype.ts index f8884724c5..627aed89f0 100644 --- a/packages/nextra/src/server/rehype-plugins/rehype.ts +++ b/packages/nextra/src/server/rehype-plugins/rehype.ts @@ -27,6 +27,9 @@ export const DEFAULT_REHYPE_PRETTY_CODE_OPTIONS: RehypePrettyCodeOptions = { light: 'github-light', dark: 'github-dark' }, + defaultLang: { + block: 'plaintext' + }, getHighlighter(opts) { return getHighlighter({ ...opts,