remark-code-example

0.5.4 • Public • Published

remark-code-example

Remark plugin to copy live code block as code example.

npm github node

Installation

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

Usage

import readFileSync from 'node:fs';

import { remark } from 'remark';
import { remarkCodeExample } from 'remark-code-example';

const markdownText = 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-example
flowchart
  Start --> Stop
```

Into

````markdown
```mermaid
flowchart
  Start --> Stop
```
````

code-example-copy

Turn

```mermaid code-example-copy
flowchart
  Start --> Stop
```

Into

```mermaid
flowchart
  Start --> Stop
```

````markdown
```mermaid
flowchart
  Start --> Stop
```
````

code-alias-copy

Turn

```mermaid code-alias-copy=diagram
flowchart
  Start --> Stop
```

Into

```mermaid
flowchart
  Start --> Stop
```

```diagram
flowchart
  Start --> Stop
```

Dependents (0)

Package Sidebar

Install

npm i remark-code-example

Weekly Downloads

0

Version

0.5.4

License

MIT

Unpacked Size

7.4 kB

Total Files

4

Last publish

Collaborators

  • airkro