Home / File/ clojure.rs — tailwindcss Source File

clojure.rs — tailwindcss Source File

Architecture documentation for clojure.rs, a rust file in the tailwindcss codebase. 4 imports, 0 dependents.

File rust Oxide PreProcessors 4 imports 10 functions

Entity Profile

Dependency Diagram

graph LR
  0ba5a6b8_d3d7_1e5f_46f4_902266673015["clojure.rs"]
  8dcde30f_3ab5_8cc5_ad00_b03510fc209b["super::Clojure"]
  0ba5a6b8_d3d7_1e5f_46f4_902266673015 --> 8dcde30f_3ab5_8cc5_ad00_b03510fc209b
  96a36755_a007_15e1_ec6c_526c02d24b9b["crate::cursor"]
  0ba5a6b8_d3d7_1e5f_46f4_902266673015 --> 96a36755_a007_15e1_ec6c_526c02d24b9b
  ed5b6564_5e78_f7bf_cdc6_b0150d9116c1["crate::extractor::pre_processors::pre_processor::PreProcessor"]
  0ba5a6b8_d3d7_1e5f_46f4_902266673015 --> ed5b6564_5e78_f7bf_cdc6_b0150d9116c1
  092d26da_8f74_08d1_48f1_765b79ca447c["bstr::ByteSlice"]
  0ba5a6b8_d3d7_1e5f_46f4_902266673015 --> 092d26da_8f74_08d1_48f1_765b79ca447c
  style 0ba5a6b8_d3d7_1e5f_46f4_902266673015 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

use crate::cursor;
use crate::extractor::pre_processors::pre_processor::PreProcessor;
use bstr::ByteSlice;

#[derive(Debug, Default)]
pub struct Clojure;

/// This is meant to be a rough estimate of a valid ClojureScript keyword
///
/// This can be approximated by the following regex:
/// /::?[a-zA-Z0-9!#$%&*+./:<=>?_|-]+/
///
/// However, keywords are intended to be detected as utilities. Since the set
/// of valid characters in a utility (outside of arbitrary values) is smaller,
/// along with the fact that neither `[]` nor `()` are allowed in keywords we
/// can simplify this list quite a bit.
#[inline]
fn is_keyword_character(byte: u8) -> bool {
    (matches!(
        byte,
        b'!' | b'#' | b'%' | b'*' | b'+' | b'-' | b'.' | b'/' | b':' | b'_'
    ) | byte.is_ascii_alphanumeric())
}

impl PreProcessor for Clojure {
    fn process(&self, content: &[u8]) -> Vec<u8> {
        let content = content
            .replace(":class", "      ")
            .replace(":className", "          ");
        let len = content.len();
        let mut result = content.to_vec();
        let mut cursor = cursor::Cursor::new(&content);

        while cursor.pos < len {
            match cursor.curr {
                // 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(),
                        };
                    }
                }

                // Discard line comments until the end of the line.
                // Comments start with `;;`
                b';' if matches!(cursor.next, b';') => {
// ... (377 more lines)

Domain

Subdomains

Dependencies

  • bstr::ByteSlice
  • crate::cursor
  • crate::extractor::pre_processors::pre_processor::PreProcessor
  • super::Clojure

Frequently Asked Questions

What does clojure.rs do?
clojure.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 clojure.rs?
clojure.rs defines 10 function(s): is_keyword_character, process, test_clojure_pre_processor, test_extract_candidates, test_extract_from_symbol_list, test_extraction_of_classes_with_dots, test_extraction_of_pseudoclasses_from_keywords, test_ignore_comments_with_invalid_strings, test_noninterference_of_parens_on_keywords, test_special_characters_are_valid_in_strings.
What does clojure.rs depend on?
clojure.rs imports 4 module(s): bstr::ByteSlice, crate::cursor, crate::extractor::pre_processors::pre_processor::PreProcessor, super::Clojure.
Where is clojure.rs in the architecture?
clojure.rs is located at crates/oxide/src/extractor/pre_processors/clojure.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