Export to Markdown or text, and import text as nodes (stage 9c)

:export md writes the document as Markdown headings in the clipboard's
format (the user's pick): # for the root and each loose node, ## for
their children, down to ######, the tags between --- lines, then the
body. :export txt writes an indented outline, tags after each title and
the body under it after "| " (the user's pick), from the new
storage::plain_text. The file goes next to the document, named after it,
or where it's told; as vim's :w to another file does, an existing file
needs :export! (the user's pick). Typed in visual mode, :export writes
just the selection, named after its first branch (the user's pick).

:import file reads Markdown headings, a list or indented lines with the
clipboard's reader, now also taking #tags at the end of a line and "| "
body lines, so a text export reads back whole. The nodes go under the
cursor's node, laid out as a mind map, as one undo step (the user's
pick).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
skkeyeandClaude Opus 5.5 committed 2026-10-02 11:46:04 -04:00
1 parent 5888d143fd
commit 9d15a054f2
14 files changed
+407 -33

No files matched your search

+9 -2
View File
@@ -109,7 +109,10 @@ pub enum Call {
Export {
format: ExportFormat,
path: Option<String>,
/// `:export!`: write over a file that's there.
force: bool,
},
Import(String),
}
/// What the command line can name, from the app: names are checked against
@@ -265,7 +268,10 @@ fn build(spec: &Spec, bang: bool, args: &[Option<&str>], sources: &Sources) -> R
Id::Help => Call::Help(first.map(str::to_string)),
Id::Version => Call::Version,
Id::Theme => Call::Theme(exactly("theme", text, &sources.themes)?.to_string()),
Id::Export => Call::Export { format: export_format(text)?, path: second.map(str::to_string) },
Id::Export => {
Call::Export { format: export_format(text)?, path: second.map(str::to_string), force: bang }
}
Id::Import => Call::Import(text.to_string()),
})
}
@@ -471,7 +477,7 @@ mod tests {
assert_eq!(call("color none"), Ok(Call::Color(None)));
assert_eq!(
call("export md out.md"),
Ok(Call::Export { format: ExportFormat::Markdown, path: Some("out.md".into()) })
Ok(Call::Export { format: ExportFormat::Markdown, path: Some("out.md".into()), force: false })
);
}
@@ -543,6 +549,7 @@ mod tests {
("set", "mouse"),
("theme", "light"),
("export", "md"),
("import", "plants.md"),
];
for spec in registry::SPECS {
let argument =