From d51afb0b70c4a408f06ceb4a3ca756d2f7b29b3d Mon Sep 17 00:00:00 2001 From: duanwilliam <38791932+duanwilliam@users.noreply.github.com> Date: Mon, 28 Mar 2022 17:21:06 -0700 Subject: [PATCH 1/2] docs: fix code block line highlighting in md syntax highlighting --- website/docs/guides/docs/sidebar/autogenerated.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/guides/docs/sidebar/autogenerated.md b/website/docs/guides/docs/sidebar/autogenerated.md index 239888b99f30..85a9082a0721 100644 --- a/website/docs/guides/docs/sidebar/autogenerated.md +++ b/website/docs/guides/docs/sidebar/autogenerated.md @@ -311,11 +311,11 @@ For handwritten sidebar definitions, you would provide metadata to sidebar items ```md title="docs/tutorials/tutorial-easy.md" --- -# highlight-start +// highlight-start sidebar_position: 2 sidebar_label: Easy sidebar_class_name: green -# highlight-end +// highlight-end --- # Easy Tutorial From 50c5e2647d3150db9cdd54d22f278626ff0031e4 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Tue, 29 Mar 2022 08:55:06 +0800 Subject: [PATCH 2/2] properly fix --- .../docusaurus-theme-common/src/utils/codeBlockUtils.ts | 8 +++++--- website/docs/guides/docs/sidebar/autogenerated.md | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts b/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts index dbc24112151c..cc28c5d21feb 100644 --- a/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts +++ b/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts @@ -15,7 +15,7 @@ const commentPatterns = { js: {start: '\\/\\/', end: ''}, jsBlock: {start: '\\/\\*', end: '\\*\\/'}, jsx: {start: '\\{\\s*\\/\\*', end: '\\*\\/\\s*\\}'}, - python: {start: '#', end: ''}, + bash: {start: '#', end: ''}, html: {start: ''}, }; @@ -59,11 +59,13 @@ function getAllMagicCommentDirectiveStyles(lang: string) { case 'python': case 'py': - return getCommentPattern(['python']); + case 'bash': + return getCommentPattern(['bash']); case 'markdown': case 'md': - return getCommentPattern(['html', 'jsx']); + // Text uses HTML, front matter uses bash + return getCommentPattern(['html', 'jsx', 'bash']); default: // all comment types diff --git a/website/docs/guides/docs/sidebar/autogenerated.md b/website/docs/guides/docs/sidebar/autogenerated.md index 85a9082a0721..239888b99f30 100644 --- a/website/docs/guides/docs/sidebar/autogenerated.md +++ b/website/docs/guides/docs/sidebar/autogenerated.md @@ -311,11 +311,11 @@ For handwritten sidebar definitions, you would provide metadata to sidebar items ```md title="docs/tutorials/tutorial-easy.md" --- -// highlight-start +# highlight-start sidebar_position: 2 sidebar_label: Easy sidebar_class_name: green -// highlight-end +# highlight-end --- # Easy Tutorial