Skip to main content

normalize

Function normalize 

Source
pub fn normalize(input: &str) -> Cow<'_, str>
Expand description

Normalize line endings for parsing. Converts \r\n to \n and bare \r (classic Mac) to \n. Returns the input borrowed if no carriage returns are found.

Use this before MarkdownFile::parse when the input may contain CRLF line endings:

let input = "# Hello\r\nWorld";
let normalized = marki_parse::normalize(input);
let md: marki_parse::MarkdownFile<'_> = marki_parse::MarkdownFile::parse(&normalized);