From 59ebfca815fc482f624cd3cf1c40c78bd7640623 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 21 Jun 2022 18:15:51 +0200 Subject: Add docs for `default_line_ending` --- src/compiler.rs | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'src/compiler.rs') diff --git a/src/compiler.rs b/src/compiler.rs index f51305b..e6275f1 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -105,7 +105,47 @@ pub struct Options { /// ``` pub allow_dangerous_protocol: bool, - /// To do. + /// Default line ending to use, for line endings not in `value`. + /// + /// Generally, micromark copies line endings (`\r`, `\n`, `\r\n`) in the + /// markdown document over to the compiled HTML. + /// In some cases, such as `> a`, CommonMark requires that extra line + /// endings are added: `
\n

a

\n
`. + /// + /// To create that line ending, the document is checked for the first line + /// ending that is used. + /// If there is no line ending, `default_line_ending` is used. + /// If that isn’t configured, `\n` is used. + /// + /// ## Examples + /// + /// ```rust + /// use micromark::{micromark, micromark_with_options, Options, LineEnding}; + /// + /// // micromark is safe by default: + /// assert_eq!( + /// micromark("> a"), + /// // To do: block quote + /// // "
\n

a

\n
" + /// "

> a

" + /// ); + /// + /// // Define `default_line_ending` to configure the default: + /// assert_eq!( + /// micromark_with_options( + /// "> a", + /// &Options { + /// allow_dangerous_html: false, + /// allow_dangerous_protocol: false, + /// default_line_ending: Some(LineEnding::CarriageReturnLineFeed), + /// + /// } + /// ), + /// // To do: block quote + /// // "
\r\n

a

\r\n
" + /// "

> a

" + /// ); + /// ``` pub default_line_ending: Option, } -- cgit