diff --git a/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.js b/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.js index 21f2a8075502..27e305ad58a6 100644 --- a/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.js +++ b/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.js @@ -102,6 +102,10 @@ export default ({children, className: languageClassName, metastring}) => { {tokens.map((line, i) => { + if (line.length === 1 && line[0].content === '') { + line[0].content = '\n'; // eslint-disable-line no-param-reassign + } + const lineProps = getLineProps({line, key: i}); if (highlightLines.includes(i + 1)) { diff --git a/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.js b/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.js index 1dffcb8e9fa3..32cdd033c6de 100644 --- a/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.js +++ b/packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.js @@ -121,6 +121,10 @@ export default ({ {tokens.map((line, i) => { + if (line.length === 1 && line[0].content === '') { + line[0].content = '\n'; // eslint-disable-line no-param-reassign + } + const lineProps = getLineProps({line, key: i}); if (highlightLines.includes(i + 1)) {