From ae1547c5c8d6e0880ba625dac4febbeefecf81ae Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Mon, 15 Mar 2021 18:42:24 +0300 Subject: [PATCH] fix(v2): allow using pre tag in Markdown directly (#4428) --- .../src/theme/MDXComponents/index.tsx | 12 +++++++++--- website/src/pages/examples/markdownPageExample.md | 11 +++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/docusaurus-theme-classic/src/theme/MDXComponents/index.tsx b/packages/docusaurus-theme-classic/src/theme/MDXComponents/index.tsx index 286a86fd5052..e121958d4d6a 100644 --- a/packages/docusaurus-theme-classic/src/theme/MDXComponents/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/MDXComponents/index.tsx @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -import React from 'react'; +import React, {isValidElement} from 'react'; import Link from '@docusaurus/Link'; -import CodeBlock from '@theme/CodeBlock'; +import CodeBlock, {Props} from '@theme/CodeBlock'; import Heading from '@theme/Heading'; import type {MDXComponentsObject} from '@theme/MDXComponents'; @@ -25,7 +25,13 @@ const MDXComponents: MDXComponentsObject = { a: (props) => , pre: (props: any) => { const {children} = props; - return ; + return ( + + ); }, h1: Heading('h1'), h2: Heading('h2'), diff --git a/website/src/pages/examples/markdownPageExample.md b/website/src/pages/examples/markdownPageExample.md index 78f642ab0919..8c92ba3fa0f8 100644 --- a/website/src/pages/examples/markdownPageExample.md +++ b/website/src/pages/examples/markdownPageExample.md @@ -188,4 +188,15 @@ function Clock(props) { test +## direct using of `pre` + +
test
+ + +
+1
+2
+3
+
+ ## Custom heading id {#custom}