Expand description
A Notion-style block document model, with markdown as the wire form.
let doc = markdown::parse("# Title\n\n- a\n- b");
assert_eq!(doc.blocks.len(), 3);
assert_eq!(markdown::serialize(&doc), "# Title\n\n- a\n- b");The model is a flat list of blocks with an indent level (Doc), not a
nested tree — Notion’s shape rather than CommonMark’s, chosen because
editing a flat list is list operations while editing a tree is restructuring.
[parse] and [serialize] are inverses up to a fixed point: parsing,
serializing and parsing again always lands on the same document, so an
edit/save cycle cannot drift.
doc, [parse], [serialize], select and edit are pure — no
gpui, no painting — and [render] is the gpui layer over them, caret and
selection included for a caller that owns them. The editing surface is the
editor crate.
An image at an http URL — a picture, a favicon, a bookmark’s cover —
needs an http client on the app, which gpui_platform::application installs
and a hand-built gpui::Application does not. gpui’s own default is a
NullHttpClient, and the failure is silent: the element paints the same
fallback it would show while a fetch was still in flight.
Re-exports§
pub use doc::Align;pub use doc::Block;pub use doc::BlockKind;pub use doc::Doc;pub use doc::Form;pub use doc::Mark;pub use doc::MarkSpan;pub use doc::Part;pub use doc::Text;pub use edit::Shortcut;pub use edit::shortcut;pub use highlight::Highlighter;pub use highlight::languages;pub use highlight::set_highlighter;pub use parse::is_image;pub use parse::is_url;pub use parse::parse;pub use preview::LinkPreview;pub use preview::Preview;pub use preview::set_link_preview;pub use render::BlockLayouts;pub use render::markdown;pub use render::render;pub use render::render_with_selection;pub use select::Cursor;pub use select::Selection;pub use serialize::serialize;