Skip to main content

Custom tool

To support custom scenario, you can provide a compile function and wire it up as you please.

In this example, we use cowsay to create silly looking cows.

./docusaurus.config.js
const { say } = require("cowsay")

...
compileCode: {
langs: [
...,
{
lang: "cowsay",
compile: async (text, langOptions) => ({
stdout: say({ text })
})
}
]}

Let's take a look at this example in action.

```cowsay
hello
```

When rendered in the docs, this snippet looks like any other code snippe. But you'll also notice an additional box underneath with the capitalized text.

http://localhost:3000
hello
Output
 _______
< hello >
-------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||