Core & UI: Remove placeholder space for codeblocks

This commit is contained in:
Fuma Nama
2025-05-06 18:01:27 +08:00
parent ec470e5d8a
commit 50db8746b5
6 changed files with 8 additions and 30 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'fumadocs-core': patch
'fumadocs-ui': patch
---
Remove placeholder space for codeblocks
-1
View File
@@ -1,6 +1,5 @@
export {
highlight,
createStyleTransformer,
getHighlighter,
type HighlightOptions,
type HighlightOptionsCommon,
-17
View File
@@ -7,7 +7,6 @@ import {
type CodeToHastOptionsCommon,
type Highlighter,
type RegexEngine,
type ShikiTransformer,
} from 'shiki';
import type { BundledTheme } from 'shiki/themes';
import { type Components, toJsxRuntime } from 'hast-util-to-jsx-runtime';
@@ -15,21 +14,6 @@ import { Fragment, type ReactNode } from 'react';
import { jsx, jsxs } from 'react/jsx-runtime';
import type { Root } from 'hast';
export function createStyleTransformer(): ShikiTransformer {
return {
name: 'rehype-code:styles',
line(hast) {
if (hast.children.length === 0) {
// Keep the empty lines when using grid layout
hast.children.push({
type: 'text',
value: ' ',
});
}
},
};
}
export const defaultThemes = {
light: 'github-light',
dark: 'github-dark',
@@ -71,7 +55,6 @@ export async function _highlight(code: string, options: HighlightOptions) {
lang,
...rest,
...themes,
transformers: [createStyleTransformer(), ...(rest.transformers ?? [])],
defaultColor: 'themes' in themes ? false : undefined,
});
}
+1 -6
View File
@@ -15,11 +15,7 @@ import {
import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
import type { CodeBlockIcon, IconOptions } from './transformer-icon';
import { transformerIcon } from './transformer-icon';
import {
createStyleTransformer,
defaultThemes,
getHighlighter,
} from '@/highlight/shiki';
import { defaultThemes, getHighlighter } from '@/highlight/shiki';
interface MetaValue {
name: string;
@@ -51,7 +47,6 @@ export const rehypeCodeDefaultOptions: RehypeCodeOptions = {
defaultLanguage: 'plaintext',
experimentalJSEngine: false,
transformers: [
createStyleTransformer(),
transformerNotationHighlight({
matchAlgorithm: 'v3',
}),
-5
View File
@@ -1,8 +1,3 @@
.fd-codeblock pre > * {
display: grid;
font-size: 13px;
}
.shiki:not(.not-fumadocs-codeblock *) {
code span {
color: var(--shiki-light);
+1 -1
View File
@@ -48,7 +48,7 @@ export const Pre = forwardRef<HTMLPreElement, HTMLAttributes<HTMLPreElement>>(
return (
<pre
ref={ref}
className={cn('p-4 focus-visible:outline-none', className)}
className={cn('text-[13px] p-4 focus-visible:outline-none', className)}
{...props}
>
{props.children}