slim.rs — tailwindcss Source File
Architecture documentation for slim.rs, a rust file in the tailwindcss codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 9bff01b6_bbfb_f7ed_1b53_44928706ceb7["slim.rs"] d541da21_febf_afb0_8191_2de817183808["super::Slim"] 9bff01b6_bbfb_f7ed_1b53_44928706ceb7 --> d541da21_febf_afb0_8191_2de817183808 96a36755_a007_15e1_ec6c_526c02d24b9b["crate::cursor"] 9bff01b6_bbfb_f7ed_1b53_44928706ceb7 --> 96a36755_a007_15e1_ec6c_526c02d24b9b c4d29b89_2191_f275_13fb_7cf117340055["crate::extractor::bracket_stack::BracketStack"] 9bff01b6_bbfb_f7ed_1b53_44928706ceb7 --> c4d29b89_2191_f275_13fb_7cf117340055 05907c18_a40e_a5a9_c7c3_5faba98e1e87["crate::extractor::machine::"] 9bff01b6_bbfb_f7ed_1b53_44928706ceb7 --> 05907c18_a40e_a5a9_c7c3_5faba98e1e87 ed5b6564_5e78_f7bf_cdc6_b0150d9116c1["crate::extractor::pre_processors::pre_processor::PreProcessor"] 9bff01b6_bbfb_f7ed_1b53_44928706ceb7 --> ed5b6564_5e78_f7bf_cdc6_b0150d9116c1 087ad9fa_43e6_1338_b489_014631bd4014["crate::extractor::variant_machine::VariantMachine"] 9bff01b6_bbfb_f7ed_1b53_44928706ceb7 --> 087ad9fa_43e6_1338_b489_014631bd4014 style 9bff01b6_bbfb_f7ed_1b53_44928706ceb7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
use crate::cursor;
use crate::extractor::bracket_stack::BracketStack;
use crate::extractor::machine::{Machine, MachineState};
use crate::extractor::pre_processors::pre_processor::PreProcessor;
use crate::extractor::variant_machine::VariantMachine;
#[derive(Debug, Default)]
pub struct Slim;
impl PreProcessor for Slim {
fn process(&self, content: &[u8]) -> Vec<u8> {
let len = content.len();
let mut result = content.to_vec();
let mut cursor = cursor::Cursor::new(content);
let mut bracket_stack = BracketStack::default();
while cursor.pos < len {
match cursor.curr {
// 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' ';
}
}
// Handle Ruby syntax with `%w[]` arrays embedded in Slim directly.
//
// ... (272 more lines)
Domain
Subdomains
Functions
Dependencies
- crate::cursor
- crate::extractor::bracket_stack::BracketStack
- crate::extractor::machine::
- crate::extractor::pre_processors::pre_processor::PreProcessor
- crate::extractor::variant_machine::VariantMachine
- super::Slim
Source
Frequently Asked Questions
What does slim.rs do?
slim.rs is a source file in the tailwindcss codebase, written in rust. It belongs to the Oxide domain, PreProcessors subdomain.
What functions are defined in slim.rs?
slim.rs defines 8 function(s): process, test_arbitrary_code_followed_by_classes, test_class_shorthand_followed_by_parens, test_embedded_ruby_percent_w_extraction, test_nested_slim_syntax, test_single_quotes_to_enforce_trailing_whitespace, test_slim_pre_processor, test_strings_only_occur_when_nested.
What does slim.rs depend on?
slim.rs imports 6 module(s): crate::cursor, crate::extractor::bracket_stack::BracketStack, crate::extractor::machine::, crate::extractor::pre_processors::pre_processor::PreProcessor, crate::extractor::variant_machine::VariantMachine, super::Slim.
Where is slim.rs in the architecture?
slim.rs is located at crates/oxide/src/extractor/pre_processors/slim.rs (domain: Oxide, subdomain: PreProcessors, directory: crates/oxide/src/extractor/pre_processors).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free