diff --git a/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts b/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts index 6886aff6ecb7..1b3badeb04aa 100644 --- a/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts +++ b/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts @@ -87,13 +87,14 @@ function getAllMagicCommentDirectiveStyles( case 'lua': case 'haskell': + case 'sql': return getCommentPattern(['lua'], magicCommentDirectives); case 'wasm': return getCommentPattern(['wasm'], magicCommentDirectives); default: - // All comment types except Lua + // All comment types except lua and wasm return getCommentPattern( Object.keys(commentPatterns).filter( (pattern) => !['lua', 'wasm'].includes(pattern), diff --git a/website/_dogfooding/_pages tests/code-block-tests.mdx b/website/_dogfooding/_pages tests/code-block-tests.mdx index 2c955e110cb4..300cf6b29d96 100644 --- a/website/_dogfooding/_pages tests/code-block-tests.mdx +++ b/website/_dogfooding/_pages tests/code-block-tests.mdx @@ -267,3 +267,48 @@ export default function MyReactPage() { ); } ``` + +```lua title="lua_sum.lua" +function sum(n) + -- highlight-next-line + local result = 0 + for i = 1, n do + -- highlight-start + result = result + i + end + -- highlight-end + print(result) +end +``` + +```haskell title="haskell.hs" +stringLength :: String -> Int +-- highlight-next-line +stringLength [] = 0 +stringLength (x:xs) = 1 + stringLength xs +``` + +```wasm title="sum_webAssembly.wasm" +(module + ;; highlight-next-line + (func $add (param $a i32) (param $b i32) (result i32) + local.get $a + ;; highlight-start + local.get $b + i32.add) + ;; highlight-end + (export "add" (func $add))) +``` + +```sql title="sql_query.sql" +-- highlight-start +SELECT * +FROM orders +-- highlight-end +WHERE customer_id IN ( + SELECT customer_id + -- highlight-next-line + FROM customers + WHERE country = 'USA' +) +```