From 1dac7e33f79eacb4368e3e2aa361290e01562b5c Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Tue, 17 Nov 2020 02:18:45 +0300 Subject: [PATCH] fix(v2): add support for interleaving Markdown in code blocks (#3749) * fix(v2): add support for interleaving Markdown in code blocks * Improve check for array --- .../docusaurus-theme-classic/src/theme/CodeBlock/index.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.tsx b/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.tsx index 5b0284abd3..22c5cb52b5 100644 --- a/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.tsx @@ -112,6 +112,11 @@ export default ({ const prismTheme = usePrismTheme(); + // In case interleaved Markdown (e.g. when using CodeBlock as standalone component). + if (Array.isArray(children)) { + children = children.join(''); + } + if (metastring && highlightLinesRangeRegex.test(metastring)) { // Tested above // eslint-disable-next-line @typescript-eslint/no-non-null-assertion