Home / Function/ parseAtRule() — tailwindcss Function Reference

parseAtRule() — tailwindcss Function Reference

Architecture documentation for the parseAtRule() function in css-parser.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  2cd5e680_b143_2eca_cc9b_084ae471679f["parseAtRule()"]
  54851997_7544_bab2_96ab_548e5f5df205["css-parser.ts"]
  2cd5e680_b143_2eca_cc9b_084ae471679f -->|defined in| 54851997_7544_bab2_96ab_548e5f5df205
  66319c06_7c38_f9ea_4bf0_2a0e18bac1a4["rule()"]
  66319c06_7c38_f9ea_4bf0_2a0e18bac1a4 -->|calls| 2cd5e680_b143_2eca_cc9b_084ae471679f
  b8a15b09_3dfb_7181_b1f8_368422e178e4["parse()"]
  b8a15b09_3dfb_7181_b1f8_368422e178e4 -->|calls| 2cd5e680_b143_2eca_cc9b_084ae471679f
  f9b19679_c1f0_28d6_4d1a_31a10c52e42d["atRule()"]
  2cd5e680_b143_2eca_cc9b_084ae471679f -->|calls| f9b19679_c1f0_28d6_4d1a_31a10c52e42d
  style 2cd5e680_b143_2eca_cc9b_084ae471679f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/css-parser.ts lines 596–627

export function parseAtRule(buffer: string, nodes: AstNode[] = []): AtRule {
  let name = buffer
  let params = ''

  // Assumption: The smallest at-rule in CSS right now is `@page`, this means
  //             that we can always skip the first 5 characters and start at the
  //             sixth (at index 5).
  //
  // There is a chance someone is using a shorter at-rule, in that case we have
  // to adjust this number back to 2, e.g.: `@x`.
  //
  // This issue can only occur if somebody does the following things:
  //
  // 1. Uses a shorter at-rule than `@page`
  // 2. Disables Lightning CSS from `@tailwindcss/postcss` (because Lightning
  //    CSS doesn't handle custom at-rules properly right now)
  // 3. Sandwiches the `@tailwindcss/postcss` plugin between two other plugins
  //    that can handle the shorter at-rule
  //
  // Let's use the more common case as the default and we can adjust this
  // behavior if necessary.
  for (let i = 5 /* '@page'.length */; i < buffer.length; i++) {
    let currentChar = buffer.charCodeAt(i)
    if (currentChar === SPACE || currentChar === TAB || currentChar === OPEN_PAREN) {
      name = buffer.slice(0, i)
      params = buffer.slice(i)
      break
    }
  }

  return atRule(name.trim(), params.trim(), nodes)
}

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

What does parseAtRule() do?
parseAtRule() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/css-parser.ts.
Where is parseAtRule() defined?
parseAtRule() is defined in packages/tailwindcss/src/css-parser.ts at line 596.
What does parseAtRule() call?
parseAtRule() calls 1 function(s): atRule.
What calls parseAtRule()?
parseAtRule() is called by 2 function(s): parse, rule.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free