diff --git a/src/lib.rs b/src/lib.rs --- 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 @@ let (events, parse_state) = parse(value, options)?; let node = to_mdast(&events, parse_state.bytes)?; Ok(node) } - -/// Do not use: exported for quick prototyping, will be removed. -#[must_use] -#[doc(hidden)] -pub fn sanitize_(value: &str) -> 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 --- 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 --- a/src/util/sanitize_uri.rs +++ b/src/util/sanitize_uri.rs @@ -10,9 +10,9 @@ /// 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 /// diff --git a/tests/test_utils/jsx_rewrite.rs b/tests/test_utils/jsx_rewrite.rs --- a/tests/test_utils/jsx_rewrite.rs +++ b/tests/test_utils/jsx_rewrite.rs @@ -7,7 +7,7 @@ create_binary_expression, create_ident, create_ident_expression, create_member_expression, }, to_swc::Program, }; -use micromark::{id_cont_ as id_cont, id_start_ as id_start, unist::Position, Location}; +use micromark::{id_cont, id_start, unist::Position, Location}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith}; /// Configuration. diff --git a/tests/test_utils/to_hast.rs b/tests/test_utils/to_hast.rs --- a/tests/test_utils/to_hast.rs +++ b/tests/test_utils/to_hast.rs @@ -1,5 +1,5 @@ use crate::test_utils::hast; -use micromark::{mdast, sanitize_, unist::Position}; +use micromark::{mdast, sanitize, unist::Position}; // To do: support these compile options: // ``` @@ -92,7 +92,7 @@ let mut index = 0; while index < state.footnote_calls.len() { let (id, count) = &state.footnote_calls[index]; - let safe_id = sanitize_(&id.to_lowercase()); + let safe_id = sanitize(&id.to_lowercase()); // Find definition: we’ll always find it. let mut definition_index = 0; @@ -412,7 +412,7 @@ state: &mut State, _node: &mdast::Node, footnote_reference: &mdast::FootnoteReference, ) -> Result { - let safe_id = sanitize_(&footnote_reference.identifier.to_lowercase()); + let safe_id = sanitize(&footnote_reference.identifier.to_lowercase()); let mut call_index = 0; // See if this has been called before. @@ -489,7 +489,7 @@ let mut properties = vec![]; properties.push(( "src".into(), - hast::PropertyValue::String(sanitize_(&image.url)), + hast::PropertyValue::String(sanitize(&image.url)), )); properties.push(("alt".into(), hast::PropertyValue::String(image.alt.clone()))); @@ -522,7 +522,7 @@ let (_, url, title) = definition.expect("expected reference to have a corresponding definition"); - properties.push(("src".into(), hast::PropertyValue::String(sanitize_(url)))); + properties.push(("src".into(), hast::PropertyValue::String(sanitize(url)))); properties.push(( "alt".into(), @@ -584,7 +584,7 @@ let mut properties = vec![]; properties.push(( "href".into(), - hast::PropertyValue::String(sanitize_(&link.url)), + hast::PropertyValue::String(sanitize(&link.url)), )); if let Some(value) = link.title.as_ref() { @@ -615,7 +615,7 @@ let (_, url, title) = definition.expect("expected reference to have a corresponding definition"); - properties.push(("href".into(), hast::PropertyValue::String(sanitize_(url)))); + properties.push(("href".into(), hast::PropertyValue::String(sanitize(url)))); if let Some(value) = title { properties.push(("title".into(), hast::PropertyValue::String(value.into())));