Skip to content

Commit

Permalink
tests: add dogfooding code-block-tests for magicComments
Browse files Browse the repository at this point in the history
  • Loading branch information
dotslashtarun committed Apr 13, 2023
1 parent f878bc0 commit 62358fc
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
45 changes: 45 additions & 0 deletions website/_dogfooding/_pages tests/code-block-tests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
```

0 comments on commit 62358fc

Please sign in to comment.