diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-06-21 18:15:51 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-06-21 18:21:51 +0200 |
commit | 59ebfca815fc482f624cd3cf1c40c78bd7640623 (patch) | |
tree | 91bbc033ce9acdba797ffaa7e8367995f55dfde3 /src | |
parent | f5bb9ab57b9153775a9ffca7322173ec424d4669 (diff) | |
download | markdown-rs-59ebfca815fc482f624cd3cf1c40c78bd7640623.tar.gz markdown-rs-59ebfca815fc482f624cd3cf1c40c78bd7640623.tar.bz2 markdown-rs-59ebfca815fc482f624cd3cf1c40c78bd7640623.zip |
Add docs for `default_line_ending`
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler.rs | 42 |
1 files changed, 41 insertions, 1 deletions
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: `<blockquote>\n<p>a</p>\n</blockquote>`. + /// + /// 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 + /// // "<blockquote>\n<p>a</p>\n</blockquote>" + /// "<p>> a</p>" + /// ); + /// + /// // 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 + /// // "<blockquote>\r\n<p>a</p>\r\n</blockquote>" + /// "<p>> a</p>" + /// ); + /// ``` pub default_line_ending: Option<LineEnding>, } |