parse() — tailwindcss Function Reference
Architecture documentation for the parse() function in css-parser.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 9d7d664d_b6fd_88fd_8800_4b530c33a95b["parse()"] 8be42ab2_7e92_957a_da93_ffe4c7d161fe["css-parser.ts"] 9d7d664d_b6fd_88fd_8800_4b530c33a95b -->|defined in| 8be42ab2_7e92_957a_da93_ffe4c7d161fe 7ac5591b_df87_a0ae_2005_4d18e64a288f["rewriteUrls()"] 7ac5591b_df87_a0ae_2005_4d18e64a288f -->|calls| 9d7d664d_b6fd_88fd_8800_4b530c33a95b 6f4989fd_689b_7bce_afb3_9718fc06d93c["expand()"] 6f4989fd_689b_7bce_afb3_9718fc06d93c -->|calls| 9d7d664d_b6fd_88fd_8800_4b530c33a95b c59be670_b950_e897_c2ef_f6a86119dcc3["compile()"] c59be670_b950_e897_c2ef_f6a86119dcc3 -->|calls| 9d7d664d_b6fd_88fd_8800_4b530c33a95b a1fd01c1_0fb9_2557_6ee0_a660cb46e83b["__unstable__loadDesignSystem()"] a1fd01c1_0fb9_2557_6ee0_a660cb46e83b -->|calls| 9d7d664d_b6fd_88fd_8800_4b530c33a95b 8ef22b30_0ed6_09d2_959d_163f9c650639["analyze()"] 8ef22b30_0ed6_09d2_959d_163f9c650639 -->|calls| 9d7d664d_b6fd_88fd_8800_4b530c33a95b 9f2a64dc_05ff_3425_1af8_f2dbd33c3b9a["optimizeAst()"] 9f2a64dc_05ff_3425_1af8_f2dbd33c3b9a -->|calls| 9d7d664d_b6fd_88fd_8800_4b530c33a95b 2d1ddb63_f29d_b245_22dc_8060d98def4c["substituteAtImports()"] 2d1ddb63_f29d_b245_22dc_8060d98def4c -->|calls| 9d7d664d_b6fd_88fd_8800_4b530c33a95b 31653e23_464a_3652_4a48_0c82332a92c4["buildPluginApi()"] 31653e23_464a_3652_4a48_0c82332a92c4 -->|calls| 9d7d664d_b6fd_88fd_8800_4b530c33a95b 18e3ad78_ceaa_f1dc_df00_cefc3e549b9c["parseVariantValue()"] 18e3ad78_ceaa_f1dc_df00_cefc3e549b9c -->|calls| 9d7d664d_b6fd_88fd_8800_4b530c33a95b bc71102c_3f3f_0a7f_c5dc_2ea1f291aec2["replaceNestedClassNameReferences()"] bc71102c_3f3f_0a7f_c5dc_2ea1f291aec2 -->|calls| 9d7d664d_b6fd_88fd_8800_4b530c33a95b fdbae017_3891_f845_038f_5fc0e026e5e4["comment()"] 9d7d664d_b6fd_88fd_8800_4b530c33a95b -->|calls| fdbae017_3891_f845_038f_5fc0e026e5e4 779f5e3a_dd2f_3d17_f0e7_51b769d1bbec["parseString()"] 9d7d664d_b6fd_88fd_8800_4b530c33a95b -->|calls| 779f5e3a_dd2f_3d17_f0e7_51b769d1bbec 6574abf9_b8da_9782_8f1b_87e120c8dee6["parseDeclaration()"] 9d7d664d_b6fd_88fd_8800_4b530c33a95b -->|calls| 6574abf9_b8da_9782_8f1b_87e120c8dee6 style 9d7d664d_b6fd_88fd_8800_4b530c33a95b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/tailwindcss/src/css-parser.ts lines 64–594
export function parse(input: string, opts?: ParseOptions) {
let source: Source | null = opts?.from ? { file: opts.from, code: input } : null
// Note: it is important that any transformations of the input string
// *before* processing do NOT change the length of the string. This
// would invalidate the mechanism used to track source locations.
if (input[0] === '\uFEFF') input = ' ' + input.slice(1)
let ast: AstNode[] = []
let licenseComments: Comment[] = []
let stack: (Rule | null)[] = []
let parent = null as Rule | null
let node = null as AstNode | null
let buffer = ''
let closingBracketStack = ''
// The start of the first non-whitespace character in the buffer
let bufferStart = 0
let peekChar
for (let i = 0; i < input.length; i++) {
let currentChar = input.charCodeAt(i)
// Skip over the CR in CRLF. This allows code below to only check for a line
// break even if we're looking at a Windows newline. Peeking the input still
// has to check for CRLF but that happens less often.
if (currentChar === CARRIAGE_RETURN) {
peekChar = input.charCodeAt(i + 1)
if (peekChar === LINE_BREAK) continue
}
// Current character is a `\` therefore the next character is escaped,
// consume it together with the next character and continue.
//
// E.g.:
//
// ```css
// .hover\:foo:hover {}
// ^
// ```
//
if (currentChar === BACKSLASH) {
if (buffer === '') bufferStart = i
buffer += input.slice(i, i + 2)
i += 1
}
// Start of a comment.
//
// E.g.:
//
// ```css
// /* Example */
// ^^^^^^^^^^^^^
// .foo {
// color: red; /* Example */
// ^^^^^^^^^^^^^
// }
// .bar {
// color: /* Example */ red;
// ^^^^^^^^^^^^^
// }
// ```
else if (currentChar === SLASH && input.charCodeAt(i + 1) === ASTERISK) {
let start = i
for (let j = i + 2; j < input.length; j++) {
peekChar = input.charCodeAt(j)
// Current character is a `\` therefore the next character is escaped.
if (peekChar === BACKSLASH) {
j += 1
}
// End of the comment
else if (peekChar === ASTERISK && input.charCodeAt(j + 1) === SLASH) {
i = j + 1
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does parse() do?
parse() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/css-parser.ts.
Where is parse() defined?
parse() is defined in packages/tailwindcss/src/css-parser.ts at line 64.
What does parse() call?
parse() calls 5 function(s): comment, parseAtRule, parseDeclaration, parseString, rule.
What calls parse()?
parse() is called by 10 function(s): __unstable__loadDesignSystem, analyze, buildPluginApi, compile, expand, optimizeAst, parseVariantValue, replaceNestedClassNameReferences, and 2 more.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free