Skip to content

Repository files navigation

remark-code-example

Remark plugin to copy live code block as code example.

npmgithubnode

Installation

npm install remark remark-code-example --save-dev

Usage

importreadFileSyncfrom'node:fs';import{remark}from'remark';import{remarkCodeExample}from'remark-code-example';constmarkdownText=readFileSync('example.md','utf8');remark().use(remarkCodeSample,{}).process(markdownText).then((file)=>console.info(file)).catch((error)=>console.warn(error));

Options.metas

  • type: object of string
  • default: {}
  • required: false
  • description: Metas of example code block

Syntax

code-example

Turn
```mermaid code-exampleflowchart Start --> Stop```
Into
````markdown```mermaidflowchart Start --> Stop```````

code-example-copy

Turn
```mermaid code-example-copyflowchart Start --> Stop```
Into
```mermaidflowchart Start --> Stop```````markdown```mermaidflowchart Start --> Stop```````

code-alias-copy

Turn
```mermaid code-alias-copy=diagramflowchart Start --> Stop```
Into
```mermaidflowchart Start --> Stop``````diagramflowchart Start --> Stop```

Related

About

Remark plugin to copy live code block as code sample.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages