From 1d8e2b373b5e347a89f05e36c73b04487e04bead Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 11 Oct 2022 14:06:50 +0200 Subject: Refactor some hidden internals --- src/lib.rs | 34 +++++++++------------------------- src/util/identifier.rs | 2 ++ src/util/sanitize_uri.rs | 4 ++-- 3 files changed, 13 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 38c024b..8ff4c93 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,12 +36,17 @@ use mdast::Node; use parser::parse; use to_html::compile as to_html; use to_mdast::compile as to_mdast; -use util::{ - identifier::{id_cont, id_start}, - sanitize_uri::sanitize, -}; #[doc(hidden)] +// Do not use: exported for quick prototyping, will be removed. +pub use util::identifier::{id_cont, id_start}; + +#[doc(hidden)] +// Do not use: exported for quick prototyping, will be removed. +pub use util::sanitize_uri::sanitize; + +#[doc(hidden)] +// Do not use: exported for quick prototyping, will be removed. pub use util::location::Location; /// Type of line endings in markdown. @@ -1514,24 +1519,3 @@ pub fn micromark_to_mdast(value: &str, options: &ParseOptions) -> Result String { - sanitize(value) -} - -/// Do not use: exported for quick prototyping, will be removed. -#[must_use] -#[doc(hidden)] -pub fn id_start_(char: char) -> bool { - id_start(char) -} - -/// Do not use: exported for quick prototyping, will be removed. -#[must_use] -#[doc(hidden)] -pub fn id_cont_(char: char, jsx: bool) -> bool { - id_cont(char, jsx) -} diff --git a/src/util/identifier.rs b/src/util/identifier.rs index 4887e02..3c47e20 100644 --- a/src/util/identifier.rs +++ b/src/util/identifier.rs @@ -3,11 +3,13 @@ use unicode_id::UnicodeID; /// Check if a character can start a JS identifier. +#[must_use] pub fn id_start(char: char) -> bool { UnicodeID::is_id_start(char) || matches!(char, '$' | '_') } /// Check if a character can continue a JS (or JSX) identifier. +#[must_use] pub fn id_cont(char: char, jsx: bool) -> bool { UnicodeID::is_id_continue(char) || matches!(char, '\u{200c}' | '\u{200d}') diff --git a/src/util/sanitize_uri.rs b/src/util/sanitize_uri.rs index 8e44758..7006ace 100644 --- a/src/util/sanitize_uri.rs +++ b/src/util/sanitize_uri.rs @@ -10,9 +10,9 @@ use alloc::{ /// Make a value safe for injection as a URL. /// /// This encodes unsafe characters with percent-encoding and skips already -/// encoded sequences (see [`normalize`][] below). +/// encoded sequences (see `normalize` below). /// Further unsafe characters are encoded as character references (see -/// [`encode`][]). +/// `encode`). /// /// ## Examples /// -- cgit