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 ffc5693d_f72e_53c2_3a9f_e796ab1c4070["skip_indented_block()"] df07b2ab_5c7f_0413_879f_f42437b5101e["process()"] df07b2ab_5c7f_0413_879f_f42437b5101e -->|calls| ffc5693d_f72e_53c2_3a9f_e796ab1c4070 435a321a_a1e2_cb4f_7579_0ca15cb86434["advance()"] ffc5693d_f72e_53c2_3a9f_e796ab1c4070 -->|calls| 435a321a_a1e2_cb4f_7579_0ca15cb86434 07207bb0_f195_4067_2024_eb12d4800851["advance_twice()"] ffc5693d_f72e_53c2_3a9f_e796ab1c4070 -->|calls| 07207bb0_f195_4067_2024_eb12d4800851 eacebf08_7f52_121a_f1b0_aaad12569230["move_to()"] ffc5693d_f72e_53c2_3a9f_e796ab1c4070 -->|calls| eacebf08_7f52_121a_f1b0_aaad12569230 style ffc5693d_f72e_53c2_3a9f_e796ab1c4070 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
Source
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