From 2565601af3895713d7da11445e2e5e3748ab1291 Mon Sep 17 00:00:00 2001 From: William Black Date: Fri, 20 Dec 2024 09:16:59 -0700 Subject: [PATCH] fix(theme-common): code block magic comments should support SQL block comments (#10782) --- .../src/utils/codeBlockUtils.ts | 4 +++- .../_dogfooding/_pages tests/code-block-tests.mdx | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts b/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts index 3d545655f673..f93ef96be7c9 100644 --- a/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts +++ b/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts @@ -107,9 +107,11 @@ function getAllMagicCommentDirectiveStyles( case 'lua': case 'haskell': - case 'sql': return getCommentPattern(['lua'], magicCommentDirectives); + case 'sql': + return getCommentPattern(['lua', 'jsBlock'], magicCommentDirectives); + case 'wasm': return getCommentPattern(['wasm'], magicCommentDirectives); diff --git a/website/_dogfooding/_pages tests/code-block-tests.mdx b/website/_dogfooding/_pages tests/code-block-tests.mdx index 6c294b11c38a..83454500f7b2 100644 --- a/website/_dogfooding/_pages tests/code-block-tests.mdx +++ b/website/_dogfooding/_pages tests/code-block-tests.mdx @@ -358,6 +358,19 @@ WHERE customer_id IN ( ) ``` +```sql title="sql_query_block.sql" +/* highlight-start */ +SELECT * +FROM orders +/* highlight-end */ +WHERE customer_id IN ( + SELECT customer_id + /* highlight-next-line */ + FROM customers + WHERE country = 'USA' +) +``` + ```matlab title="matlab.m" % highlight-start function result = times2(n)