pulldown-cmark-codeblock
Extract Markdown code blocks from Markdown documents parsed with
pulldown-cmark.
pulldown-cmark already exposes the fenced code block info string through
Event::Start(Tag::CodeBlock(CodeBlockKind::Fenced(info_string))). This crate
builds on top of that lower-level event stream and returns complete,
ready-to-use code block records.
- fenced or indented block kind
- language parsed from the first info string word
- raw info string
- remaining attributes as a raw string or token iterator
- code block source text
- byte range covering the whole block
- zero-based line range covering the whole block
- indentation before the opening marker
use ;
let markdown = "# Title\n\n```rust runnable key=value\nfn main() {}\n```\n";
let block = code_blocks.next.unwrap;
assert!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
The detailed API documentation is written in src/lib.rs with crate-level
//! rustdoc comments, so it is generated directly by cargo doc and
published with the crate documentation.