Principle:AFK surf Open agent Layout Normalization
| Knowledge Sources | |
|---|---|
| Domains | Markdown, Import_Export, Layout |
| Last Updated | 2026-10-25 00:00 GMT |
Overview
Pattern of flattening Markdown containing advanced layout directives (multi-column, note splits) into a sequence of portable block snapshots, and re-encoding snapshots back to directive Markdown.
Description
Standard Markdown has no notion of multi-column layouts or document splits. BlockSuite extends Markdown with HTML-comment directives: ' opens a column region, ' directs content into a named column, ' splits the document into a separate note with a title and background, and ' closes a column. The SimpleLayoutConverter parses these directives during forward conversion (markdownToMultipleSnapshots), producing one BlockSnapshot per split note. The reverse (multipleSnapshotsToMarkdown) re-serializes snapshots back to Markdown with the directives re-encoded. Lossy flattening may occur for highly custom layouts.
Usage
Apply this principle when your Markdown source uses layout directives and you need the editor to render multi-column or multi-note layouts, or when you want to verify round-trip fidelity of layout-bearing documents.
Theoretical Basis
The layout directives encode a tree of layout containers (columns, splits) over the linear Markdown. Forward conversion: parse(Markdown + directives) → [BlockSnapshot per split note]. Reverse: [snapshots] → Markdown + directives. The directives are preserved as HTML comments so plain Markdown renderers ignore them.
Pseudo-code:
const snapshots = await SimpleLayoutConverter.markdownToMultipleSnapshots(markdown);
const backToMarkdown = await SimpleLayoutConverter.multipleSnapshotsToMarkdown(snapshots);