Crate pulldown_cmark_to_cmark

Crate pulldown_cmark_to_cmark 

Source
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() and cmark_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() and cmark_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.
CodeBlockKind
The kind of code block being serialized.
Error
The error returned by cmark_resume_with_options() and cmark_resume_with_source_range_and_options().
ImageLink
The category of image link being serialized.
LinkCategory
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> + 1 that occur within a fenced code-block events.
cmark
As cmark_with_options(), but with default Options.
cmark_resume
As cmark_resume_with_options(), but with default Options.
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 default Options.
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 the source string.
cmark_with_options
As cmark_resume_with_options(), but with the State finalized.
cmark_with_source_range
As cmark_with_source_range_and_options, but with default Options.
cmark_with_source_range_and_options
As cmark_resume_with_source_range_and_options, but with the State finalized.