Skip to content

Commit

Permalink
Disallow spacing within each modifier_classnames
Browse files Browse the repository at this point in the history
  • Loading branch information
Oyelowo committed Oct 11, 2023
1 parent 822b81c commit 5294497
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
6 changes: 3 additions & 3 deletions tailwind/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand All @@ -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
Expand Down
21 changes: 2 additions & 19 deletions tw-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, ()))
}
Expand Down Expand Up @@ -255,23 +253,17 @@ 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, ()))
}

// 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, ()))
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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, ()))
}
Expand All @@ -404,15 +394,12 @@ fn arbitrary_css_value(input: &str) -> IResult<&str, ()> {
tag("var(--"),
// <ident>: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, ()))
}
Expand All @@ -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)?;
Expand All @@ -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)?;
Expand All @@ -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)?;
Expand Down Expand Up @@ -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![]))
Expand Down

0 comments on commit 5294497

Please sign in to comment.