docsy_markdown 0.1.3
docsy_markdown: ^0.1.3 copied to clipboard
Markdown import and export support for Docsy, the modular Flutter WYSIWYG editor. Convert documents seamlessly between Docsy and Markdown.
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.
Features #
- Export
DocumentRootto 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**

License #
MIT License. See LICENSE.