process_maud_templates() — tailwindcss Function Reference
Architecture documentation for the process_maud_templates() function in rust.rs from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 0f49e8ac_f357_3018_516f_2f5353ab4e33["process_maud_templates()"] b83b130e_f494_4c75_1153_c58b04972660["rust.rs"] 0f49e8ac_f357_3018_516f_2f5353ab4e33 -->|defined in| b83b130e_f494_4c75_1153_c58b04972660 994c06bf_1d1d_8c36_9c29_cac53b40d05f["process()"] 994c06bf_1d1d_8c36_9c29_cac53b40d05f -->|calls| 0f49e8ac_f357_3018_516f_2f5353ab4e33 style 0f49e8ac_f357_3018_516f_2f5353ab4e33 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
crates/oxide/src/extractor/pre_processors/rust.rs lines 29–121
fn process_maud_templates(&self, replaced_content: &[u8]) -> Vec<u8> {
let len = replaced_content.len();
let mut result = replaced_content.to_vec();
let mut cursor = cursor::Cursor::new(replaced_content);
let mut bracket_stack = bracket_stack::BracketStack::default();
while cursor.pos < len {
match cursor.curr {
// Escaped character, skip ahead to the next character
b'\\' => {
cursor.advance_twice();
continue;
}
// Consume strings as-is
b'"' => {
result[cursor.pos] = b' ';
cursor.advance();
while cursor.pos < len {
match cursor.curr {
// Escaped character, skip ahead to the next character
b'\\' => cursor.advance_twice(),
// End of the string
b'"' => {
result[cursor.pos] = b' ';
break;
}
// Everything else is valid
_ => cursor.advance(),
};
}
}
// Only replace `.` with a space if it's not surrounded by numbers. E.g.:
//
// ```diff
// - .flex.items-center
// + flex items-center
// ```
//
// But with numbers, it's allowed:
//
// ```diff
// - px-2.5
// + px-2.5
// ```
b'.' => {
// Don't replace dots with spaces when inside of any type of brackets, because
// this could be part of arbitrary values. E.g.: `bg-[url(https://example.com)]`
// ^
if !bracket_stack.is_empty() {
cursor.advance();
continue;
}
// If the dot is surrounded by digits, we want to keep it. E.g.: `px-2.5`
// EXCEPT if it's followed by a valid variant that happens to start with a
// digit.
// E.g.: `bg-red-500.2xl:flex`
// ^^^
if cursor.prev.is_ascii_digit() && cursor.next.is_ascii_digit() {
let mut next_cursor = cursor.clone();
next_cursor.advance();
let mut variant_machine = VariantMachine::default();
if let MachineState::Done(_) = variant_machine.next(&mut next_cursor) {
result[cursor.pos] = b' ';
}
} else {
result[cursor.pos] = b' ';
}
}
b'[' => {
bracket_stack.push(cursor.curr);
}
b']' if !bracket_stack.is_empty() => {
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does process_maud_templates() do?
process_maud_templates() is a function in the tailwindcss codebase, defined in crates/oxide/src/extractor/pre_processors/rust.rs.
Where is process_maud_templates() defined?
process_maud_templates() is defined in crates/oxide/src/extractor/pre_processors/rust.rs at line 29.
What calls process_maud_templates()?
process_maud_templates() 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