Home / Function/ next() — tailwindcss Function Reference

next() — tailwindcss Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  4874f059_8655_141f_83af_85503cf87db8["next()"]
  35b2adf8_a27b_5aee_3865_21fb048c97fb["advance()"]
  4874f059_8655_141f_83af_85503cf87db8 -->|calls| 35b2adf8_a27b_5aee_3865_21fb048c97fb
  style 4874f059_8655_141f_83af_85503cf87db8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/oxide/src/extractor/modifier_machine.rs lines 32–96

    fn next(&mut self, cursor: &mut cursor::Cursor<'_>) -> MachineState {
        // A modifier must start with a `/`, everything else is not a valid start of a modifier
        if Class::Slash != cursor.curr.into() {
            return MachineState::Idle;
        }

        let start_pos = cursor.pos;
        cursor.advance();

        match cursor.curr.into() {
            // Start of an arbitrary value:
            //
            // ```
            // bg-red-500/[20%]
            //            ^^^^^
            // ```
            Class::OpenBracket => match self.arbitrary_value_machine.next(cursor) {
                MachineState::Idle => self.restart(),
                MachineState::Done(_) => self.done(start_pos, cursor),
            },

            // Start of an arbitrary variable:
            //
            // ```
            // bg-red-500/(--my-opacity)
            //            ^^^^^^^^^^^^^^
            // ```
            Class::OpenParen => match self.arbitrary_variable_machine.next(cursor) {
                MachineState::Idle => self.restart(),
                MachineState::Done(_) => self.done(start_pos, cursor),
            },

            // Start of a named modifier:
            //
            // ```
            // bg-red-500/20
            //            ^^
            // ```
            Class::ValidStart => {
                let len = cursor.input.len();
                while cursor.pos < len {
                    match cursor.curr.into() {
                        Class::ValidStart | Class::ValidInside => {
                            match cursor.next.into() {
                                // Only valid characters are allowed, if followed by another valid character
                                Class::ValidStart | Class::ValidInside => cursor.advance(),

                                // Valid character, but at the end of the modifier, this ends the
                                // modifier
                                _ => return self.done(start_pos, cursor),
                            }
                        }

                        // Anything else is invalid, end of the modifier
                        _ => return self.restart(),
                    }
                }

                MachineState::Idle
            }

            // Anything else is not a valid start of a modifier
            _ => MachineState::Idle,
        }
    }

Domain

Subdomains

Calls

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free