diff --git a/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts b/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts index 16a45f856d84..3d545655f673 100644 --- a/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts +++ b/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts @@ -28,6 +28,7 @@ const commentPatterns = { wasm: {start: '\\;\\;', end: ''}, tex: {start: '%', end: ''}, vb: {start: "['‘’]", end: ''}, + vbnet: {start: "(?:_\\s*)?['‘’]", end: ''}, // Visual Studio 2019 or later rem: {start: '[Rr][Ee][Mm]\\b', end: ''}, f90: {start: '!', end: ''}, // Free format only ml: {start: '\\(\\*', end: '\\*\\)'}, @@ -113,10 +114,11 @@ function getAllMagicCommentDirectiveStyles( return getCommentPattern(['wasm'], magicCommentDirectives); case 'vb': - case 'vbnet': case 'vba': case 'visual-basic': return getCommentPattern(['vb', 'rem'], magicCommentDirectives); + case 'vbnet': + return getCommentPattern(['vbnet', 'rem'], magicCommentDirectives); case 'batch': return getCommentPattern(['rem'], magicCommentDirectives); diff --git a/website/_dogfooding/_pages tests/code-block-tests.mdx b/website/_dogfooding/_pages tests/code-block-tests.mdx index 27e751cfa6cc..6c294b11c38a 100644 --- a/website/_dogfooding/_pages tests/code-block-tests.mdx +++ b/website/_dogfooding/_pages tests/code-block-tests.mdx @@ -384,16 +384,32 @@ y = times2(x); \end{document} ``` -```vbnet title="vbnet.vb" -Dim languages As New Set(Of String) From { +```vba title="vba.vb" +Function Factorial(ByVal n As Long) As Long + If n < 0 Then + Err.Raise 5 ' Invalid argument + End If + 'highlight-next-line + Factorial = 1 ' return value + Dim i As Long ' highlight-start + For i = 2 To n + Factorial = Factorial * i + Next + ' highlight-end +End Function +``` + +```vbnet title="vbnet.vb" +' highlight-next-line +Dim languages As New HashSet(Of String) From { "C#", "Visual Basic", + _ ' highlight-start "F#", - ' highlight-end "PowerShell", - ' highlight-next-line "TypeScript" + _' highlight-end } ```