Home / Function/ next() — tailwindcss Function Reference

next() — tailwindcss Function Reference

Architecture documentation for the next() function in css_variable_machine.rs from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  f370f0b7_18ea_89c6_58ab_a689cbf857db["next()"]
  07207bb0_f195_4067_2024_eb12d4800851["advance_twice()"]
  f370f0b7_18ea_89c6_58ab_a689cbf857db -->|calls| 07207bb0_f195_4067_2024_eb12d4800851
  435a321a_a1e2_cb4f_7579_0ca15cb86434["advance()"]
  f370f0b7_18ea_89c6_58ab_a689cbf857db -->|calls| 435a321a_a1e2_cb4f_7579_0ca15cb86434
  style f370f0b7_18ea_89c6_58ab_a689cbf857db fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/oxide/src/extractor/css_variable_machine.rs lines 21–88

    fn next(&mut self, cursor: &mut cursor::Cursor<'_>) -> MachineState {
        // CSS Variables must start with `--`
        if Class::Dash != cursor.curr.into() || Class::Dash != cursor.next.into() {
            return MachineState::Idle;
        }

        let start_pos = cursor.pos;
        let len = cursor.input.len();

        cursor.advance_twice();

        while cursor.pos < len {
            match cursor.curr.into() {
                // https://drafts.csswg.org/css-syntax-3/#ident-token-diagram
                //
                Class::AllowedCharacter | Class::Dash => {
                    match cursor.next.into() {
                        // Valid character followed by a valid character or an escape character
                        //
                        // E.g.: `--my-variable`
                        //                ^^
                        // E.g.: `--my-\#variable`
                        //            ^^
                        Class::AllowedCharacter | Class::Dash | Class::Escape => cursor.advance(),

                        // Valid character followed by anything else means the variable is done
                        //
                        // E.g.: `'--my-variable'`
                        //                      ^
                        _ => {
                            // There must be at least 1 character after the `--`
                            if cursor.pos - start_pos < 2 {
                                return self.restart();
                            } else {
                                return self.done(start_pos, cursor);
                            }
                        }
                    }
                }

                Class::Escape => match cursor.next.into() {
                    // An escaped whitespace character is not allowed
                    //
                    // In CSS it is allowed, but in the context of a class it's not because then we
                    // would have spaces in the class.
                    //
                    // E.g.: `bg-(--my-\ color)`
                    //                  ^
                    Class::Whitespace => return self.restart(),

                    // An escape at the end of the class is not allowed
                    Class::End => return self.restart(),

                    // An escaped character, skip the next character, resume after
                    //
                    // E.g.: `--my-\#variable`
                    //             ^           We are here
                    //               ^         Resume here
                    _ => cursor.advance_twice(),
                },

                // Character is not valid anymore
                _ => return self.restart(),
            }
        }

        MachineState::Idle
    }

Domain

Subdomains

Frequently Asked Questions

What does next() do?
next() is a function in the tailwindcss codebase.
What does next() call?
next() calls 2 function(s): advance, advance_twice.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free