aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_utils
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-06 12:12:36 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-06 12:12:36 +0200
commit6e80e03bb6d6af47aba2b339f160e4895ab5afba (patch)
tree98ecdfd1d73065ae45846320ccf43e5eb8c8cced /tests/test_utils
parentb75d7976cfe8db43783b930c1f4774f2ad4936f5 (diff)
downloadmarkdown-rs-6e80e03bb6d6af47aba2b339f160e4895ab5afba.tar.gz
markdown-rs-6e80e03bb6d6af47aba2b339f160e4895ab5afba.tar.bz2
markdown-rs-6e80e03bb6d6af47aba2b339f160e4895ab5afba.zip
Refactor to share identifier methods
Diffstat (limited to 'tests/test_utils')
-rw-r--r--tests/test_utils/jsx_rewrite.rs20
1 files changed, 5 insertions, 15 deletions
diff --git a/tests/test_utils/jsx_rewrite.rs b/tests/test_utils/jsx_rewrite.rs
index fbce344..b6ffad6 100644
--- a/tests/test_utils/jsx_rewrite.rs
+++ b/tests/test_utils/jsx_rewrite.rs
@@ -1,8 +1,10 @@
extern crate swc_common;
extern crate swc_ecma_ast;
-use crate::test_utils::to_swc::Program;
+use crate::{
+ micromark::{id_cont_ as id_cont, id_start_ as id_start},
+ test_utils::to_swc::Program,
+};
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
-use unicode_id::UnicodeID;
/// Configuration.
#[derive(Debug, Default, Clone)]
@@ -1159,7 +1161,7 @@ fn is_identifier_name(name: &str) -> bool {
if if index == 0 {
!id_start(char)
} else {
- !id_cont(char)
+ !id_cont(char, false)
} {
return false;
}
@@ -1167,15 +1169,3 @@ fn is_identifier_name(name: &str) -> bool {
true
}
-
-// To do: share with `partial_mdx_jsx`.
-/// Check if a character can start a JS identifier.
-fn id_start(char: char) -> bool {
- UnicodeID::is_id_start(char) || matches!(char, '$' | '_')
-}
-
-// To do: share with `partial_mdx_jsx`.
-/// Check if a character can continue a JS identifier.
-fn id_cont(char: char) -> bool {
- UnicodeID::is_id_continue(char) || matches!(char, '\u{200c}' | '\u{200d}')
-}