Docsy Markdown

The Docsy Markdown package provides Markdown import and export for the Docsy editor. It converts a DocumentRoot to Markdown and parses Markdown back into Docsy blocks.

Try it Live

Features

  • Export DocumentRoot to Markdown
  • Import Markdown back into Docsy
  • Supports paragraphs, headings, quotes, lists, dividers, code blocks, inline formatting, links, and image embeds
  • Uses Markdown syntax when possible
  • Falls back to HTML <img> output when image width or height must be preserved

Installation

Add this to your pubspec.yaml:

dependencies:
  docsy_markdown: ^0.1.3

Usage

import 'package:docsy/docsy.dart';
import 'package:docsy_markdown/docsy_markdown.dart';

void main() {
  final doc = DocumentRoot(
    blocks: [
      ParagraphNode(
        inlines: const [
          TextSpanNode('Hello '),
          TextSpanNode('world', marks: TextMarks(bold: true)),
        ],
      ),
      EmbedNode(
        kind: 'image',
        data: const {
          'src': 'https://example.com/image.png',
          'alt': 'Example image',
        },
      ),
    ],
  );

  final markdown = DocsyMarkdownCodec().encode(doc);
  final roundTrip = DocsyMarkdownCodec().decode(markdown);

  print(markdown);
  print(roundTrip.blocks.length);
}

Example

Hello **world**

![Example image](https://example.com/image.png)

License

MIT License. See LICENSE.

Libraries

docsy_markdown