From 52944972324aa0adaa4bb2f28ffa5efa35399990 Mon Sep 17 00:00:00 2001 From: oyelowo Date: Tue, 10 Oct 2023 21:40:04 -0600 Subject: [PATCH] Disallow spacing within each modifier_classnames --- tailwind/src/main.rs | 6 +++--- tw-macro/src/lib.rs | 21 ++------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/tailwind/src/main.rs b/tailwind/src/main.rs index b5f72a9..b41f315 100644 --- a/tailwind/src/main.rs +++ b/tailwind/src/main.rs @@ -11,9 +11,9 @@ fn main() { let _ = tw!("btn btn"); let test = tw!( - r#"[mask-type:alpha] [ mask-type: alpha ] before:content-['rerer erer re rr r \re reFestivus'] + r#"[mask-type:alpha] [mask-type:alpha] before:content-['rerer erer re rr r \re reFestivus'] after:content-['I am a content'] after:content-['I am a content'] after:content-['I am a content'] - active:hover:text-[#bada55] active:hover:text-[ #ba5 ] text-[#bada55] hover:aria-checked:text-[22px] + active:hover:text-[#bada55] active:hover:text-[#fa5] text-[#bada55] hover:aria-checked:text-[22px] text-[22.34e434cm] before:content-['hello\_world'] grid grid-cols-[fit-content(theme(spacing.32))] @@ -22,7 +22,7 @@ fn main() { text-[length:var(--my-var)] text-[color:var(--my-var)] [--scroll-offset:56px] lg:[--scroll-offset:44px] - btn bg-[url('/img/down-arrow.svg')] ring-white/10 bg-black/25 bg-black/[100] bg-black/[0.75] active:hover:collapse-arrow + btn bg-[url('/img/down-arrow.svg')] ring-white/10 bg-black/25 bg-black/[80%] bg-black/[100] bg-black/[0.75] active:hover:collapse-arrow -mt-4 diff --git a/tw-macro/src/lib.rs b/tw-macro/src/lib.rs index 381f247..e6f4ffc 100644 --- a/tw-macro/src/lib.rs +++ b/tw-macro/src/lib.rs @@ -170,10 +170,8 @@ fn lengthy_arbitrary_classname(input: &str) -> IResult<&str, ()> { // arbitrary value let (input, _) = tag("-")(input)?; let (input, _) = tag("[")(input)?; - let (input, _) = multispace0(input)?; // is number let (input, _) = parse_length_unit(input)?; - let (input, _) = multispace0(input)?; let (input, _) = tag("]")(input)?; Ok((input, ())) } @@ -255,9 +253,7 @@ fn colorful_arbitrary_baseclass(input: &str) -> IResult<&str, ()> { // arbitrary value let (input, _) = tag("-")(input)?; let (input, _) = tag("[")(input)?; - let (input, _) = multispace0(input)?; let (input, _) = alt((parse_hex_color, parse_rgb_color, parse_rgba_color))(input)?; - let (input, _) = multispace0(input)?; let (input, _) = tag("]")(input)?; Ok((input, ())) } @@ -265,13 +261,9 @@ fn colorful_arbitrary_baseclass(input: &str) -> IResult<&str, ()> { // e.g: [mask-type:alpha] fn kv_pair_classname(input: &str) -> IResult<&str, ()> { let (input, _) = tag("[")(input)?; - let (input, _) = multispace0(input)?; let (input, _) = take_while1(is_ident_char)(input)?; - let (input, _) = multispace0(input)?; let (input, _) = tag(":")(input)?; - let (input, _) = multispace0(input)?; let (input, _) = take_while1(is_ident_char)(input)?; - let (input, _) = multispace0(input)?; let (input, _) = tag("]")(input)?; Ok((input, ())) } @@ -325,7 +317,7 @@ fn predefined_colorful_opacity(input: &str) -> IResult<&str, ()> { Ok((input, ())) } -// bg-black/[27] +// bg-black/[27] bg-black/[27%] fn arbitrary_opacity(input: &str) -> IResult<&str, ()> { let input = if COLORFUL_BASECLASSES .iter() @@ -373,11 +365,9 @@ fn bg_arbitrary_url(input: &str) -> IResult<&str, ()> { }; let (input, _) = take_while1(|char| is_ident_char(char) && char != '[')(input)?; let (input, _) = tag("[")(input)?; - let (input, _) = multispace0(input)?; let (input, _) = tag("url('")(input)?; let (input, _) = take_until("')")(input)?; let (input, _) = tag("')")(input)?; - let (input, _) = multispace0(input)?; let (input, _) = tag("]")(input)?; Ok((input, ())) } @@ -404,15 +394,12 @@ fn arbitrary_css_value(input: &str) -> IResult<&str, ()> { tag("var(--"), // :var(-- )))(input)?; - let (input, _) = multispace0(input)?; let (input, _) = take_while1(|char| is_ident_char(char) && char != '(')(input)?; let (input, _) = tag("(")(input)?; let (input, _) = take_until(")]")(input)?; - let (input, _) = multispace0(input)?; // allow anything inthe brackets let (input, _) = take_until("]")(input)?; - let (input, _) = multispace0(input)?; let (input, _) = tag("]")(input)?; Ok((input, ())) } @@ -433,7 +420,6 @@ fn arbitrary_css_var(input: &str) -> IResult<&str, ()> { }; let (input, _) = take_while1(|char| is_ident_char(char) && char != '[')(input)?; let (input, _) = tag("[")(input)?; - let (input, _) = multispace0(input)?; let (input, _) = tag("--")(input)?; let (input, _) = take_while1(|char| is_ident_char(char) && char != ']')(input)?; let (input, _) = tag("]")(input)?; @@ -455,7 +441,6 @@ fn arbitrary_css_var2(input: &str) -> IResult<&str, ()> { }; let (input, _) = take_while1(|char| is_ident_char(char) && char != '[')(input)?; let (input, _) = tag("[")(input)?; - let (input, _) = multispace0(input)?; let (input, _) = tag("var(--")(input)?; let (input, _) = take_while1(|char| is_ident_char(char) && char != ')')(input)?; let (input, _) = tag(")]")(input)?; @@ -478,10 +463,8 @@ fn arbitrary_css_var3(input: &str) -> IResult<&str, ()> { }; let (input, _) = take_while1(|char| is_ident_char(char) && char != '[')(input)?; let (input, _) = tag("[")(input)?; - let (input, _) = multispace0(input)?; let (input, _) = take_while1(|char| is_ident_char(char) && char != ':')(input)?; let (input, _) = tag(":")(input)?; - let (input, _) = multispace0(input)?; let (input, _) = tag("var(--")(input)?; let (input, _) = take_while1(|char| is_ident_char(char) && char != ')')(input)?; let (input, _) = tag(")]")(input)?; @@ -726,7 +709,7 @@ fn parse_tw_full_classname(input: &str) -> IResult<&str, Vec<&str>> { // text-[color:var(--my-var)] fn parse_class_names(input: &str) -> IResult<&str, Vec<&str>> { let (input, _) = multispace0(input)?; - let (input, class_names) = separated_list0(multispace1, parse_tw_full_classname)(input)?; + let (input, _class_names) = separated_list0(multispace1, parse_tw_full_classname)(input)?; let (input, _) = multispace0(input)?; Ok((input, vec![]))