From ec2d1bfb4232178fb3a6cba36f138bc6efbbf34a Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 13 Oct 2022 10:40:01 +0200 Subject: Rename crate to `markdown` --- src/lib.rs | 168 ++++++++++++++++++++------------------- src/subtokenize.rs | 2 +- src/to_html.rs | 2 +- src/util/character_reference.rs | 6 +- src/util/encode.rs | 2 +- src/util/gfm_tagfilter.rs | 2 +- src/util/normalize_identifier.rs | 2 +- src/util/sanitize_uri.rs | 6 +- src/util/slice.rs | 2 +- 9 files changed, 97 insertions(+), 95 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 365127f..dc429c6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,15 +1,15 @@ -//! Public API of micromark. +//! Public API of `markdown-rs`. //! -//! This module exposes primarily [`micromark`][]. -//! It also exposes [`micromark_with_options`][] and [`micromark_to_mdast`][]. +//! This module exposes primarily [`to_html()`][]. +//! It also exposes [`to_html_with_options()`][] and [`to_mdast()`][]. //! -//! * [`micromark`][] +//! * [`to_html()`][] //! — safe way to transform (untrusted?) markdown into HTML -//! * [`micromark_with_options`][] -//! — like `micromark` but lets you configure how markdown is turned into -//! HTML, such as allowing dangerous HTML or turning on/off -//! different constructs (GFM, MDX, and the like) -//! * [`micromark_to_mdast`][] +//! * [`to_html_with_options()`][] +//! — like `to_html` but lets you configure how markdown is turned into +//! HTML, such as allowing dangerous HTML or turning on/off different +//! constructs (GFM, MDX, and the like) +//! * [`to_mdast()`][] //! — turn markdown into a syntax tree #![no_std] #![deny(clippy::pedantic)] @@ -37,8 +37,6 @@ mod util; use alloc::{boxed::Box, fmt, string::String}; use mdast::Node; use parser::parse; -use to_html::compile as to_html; -use to_mdast::compile as to_mdast; #[doc(hidden)] // Do not use: exported for quick prototyping, will be removed. @@ -60,7 +58,7 @@ pub use util::location::Location; /// ## Examples /// /// ``` -/// use micromark::LineEnding; +/// use markdown::LineEnding; /// # fn main() { /// /// // Use a CR + LF combination: @@ -128,7 +126,7 @@ impl LineEnding { pub enum MdxSignal { /// A syntax error. /// - /// `micromark-rs` will crash with error message `String`, and convert the + /// `markdown-rs` will crash with error message `String`, and convert the /// `usize` (byte offset into `&str` passed to `MdxExpressionParse` or /// `MdxEsmParse`) to where it happened in the whole document. /// @@ -140,7 +138,7 @@ pub enum MdxSignal { Error(String, usize), /// An error at the end of the (partial?) expression. /// - /// `micromark-rs` will either crash with error message `String` if it + /// `markdown-rs` will either crash with error message `String` if it /// doesn’t have any more text, or it will try again later when more text /// is available. /// @@ -152,7 +150,7 @@ pub enum MdxSignal { Eof(String), /// Done, successfully. /// - /// `micromark-rs` knows that this is the end of a valid expression/esm and + /// `markdown-rs` knows that this is the end of a valid expression/esm and /// continues with markdown. /// /// ## Examples @@ -213,7 +211,7 @@ pub type MdxExpressionParse = dyn Fn(&str, &MdxExpressionKind) -> MdxSignal; /// ## Examples /// /// ``` -/// use micromark::Constructs; +/// use markdown::Constructs; /// # fn main() { /// /// // Use the default trait to get `CommonMark` constructs: @@ -641,7 +639,7 @@ impl Constructs { /// ## Examples /// /// ``` -/// use micromark::CompileOptions; +/// use markdown::CompileOptions; /// # fn main() { /// /// // Use the default trait to get safe defaults: @@ -675,18 +673,18 @@ pub struct CompileOptions { /// ## Examples /// /// ``` - /// use micromark::{micromark, micromark_with_options, CompileOptions, Options}; + /// use markdown::{to_html, to_html_with_options, CompileOptions, Options}; /// # fn main() -> Result<(), String> { /// - /// // micromark is safe by default: + /// // `markdown-rs` is safe by default: /// assert_eq!( - /// micromark("Hi, venus!"), + /// to_html("Hi, venus!"), /// "

Hi, <i>venus</i>!

" /// ); /// /// // Turn `allow_dangerous_html` on to allow potentially dangerous HTML: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "Hi, venus!", /// &Options { /// compile: CompileOptions { @@ -719,18 +717,18 @@ pub struct CompileOptions { /// ## Examples /// /// ``` - /// use micromark::{micromark, micromark_with_options, CompileOptions, Options}; + /// use markdown::{to_html, to_html_with_options, CompileOptions, Options}; /// # fn main() -> Result<(), String> { /// - /// // micromark is safe by default: + /// // `markdown-rs` is safe by default: /// assert_eq!( - /// micromark(""), + /// to_html(""), /// "

javascript:alert(1)

