Code Demo

About 1 min

Let you insert code demos in your Markdown file.

Config

Syntax

You should use the following syntax:

::: [type]-demo Optional title text

```html
<!-- ↑ use available ones -->
<!-- your code here -->
<!-- you can have multiple code block, but each language must appear only once. -->
```

```json
// json block is for config
{
  // your config here (optional)
}
```

:::

Tips

The json block is optional, for config please see config.

The plugin support three types:

  • normal
  • vue
  • react

Available Languages

You can use different language in your demo block.

When you set language which can not run on browsers, since the plugin is not able to resolve them, so demo display will be disabled. The plugin will only show the code and provide you a button to open it in CodePen.

Available HTML languages:

  • "html" (default)
  • "slim"
  • "haml"
  • "markdown"

You can also use md in code block.

Available JS languages:

  • "javascript" (default)
  • "coffeescript"
  • "babel"
  • "livescript"
  • "typescript"

You can also use js, ts, coffee and ls in code block.

Available CSS languages:

  • "css" (default)
  • "less"
  • "scss"
  • "sass"
  • "stylus"

You can also use styl in code block.

Not Supported Language Demo

A demo using language not supported by browsers
# Title

is very powerful!
const message: string = "VuePress Theme Hope";

document.querySelector("h1").innerHTML = message;
h1 {
  font-style: italic;

  + p {
    color: red;
  }
}
Code
::: normal-demo A normal demo

```md
# Title

is very powerful!
```

```ts
const message: string = "VuePress Theme Hope";

document.querySelector("h1").innerHTML = message;
```

```scss
h1 {
  font-style: italic;

  + p {
    color: red;
  }
}
```

:::
Loading...