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.

Function rust OxideCore PreProcessors calls 3 called by 1

Entity Profile

Dependency Diagram

graph TD
  8faec703_0c1c_dd65_5f9e_9f8137271c9e["skip_indented_block()"]
  8af59f03_1c0a_3e63_fddc_bd0fcceab247["process()"]
  8af59f03_1c0a_3e63_fddc_bd0fcceab247 -->|calls| 8faec703_0c1c_dd65_5f9e_9f8137271c9e
  35b2adf8_a27b_5aee_3865_21fb048c97fb["advance()"]
  8faec703_0c1c_dd65_5f9e_9f8137271c9e -->|calls| 35b2adf8_a27b_5aee_3865_21fb048c97fb
  a342bcc5_aaba_6cba_f921_8c94c0d956ac["advance_twice()"]
  8faec703_0c1c_dd65_5f9e_9f8137271c9e -->|calls| a342bcc5_aaba_6cba_f921_8c94c0d956ac
  95863211_f6f6_7fff_0253_53a5f33740d9["move_to()"]
  8faec703_0c1c_dd65_5f9e_9f8137271c9e -->|calls| 95863211_f6f6_7fff_0253_53a5f33740d9
  style 8faec703_0c1c_dd65_5f9e_9f8137271c9e 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 {
                        // We are done with this block
                        break;
                    }
                }

                // Not whitespace, end of block
                _ => break,
            };

            cursor.advance();
        }

        // We didn't find a newline, we reached the end of the input
        if last_known_newline_position == last_newline_position {
            return cursor.pos;
        }

        // Move the cursor to the last newline position
        cursor.move_to(last_newline_position);

        last_newline_position
    }

Domain

Subdomains

Called By

Frequently Asked Questions

What does skip_indented_block() do?
skip_indented_block() is a function in the tailwindcss codebase.
What does skip_indented_block() call?
skip_indented_block() calls 3 function(s): advance, advance_twice, move_to.
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