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 OxideCore Extractor calls 1 called by 2

Entity Profile

Dependency Diagram

graph TD
  1d825a09_87b5_c531_bb8e_a4c358c7b855["parseAtRule()"]
  f4f92a3d_c13e_a751_8402_451ffa4c772f["rule()"]
  f4f92a3d_c13e_a751_8402_451ffa4c772f -->|calls| 1d825a09_87b5_c531_bb8e_a4c358c7b855
  253418a1_4f08_cf0e_5b8e_c6392b9959eb["parse()"]
  253418a1_4f08_cf0e_5b8e_c6392b9959eb -->|calls| 1d825a09_87b5_c531_bb8e_a4c358c7b855
  c35acfc6_964d_737e_6ecc_275e6f10293a["atRule()"]
  1d825a09_87b5_c531_bb8e_a4c358c7b855 -->|calls| c35acfc6_964d_737e_6ecc_275e6f10293a
  style 1d825a09_87b5_c531_bb8e_a4c358c7b855 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.
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