Run code fences in your markdown.
npm install @leptosia/docute-run-codeRun code fences in your markdown.
First load this plugin via tag:
``html`
This plugin is exposed as window.docuteRunCode:
`js`
new Docute({
// ...
plugins: [
docuteRunCode()
]
})
Then in code fences, you can use // @run-code comment to indicate that it's runnable:
``markdown
Here's a demo for HTM:
`js
// @run-code
import { html, Component, render } from 'https://unpkg.com/htm/preact/standalone.mjs';
class App extends Component {
addTodo() {
const { todos = [] } = this.state;
this.setState({ todos: todos.concat(Item ${todos.length}) });
}
render({ page }, { todos = [] }) {
return html
- ${todo}
)};
}
}
const Header = ({ name }) => htmlconst Footer = props => html
render(html
<${App} page="All" />, document.body);
`
``$3
- js: with
// @run-code comment
- javascript: with // @run-code comment
- html: with commentOptions
$3
- Type:
boolean
- Default: undefinedFor
js or javascript code fences, the code will be wrapped in