···8585 Self { inner: ast }
8686 }
87878888+ /// Build an AST tree from a [`Vec`] of [`Node`]s
8989+ ///
9090+ /// # Example
9191+ ///
9292+ /// ```rust
9393+ /// // This assertion converts the Gemtext "=> / Home\n" to an AST tree of one
9494+ /// // node, then converts the AST tree back to Gemtext, and compares it against
9595+ /// // the original Gemtext.
9696+ /// assert_eq!(
9797+ /// germ::ast::Ast::from_nodes(
9898+ /// germ::gemini_to_ast!("=> / Home\n").inner().to_vec()
9999+ /// )
100100+ /// .to_gemtext(),
101101+ /// "=> / Home\n"
102102+ /// );
103103+ /// ```
104104+ #[must_use]
105105+ pub fn from_nodes(nodes: Vec<Node>) -> Self { Self { inner: nodes } }
106106+88107 #[must_use]
89108 pub fn to_gemtext(&self) -> String {
90109 let mut gemtext = String::new();
+8
src/ast/node.rs
···171171 /// A whitespace line, a line which contains nothing but whitespace.
172172 Whitespace,
173173}
174174+175175+impl Node {
176176+ /// Obtain the Gemtext content of a single [`Node`] as a [`String`]
177177+ #[must_use]
178178+ pub fn content(&self) -> String {
179179+ super::Ast::from_nodes(vec![self.to_owned()]).to_gemtext()
180180+ }
181181+}