Home / Function/ skip_indented_block() — tailwindcss Function Reference

skip_indented_block() — tailwindcss Function Reference

Architecture documentation for the skip_indented_block() function in haml.rs from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  d38b2186_9ab8_93bb_3bcd_6cc274fefebf["skip_indented_block()"]
  ca2cb7f3_129e_2351_7658_5668e9773b08["haml.rs"]
  d38b2186_9ab8_93bb_3bcd_6cc274fefebf -->|defined in| ca2cb7f3_129e_2351_7658_5668e9773b08
  b09c5f6b_e2b1_8676_9c0e_80d8fd9bf8dd["process()"]
  b09c5f6b_e2b1_8676_9c0e_80d8fd9bf8dd -->|calls| d38b2186_9ab8_93bb_3bcd_6cc274fefebf
  style d38b2186_9ab8_93bb_3bcd_6cc274fefebf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/oxide/src/extractor/pre_processors/haml.rs lines 240–342

    fn skip_indented_block(
        &self,
        cursor: &mut cursor::Cursor,
        last_known_newline_position: usize,
    ) -> usize {
        let len = cursor.input.len();

        // Special case: if the first character of the block is `=`, then newlines are only allowed
        // _if_ the last character of the previous line is a comma `,`.
        //
        // https://haml.info/docs/yardoc/file.REFERENCE.html#inserting_ruby
        //
        // > A line of Ruby code can be stretched over multiple lines as long as each line but the
        // > last ends with a comma. For example:
        //
        // ```haml
        // = link_to_remote "Add to cart",
        //     :url => { :action => "add", :id => product.id },
        //     :update => { :success => "cart", :failure => "error" }
        // ```
        let evaluation_type = cursor.curr;

        let block_indentation_level = cursor
            .pos
            .saturating_sub(last_known_newline_position)
            .saturating_sub(1); /* The newline itself */

        let mut last_newline_position = last_known_newline_position;

        // Consume until the end of the line first
        while cursor.pos < len && cursor.curr != b'\n' {
            cursor.advance();
        }

        // Block is already done, aka just a line
        if evaluation_type == b'=' && cursor.prev != b',' {
            return cursor.pos;
        }

        'outer: while cursor.pos < len {
            match cursor.curr {
                // Escape the next character
                b'\\' => {
                    cursor.advance_twice();
                    continue;
                }

                // Track the last newline position
                b'\n' => {
                    last_newline_position = cursor.pos;

                    // We are done with this block
                    if evaluation_type == b'=' && cursor.prev != b',' {
                        break;
                    }

                    cursor.advance();
                    continue;
                }

                // Skip whitespace and compute the indentation level
                x if x.is_ascii_whitespace() => {
                    // Find first non-whitespace character
                    while cursor.pos < len && cursor.curr.is_ascii_whitespace() {
                        if cursor.curr == b'\n' {
                            last_newline_position = cursor.pos;

                            if evaluation_type == b'=' && cursor.prev != b',' {
                                // We are done with this block
                                break 'outer;
                            }
                        }

                        cursor.advance();
                    }

                    let indentation = cursor
                        .pos
                        .saturating_sub(last_newline_position)
                        .saturating_sub(1); /* The newline itself */
                    if indentation < block_indentation_level {

Domain

Subdomains

Called By

Frequently Asked Questions

What does skip_indented_block() do?
skip_indented_block() is a function in the tailwindcss codebase, defined in crates/oxide/src/extractor/pre_processors/haml.rs.
Where is skip_indented_block() defined?
skip_indented_block() is defined in crates/oxide/src/extractor/pre_processors/haml.rs at line 240.
What calls skip_indented_block()?
skip_indented_block() is called by 1 function(s): process.

Analyze Your Own Codebase

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

Try Supermodel Free