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 | |
parent | f5bb9ab57b9153775a9ffca7322173ec424d4669 (diff) | |
download | markdown-rs-59ebfca815fc482f624cd3cf1c40c78bd7640623.tar.gz markdown-rs-59ebfca815fc482f624cd3cf1c40c78bd7640623.tar.bz2 markdown-rs-59ebfca815fc482f624cd3cf1c40c78bd7640623.zip |
Add docs for `default_line_ending`
-rw-r--r-- | readme.md | 2 | ||||
-rw-r--r-- | src/compiler.rs | 42 |
2 files changed, 42 insertions, 2 deletions
@@ -68,7 +68,6 @@ cargo doc --document-private-items #### Docs -- [ ] (1) Add docs for `default_line_ending` - [ ] (1) Add docs for virtual spaces - [ ] (1) Add docs to `subtokenize.rs` - [ ] (1) Add docs for `link.rs` @@ -234,6 +233,7 @@ cargo doc --document-private-items `construct/mod.rs`) - [x] (1) Configurable tokens (destination, label, title) - [x] (1) Configurable limit (destination) +- [x] (1) Add docs for `default_line_ending` ### Extensions 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>, } |