Skip to main content

Crate turndown_cdp

Crate turndown_cdp 

Source
Expand description

§turndown-cdp

Convert CDP-style DOM nodes to Markdown.

This is a Rust implementation inspired by turndown, providing a similar API for converting DOM trees to Markdown.

§Design

This library accepts a CDP-style DOM Node structure (matching Chrome DevTools Protocol). This design allows:

  • Zero parsing overhead: When DOM is already available (e.g., from CDP/chromiumoxide)
  • Parser agnostic: Any HTML parser can convert to the Node structure
  • Minimal dependencies: No HTML parser bundled

§Example

use turndown_cdp::{TurndownService, Node};

let service = TurndownService::new();

// Create a simple DOM tree
let mut h1 = Node::element("h1");
h1.add_child(Node::text("Hello World"));

let markdown = service.turndown(&h1).unwrap();
assert!(markdown.contains("Hello World"));

Re-exports§

pub use node::Node;
pub use node::NodeRef;
pub use node::NodeType;

Modules§

node
CDP-style DOM Node structure for HTML to Markdown conversion.

Structs§

TurndownOptions
Options for Markdown serialization
TurndownService
The main service for converting DOM nodes to Markdown

Enums§

CodeBlockStyle
Code block style options
HeadingStyle
Heading style options
LinkReferenceStyle
Reference style for referenced links
LinkStyle
Link style options
TurndownError
Error type for turndown operations

Type Aliases§

Result