Skip to content

Commit 51f2c75

Browse files
bors[bot]Nemo157
andauthored
20: Support non-ascii identifiers r=Nemo157 a=Nemo157 Fixes Nullus157#19 Co-authored-by: Wim Looman <[email protected]>
2 parents 10ed66f + d7a089d commit 51f2c75

File tree

6 files changed

+34
-58
lines changed

6 files changed

+34
-58
lines changed

Cargo.lock

Lines changed: 14 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stylish-core"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2021"
55
repository = "https://github.com/Nullus157/stylish-rs"
66
license = "MIT OR Apache-2.0"
@@ -21,7 +21,7 @@ stack_dst.default-features = false
2121
stack_dst.version = "0.6.0"
2222
stylish-macros.default-features = false
2323
stylish-macros.path = "../macros"
24-
stylish-macros.version = "=0.1.0"
24+
stylish-macros.version = "=0.1.1"
2525
stylish-macros.optional = true
2626
stylish-style.default-features = false
2727
stylish-style.path = "../style"

deny.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
allow = [
33
"MIT",
44
"Apache-2.0",
5+
"Unicode-DFS-2016",
56
]

macros/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stylish-macros"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2021"
55
repository = "https://github.com/Nullus157/stylish-rs"
66
license = "MIT OR Apache-2.0"
@@ -13,7 +13,7 @@ proc-macro = true
1313
[dependencies]
1414
nom.default-features = false
1515
nom.features = ["std"]
16-
nom.version = "6.0.1"
16+
nom.version = "7.1.1"
1717
proc-macro2.default-features = false
1818
proc-macro2.version = "1.0.24"
1919
quote.default-features = false
@@ -25,6 +25,8 @@ stylish-style.default-features = false
2525
stylish-style.features = ["alloc"]
2626
stylish-style.version = "=0.1.0"
2727
stylish-style.path = "../style"
28+
unicode-ident.default-features = false
29+
unicode-ident.version = "1.0.3"
2830

2931
[package.metadata.docs.rs]
3032
all-features = true

macros/src/format.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::str::FromStr;
33
use nom::{
44
branch::alt,
55
bytes::complete::tag,
6-
character::complete::{alpha1, alphanumeric1, anychar, digit1, none_of},
6+
character::complete::{anychar, char, digit1, none_of, satisfy},
77
combinator::{all_consuming, cut, map, map_res, opt, recognize, value},
88
multi::{many0, many1, separated_list0},
99
sequence::{delimited, pair, preceded, terminated},
@@ -13,8 +13,8 @@ use stylish_style::{Background, Color, Foreground, Intensity, Restyle, Style, St
1313

1414
fn identifier(input: &str) -> IResult<&str, &str> {
1515
recognize(pair(
16-
alt((alpha1, tag("_"))),
17-
many0(alt((alphanumeric1, tag("_")))),
16+
alt((satisfy(unicode_ident::is_xid_start), char('_'))),
17+
many0(satisfy(unicode_ident::is_xid_continue)),
1818
))(input)
1919
}
2020

tests/tests.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(uncommon_codepoints)]
2+
13
#[cfg(not(feature = "_tests"))]
24
compile_error!("please test with --all-features");
35

@@ -183,6 +185,14 @@ mod tests {
183185
);
184186
}
185187

188+
#[test]
189+
fn non_ascii_idents() {
190+
let 𓀄 = 5;
191+
assert_eq!(stylish::plain::format!("{𓀄}"), "5");
192+
assert_eq!(stylish::plain::format!("{}", 𓀄), "5");
193+
assert_eq!(stylish::plain::format!("{𓀄}", 𓀄 = 5), "5");
194+
}
195+
186196
#[cfg(stylish_proc_macro_expand)]
187197
#[test]
188198
fn extended_builtin_macros() {

0 commit comments

Comments
 (0)