Expand description
Convert pulldown-cmark Events back to the string they were parsed from.
This crate provides functions to serialize markdown events back into markdown text format.
§Examples
use pulldown_cmark::Parser;
use pulldown_cmark_to_cmark::cmark;
let input_markdown = "# Hello\n\nWorld!";
let events = Parser::new(input_markdown);
let mut output_markdown = String::new();
cmark(events, &mut output_markdown).unwrap();
assert_eq!(output_markdown, input_markdown);Structs§
- Heading
- Information about a heading’s attributes (id, classes, and other attributes).
- Options
- Configuration for the
cmark_with_options()andcmark_resume_with_options()functions. The defaults should provide decent spacing and most importantly, will provide a faithful rendering of your markdown document particularly when rendering it to HTML. - State
- The state of the
cmark_resume()andcmark_resume_with_options()functions. This does not only allow introspection, but enables the user to halt the serialization at any time, and resume it later.
Enums§
- Alignment
- Similar to Pulldown-Cmark-Alignment, but with required traits for comparison to allow testing.
- Code
Block Kind - The kind of code block being serialized.
- Error
- The error returned by
cmark_resume_with_options()andcmark_resume_with_source_range_and_options(). - Image
Link - The category of image link being serialized.
- Link
Category - The category of link being serialized.
Constants§
- DEFAULT_
CODE_ BLOCK_ TOKEN_ COUNT - Thea mount of code-block tokens one needs to produce a valid fenced code-block.
Functions§
- calculate_
code_ block_ token_ count - Return the
<seen amount of consecutive fenced code-block tokens> + 1that occur within a fenced code-blockevents. - cmark
- As
cmark_with_options(), but with defaultOptions. - cmark_
resume - As
cmark_resume_with_options(), but with defaultOptions. - cmark_
resume_ with_ options - Serialize a stream of pulldown-cmark-Events into a string-backed buffer.
- cmark_
resume_ with_ source_ range - As
cmark_resume_with_source_range_and_options, but with defaultOptions. - cmark_
resume_ with_ source_ range_ and_ options - Serialize a stream of pulldown-cmark-Events while preserving the escape characters in
source. Each input Event is accompanied by an optional Range that maps it back to thesourcestring. - cmark_
with_ options - As
cmark_resume_with_options(), but with theStatefinalized. - cmark_
with_ source_ range - As
cmark_with_source_range_and_options, but with defaultOptions. - cmark_
with_ source_ range_ and_ options - As
cmark_resume_with_source_range_and_options, but with theStatefinalized.