canonicalize

Function canonicalize 

Source
pub fn canonicalize(input: &str) -> String
Expand description

Canonicalize (or format) a Markdown input by parsing and then converting back to a string.

⚠️ Warning ⚠️: This function is semver exempt. The precise canonicalization behavior may change in MINOR or PATCH versions of markdown-ast. (Stabilizing the behavior of this function will require additional options to configure the behavior of pulldown-cmark-to-cmark.)

§Examples

List items using - (minus) are canonicalized to the * (asterisk) list marker type:

use markdown_ast::canonicalize;
assert_eq!(
canonicalize("\
- Foo
- Bar
"),
"\
* Foo

* Bar"
)

Hard breaks ending in backslash are canonicalized to the “two spaces at the end of the line” form:

use markdown_ast::canonicalize;
assert_eq!(
canonicalize(r#"
This ends in a hard break.\
This is a new line."#),
// Note: The two spaces at the end of the first line below may not be
//       visible, but they're there.
"\
This ends in a hard break.  
This is a new line."
)