diff --git a/docs/guide/page-config.md b/docs/guide/page-config.md index 1c0877d5c2..c7236804ad 100644 --- a/docs/guide/page-config.md +++ b/docs/guide/page-config.md @@ -74,7 +74,7 @@ demo: ``` -配置 `demo.cols` 后,以下多个 demo 完将会被渲染为双栏布局: +配置 `demo.cols` 后,以下用**单个换行符**分隔的 code 标签 demo 会被渲染为双栏布局: ```md 分栏 1 diff --git a/src/loaders/markdown/transformer/fixtures/demo/cols/demo.jsx b/src/loaders/markdown/transformer/fixtures/demo/cols/demo.jsx new file mode 100644 index 0000000000..c73b7bc3aa --- /dev/null +++ b/src/loaders/markdown/transformer/fixtures/demo/cols/demo.jsx @@ -0,0 +1 @@ +export default () => 'demo'; diff --git a/src/loaders/markdown/transformer/fixtures/demo/cols/expect.ts b/src/loaders/markdown/transformer/fixtures/demo/cols/expect.ts new file mode 100644 index 0000000000..fbeccb6311 --- /dev/null +++ b/src/loaders/markdown/transformer/fixtures/demo/cols/expect.ts @@ -0,0 +1,61 @@ +import type { IMdTransformerResult } from '../../..'; + +export default (ret: IMdTransformerResult) => { + expect(ret.content).toMatchInlineSnapshot(` + "<>" + `); +}; diff --git a/src/loaders/markdown/transformer/fixtures/demo/cols/index.md b/src/loaders/markdown/transformer/fixtures/demo/cols/index.md new file mode 100644 index 0000000000..866d920256 --- /dev/null +++ b/src/loaders/markdown/transformer/fixtures/demo/cols/index.md @@ -0,0 +1,17 @@ +--- +demo: + cols: 2 +--- + + + +分栏 1 +分栏 2 +分栏 3 +分栏 4 + + + +bad 分栏 1 + +bad 分栏 2 diff --git a/src/loaders/markdown/transformer/rehypeDemo.ts b/src/loaders/markdown/transformer/rehypeDemo.ts index 9bbfec2ecc..1fc6eafc81 100644 --- a/src/loaders/markdown/transformer/rehypeDemo.ts +++ b/src/loaders/markdown/transformer/rehypeDemo.ts @@ -319,11 +319,8 @@ export default function rehypeDemo( ) { const startLine = node.position?.start.line; const suffix = startLine ? `:${startLine}` : ''; - - logger.warn( - `Duplicate demo id found due to filename conflicts, please consider adding a unique id to code tag to resolve this. - at ${opts.fileAbsPath}${suffix}`, - ); + // prettier-ignore + logger.warn(`Duplicate demo id found due to filename conflicts, please consider adding a unique id to code tag to resolve this. at ${opts.fileAbsPath}${suffix}`); } // eslint-disable-next-line @typescript-eslint/no-unused-vars