# plotwork import

> Page: https://docs.plotwork.dev/cli/commands/import. Index of every page: https://docs.plotwork.dev/llms.txt

Convert Mermaid to Plotwork: a `.mmd` file, or every `mermaid` fence of a Markdown file. It is a command of the Plotwork command line, the npm package `@buun_group/plotwork`.

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Convert Mermaid to Plotwork: a `.mmd` file, or every `mermaid` fence of a Markdown file. |
| How do I run it? | `npx -y @buun_group/plotwork@0.1.0 import`, or `plotwork import` once the package is installed. |
| What does it write? | The source with `--out`, or the Markdown file with `--write`. |
| Does it use the network? | No. It reads and writes files on this machine only. |
| Does it read the repository settings? | No. |
| How do I read this in a terminal? | `plotwork import --help` |

## Synopsis

```sh
plotwork import <file> [--out <file>] [--write] [--format text|json] [--lenient]
```

## What it does

Converts Mermaid to Plotwork. A `.mmd` or `.mermaid` file prints its Plotwork source. A Markdown file is reported on fence by fence, and rewritten only with `--write`; a fence that cannot be converted is left as it was.

Each diagnostic says what was not carried over and how to say it in Plotwork, and the Plotwork validator then checks the result.

## Options

| Option | Default | What it does |
|---|---|---|
| `--out <file>` | standard output | Write the source of a `.mmd` file to a file. |
| `--write` | Off | Rewrite the Markdown file with each fence that converts. |
| `--format text\|json` | `text` | `json` prints the conversion and its diagnostics as data. |
| `--lenient` | Off | Convert what can be converted and report the rest, instead of refusing a diagram with a statement it cannot carry. |

## Examples

Convert one Mermaid file.

```sh
plotwork import flow.mmd --out flow.diagram
```

Convert every mermaid fence of a page that converts, in place.

```sh
plotwork import README.md --write
```

## Exit codes

| Code | When |
|---|---|
| `0` | Everything converted. |
| `1` | A diagram or a fence could not be converted, or the file could not be read. |
| `2` | A mistake in the command line: an unknown option, a missing operand, a file or glob that matches nothing, or a settings file that cannot be read. Also when the file is not `.mmd`, `.mermaid`, or Markdown. |

## See also

| Doc | Why |
|---|---|
| [Command reference](https://docs.plotwork.dev/cli/commands.md) | Every command of the command line |
| [Migrating from Mermaid](https://docs.plotwork.dev/migrating-from-mermaid.md) | What converts and what does not |
| [Exit codes and output formats](https://docs.plotwork.dev/cli/exit-codes-and-output.md) | What every code and format means |
