pub struct Document { /* private fields */ }Expand description
A parsed Markdown document: a preamble and a tree of sections.
Implementations§
Source§impl Document
impl Document
Sourcepub fn parse(source: impl AsRef<str>) -> Self
pub fn parse(source: impl AsRef<str>) -> Self
Parse Markdown into a navigable document. Always succeeds: text with no headings is simply all preamble.
Sourcepub fn preamble(&self) -> &str
pub fn preamble(&self) -> &str
Content before the first heading. Skills often open with a sentence of orientation; this is it.
Sourcepub fn outline(&self) -> impl Iterator<Item = (usize, &Section)>
pub fn outline(&self) -> impl Iterator<Item = (usize, &Section)>
Every section, depth-first, paired with its nesting depth (0 at the top) — the shape of a table of contents.
let doc = Document::parse("# A\n## B\n# C\n");
let toc: Vec<_> = doc.outline().map(|(d, s)| (d, s.heading())).collect();
assert_eq!(toc, [(0, "A"), (1, "B"), (0, "C")]);Sourcepub fn section<'a>(
&self,
path: impl IntoIterator<Item = &'a str>,
) -> Option<&Section>
pub fn section<'a>( &self, path: impl IntoIterator<Item = &'a str>, ) -> Option<&Section>
Follow a path of heading texts from the top: ["Deploy", "Rollback"]
finds Rollback nested under Deploy. Matching ignores case and
surrounding whitespace.
Sourcepub fn links(&self) -> Vec<Link>
pub fn links(&self) -> Vec<Link>
Every inline link in the document, in order. Targets classified as
LinkTarget::InPackage are the skill’s on-demand resources.
Trait Implementations§
impl Eq for Document
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.