" /// ); /// /// // Turn `allow_dangerous_protocol` on to allow potentially dangerous protocols: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "", /// &Options { /// compile: CompileOptions { @@ -750,8 +748,8 @@ pub struct CompileOptions { /// Default line ending to use when compiling to HTML, for line endings not /// in `value`. /// - /// Generally, micromark copies line endings (`\r`, `\n`, `\r\n`) in the - /// markdown document over to the compiled HTML. + /// Generally, `markdown-rs` 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
`. /// @@ -763,18 +761,18 @@ pub struct CompileOptions { /// ## Examples /// /// ``` - /// use micromark::{micromark, micromark_with_options, CompileOptions, LineEnding, Options}; + /// use markdown::{to_html, to_html_with_options, CompileOptions, LineEnding, Options}; /// # fn main() -> Result<(), String> { /// - /// // micromark uses `\n` by default: + /// // `markdown-rs` uses `\n` by default: /// assert_eq!( - /// micromark("> a"), + /// to_html("> a"), /// "
\n

a

\n
" /// ); /// /// // Define `default_line_ending` to configure the default: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "> a", /// &Options { /// compile: CompileOptions { @@ -805,12 +803,12 @@ pub struct CompileOptions { /// ## Examples /// /// ``` - /// use micromark::{micromark, micromark_with_options, CompileOptions, Options, ParseOptions}; + /// use markdown::{to_html_with_options, CompileOptions, Options, ParseOptions}; /// # fn main() -> Result<(), String> { /// /// // `"Footnotes"` is used by default: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "[^a]\n\n[^a]: b", /// &Options::gfm() /// )?, @@ -819,7 +817,7 @@ pub struct CompileOptions { /// /// // Pass `gfm_footnote_label` to use something else: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "[^a]\n\n[^a]: b", /// &Options { /// parse: ParseOptions::gfm(), @@ -850,12 +848,12 @@ pub struct CompileOptions { /// ## Examples /// /// ``` - /// use micromark::{micromark, micromark_with_options, CompileOptions, Options, ParseOptions}; + /// use markdown::{to_html_with_options, CompileOptions, Options, ParseOptions}; /// # fn main() -> Result<(), String> { /// /// // `"h2"` is used by default: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "[^a]\n\n[^a]: b", /// &Options::gfm() /// )?, @@ -864,7 +862,7 @@ pub struct CompileOptions { /// /// // Pass `gfm_footnote_label_tag_name` to use something else: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "[^a]\n\n[^a]: b", /// &Options { /// parse: ParseOptions::gfm(), @@ -898,12 +896,12 @@ pub struct CompileOptions { /// ## Examples /// /// ``` - /// use micromark::{micromark, micromark_with_options, CompileOptions, Options, ParseOptions}; + /// use markdown::{to_html_with_options, CompileOptions, Options, ParseOptions}; /// # fn main() -> Result<(), String> { /// /// // `"class=\"sr-only\""` is used by default: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "[^a]\n\n[^a]: b", /// &Options::gfm() /// )?, @@ -912,7 +910,7 @@ pub struct CompileOptions { /// /// // Pass `gfm_footnote_label_attributes` to use something else: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "[^a]\n\n[^a]: b", /// &Options { /// parse: ParseOptions::gfm(), @@ -941,12 +939,12 @@ pub struct CompileOptions { /// ## Examples /// /// ``` - /// use micromark::{micromark, micromark_with_options, CompileOptions, Options, ParseOptions}; + /// use markdown::{to_html_with_options, CompileOptions, Options, ParseOptions}; /// # fn main() -> Result<(), String> { /// /// // `"Back to content"` is used by default: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "[^a]\n\n[^a]: b", /// &Options::gfm() /// )?, @@ -955,7 +953,7 @@ pub struct CompileOptions { /// /// // Pass `gfm_footnote_back_label` to use something else: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "[^a]\n\n[^a]: b", /// &Options { /// parse: ParseOptions::gfm(), @@ -997,12 +995,12 @@ pub struct CompileOptions { /// ## Examples /// /// ``` - /// use micromark::{micromark, micromark_with_options, CompileOptions, Options, ParseOptions}; + /// use markdown::{to_html_with_options, CompileOptions, Options, ParseOptions}; /// # fn main() -> Result<(), String> { /// /// // `"user-content-"` is used by default: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "[^a]\n\n[^a]: b", /// &Options::gfm() /// )?, @@ -1011,7 +1009,7 @@ pub struct CompileOptions { /// /// // Pass `gfm_footnote_clobber_prefix` to use something else: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "[^a]\n\n[^a]: b", /// &Options { /// parse: ParseOptions::gfm(), @@ -1041,12 +1039,12 @@ pub struct CompileOptions { /// ## Examples /// /// ``` - /// use micromark::{micromark_with_options, CompileOptions, Options, ParseOptions}; + /// use markdown::{to_html_with_options, CompileOptions, Options, ParseOptions}; /// # fn main() -> Result<(), String> { /// - /// // With `allow_dangerous_html`, micromark passes HTML through untouched: + /// // With `allow_dangerous_html`, `markdown-rs` passes HTML through untouched: /// assert_eq!( - /// micromark_with_options( + /// to_html_with_options( /// "