### Convert between Markdown and Confluence Storage Format Source: https://docs.rs/confmark/0.6.0/confmark/index.html Demonstrates basic bidirectional conversion using the Document struct. Requires the confmark crate. ```rust use confmark::Document; // Markdown -> Confluence Storage Format. let xml = Document::from_markdown("# Title").to_confluence(); assert_eq!(xml, "

Title

"); // Confluence Storage Format -> Markdown. let md = Document::from_confluence("

Title

").to_markdown(); assert_eq!(md, "# Title"); ``` -------------------------------- ### Iterate over document blocks Source: https://docs.rs/confmark/0.6.0/confmark/ast/struct.Document.html Use the blocks method to perform a depth-first pre-order traversal of all blocks in the document. ```rust use confmark::{Document, ast::Block}; let doc = Document::from_markdown("# Title\n\n## Section\n\ntext"); let levels: Vec = doc .blocks() .filter_map(|block| match block { Block::Heading { level, .. } => Some(*level), _ => None, }) .collect(); assert_eq!(levels, [1, 2]); ``` -------------------------------- ### Document::to_markdown Source: https://docs.rs/confmark/0.6.0/confmark/index.html Renders the Document object into a Markdown string. ```APIDOC ## Document::to_markdown ### Description Converts the Document AST into a Markdown string. ### Signature `pub fn to_markdown(&self) -> String` ``` -------------------------------- ### Document::to_markdown Source: https://docs.rs/confmark Renders a Document object into a Markdown string. ```APIDOC ## Document::to_markdown ### Description Converts the `Document` AST into a Markdown string. ### Signature `pub fn to_markdown(&self) -> String` ``` -------------------------------- ### Document::to_confluence Source: https://docs.rs/confmark/0.6.0/confmark/index.html Renders the Document object into a Confluence Storage Format string. ```APIDOC ## Document::to_confluence ### Description Converts the Document AST into a Confluence Storage Format (XHTML) string. ### Signature `pub fn to_confluence(&self) -> String` ``` -------------------------------- ### Document::to_confluence Source: https://docs.rs/confmark Renders a Document object into a Confluence Storage Format string. ```APIDOC ## Document::to_confluence ### Description Converts the `Document` AST into a Confluence Storage Format (XHTML) string. ### Signature `pub fn to_confluence(&self) -> String` ``` -------------------------------- ### Macro struct definition Source: https://docs.rs/confmark/0.6.0/confmark/ast/struct.Macro.html The definition of the Macro struct, containing the macro name, parameters, and body. ```rust pub struct Macro { pub name: String, pub params: Vec<(String, String)>, pub body: MacroBody, } ``` -------------------------------- ### Document::from_markdown Source: https://docs.rs/confmark Parses a Markdown string into a Document object. ```APIDOC ## Document::from_markdown ### Description Parses a string containing Markdown (CommonMark + GFM) into a `Document` instance. ### Signature `pub fn from_markdown(input: &str) -> Document` ``` -------------------------------- ### Document::from_markdown Source: https://docs.rs/confmark/0.6.0/confmark/index.html Parses a Markdown string into a Document object. ```APIDOC ## Document::from_markdown ### Description Parses a Markdown (CommonMark + GFM) string into a Document object. ### Signature `pub fn from_markdown(input: &str) -> Document` ### Parameters - **input** (&str) - Required - The Markdown formatted string to parse. ``` -------------------------------- ### Define Document struct Source: https://docs.rs/confmark/0.6.0/confmark/ast/struct.Document.html The core structure representing a document, containing a collection of blocks. ```rust pub struct Document { pub blocks: Vec, } ``` -------------------------------- ### Document::from_confluence Source: https://docs.rs/confmark Parses a Confluence Storage Format (XHTML) string into a Document object. ```APIDOC ## Document::from_confluence ### Description Parses a string containing Confluence Storage Format (XHTML) into a `Document` instance. ### Signature `pub fn from_confluence(input: &str) -> Document` ``` -------------------------------- ### Document::from_confluence Source: https://docs.rs/confmark/0.6.0/confmark/index.html Parses a Confluence Storage Format (XHTML) string into a Document object. ```APIDOC ## Document::from_confluence ### Description Parses a Confluence Storage Format (XHTML) string into a Document object. ### Signature `pub fn from_confluence(input: &str) -> Document` ### Parameters - **input** (&str) - Required - The Confluence Storage Format string to parse. ``` -------------------------------- ### Iterate over document inlines Source: https://docs.rs/confmark/0.6.0/confmark/ast/struct.Document.html Use the inlines method to perform a depth-first pre-order traversal of all inline elements within the document. ```rust use confmark::{ Document, ast::{Inline, LinkTarget}, }; let doc = Document::from_markdown("see [a](https://a.test) and [b](https://b.test)"); let urls: Vec<&str> = doc .inlines() .filter_map(|inline| match inline { Inline::Link { target: Some(LinkTarget::External(url)), .. } => Some(url.as_str()), _ => None, }) .collect(); assert_eq!(urls, ["https://a.test", "https://b.test"]); ``` -------------------------------- ### Define Table struct Source: https://docs.rs/confmark/0.6.0/confmark/ast/struct.Table.html The structure definition for a GFM/Confluence table, containing alignment settings and cell data. ```rust pub struct Table { pub align: Vec, pub head: Vec>, pub rows: Vec>>, } ``` -------------------------------- ### ImageSource Enum Definition Source: https://docs.rs/confmark/0.6.0/confmark/ast/enum.ImageSource.html The enum structure defining the two possible sources for an image. ```rust pub enum ImageSource { External(String), Attachment(String), } ``` -------------------------------- ### Task Struct Definition Source: https://docs.rs/confmark/0.6.0/confmark/ast/struct.Task.html The definition of the Task struct, which includes a checked status and content elements. ```rust pub struct Task { pub checked: bool, pub content: Vec, } ``` -------------------------------- ### Alignment Enum Definition Source: https://docs.rs/confmark/0.6.0/confmark/ast/enum.Alignment.html The core enum structure defining the available alignment variants. ```rust pub enum Alignment { None, Left, Center, Right, } ``` -------------------------------- ### Inline Enum Definition Source: https://docs.rs/confmark/0.6.0/confmark/ast/enum.Inline.html The primary enum structure defining all supported inline elements. ```rust pub enum Inline { Text(String), Strong(Vec), Emphasis(Vec), Strikethrough(Vec), Code(String), Link { target: Option, anchor: Option, title: Option, content: Vec, }, Image { source: ImageSource, alt: String, width: Option, height: Option, }, SoftBreak, HardBreak, Macro(Macro), RawConfluence(String), } ``` -------------------------------- ### Block Enum Definition Source: https://docs.rs/confmark/0.6.0/confmark/ast/enum.Block.html The primary enum structure defining various block types supported by the AST. ```rust pub enum Block { Heading { level: u8, content: Vec, }, Paragraph(Vec), CodeBlock { language: Option, code: String, }, List { ordered: bool, items: Vec>, }, TaskList(Vec), BlockQuote(Vec), Table(Table), ThematicBreak, Macro(Macro), RawConfluence(String), } ``` -------------------------------- ### LinkTarget Enum Definition Source: https://docs.rs/confmark/0.6.0/confmark/ast/enum.LinkTarget.html Defines the structure of LinkTarget variants, representing different types of Confluence resources. ```rust pub enum LinkTarget { External(String), Page { space: Option, title: String, content_id: Option, }, BlogPost { space: Option, title: String, posting_day: String, }, Content(String), Attachment { filename: String, parent: Option>, }, User { account_id: Option, userkey: Option, }, Space(String), Shortcut { key: String, parameter: Option, }, } ``` -------------------------------- ### MacroBody Enum Definition Source: https://docs.rs/confmark/0.6.0/confmark/ast/enum.MacroBody.html The definition of the MacroBody enum, which supports empty, plain text, and rich text variants. ```rust pub enum MacroBody { Empty, PlainText(String), RichText(Vec), } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.