aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib.rs34
-rw-r--r--src/util/identifier.rs2
-rw-r--r--src/util/sanitize_uri.rs4
-rw-r--r--tests/test_utils/jsx_rewrite.rs2
-rw-r--r--tests/test_utils/to_hast.rs14
5 files changed, 21 insertions, 35 deletions
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<Node, S
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
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
///
diff --git a/tests/test_utils/jsx_rewrite.rs b/tests/test_utils/jsx_rewrite.rs
index 9dd2605..33879b0 100644
--- a/tests/test_utils/jsx_rewrite.rs
+++ b/tests/test_utils/jsx_rewrite.rs
@@ -7,7 +7,7 @@ use crate::test_utils::{
},
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
index 4907e23..1ba8d35 100644
--- 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 @@ pub fn to_hast(mdast: &mdast::Node) -> hast::Node {
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 @@ fn transform_footnote_reference(
_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 @@ fn transform_image(_state: &mut State, _node: &mdast::Node, image: &mdast::Image
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 @@ fn transform_image_reference(
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 @@ fn transform_link(state: &mut State, node: &mdast::Node, link: &mdast::Link) ->
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 @@ fn transform_link_reference(
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())));