Home / Function/ parseAtRule() — tailwindcss Function Reference

parseAtRule() — tailwindcss Function Reference

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

Function typescript Oxide Extractor calls 1 called by 2

Entity Profile

Dependency Diagram

graph TD
  5a24e873_f8af_b5d4_26ce_8f5de8d9fe83["parseAtRule()"]
  8be42ab2_7e92_957a_da93_ffe4c7d161fe["css-parser.ts"]
  5a24e873_f8af_b5d4_26ce_8f5de8d9fe83 -->|defined in| 8be42ab2_7e92_957a_da93_ffe4c7d161fe
  085cf56e_8188_afb1_04da_5ccd0fb7babc["rule()"]
  085cf56e_8188_afb1_04da_5ccd0fb7babc -->|calls| 5a24e873_f8af_b5d4_26ce_8f5de8d9fe83
  9d7d664d_b6fd_88fd_8800_4b530c33a95b["parse()"]
  9d7d664d_b6fd_88fd_8800_4b530c33a95b -->|calls| 5a24e873_f8af_b5d4_26ce_8f5de8d9fe83
  2f6881be_62d9_4b96_7331_a962ced095f7["atRule()"]
  5a24e873_f8af_b5d4_26ce_8f5de8d9fe83 -->|calls| 2f6881be_62d9_4b96_7331_a962ced095f7
  style 5a24e873_f8af_b5d4_26ce_8f5de8d9fe83 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