Home / Function/ recursivelyEscapeUnderscores() — tailwindcss Function Reference

recursivelyEscapeUnderscores() — tailwindcss Function Reference

Architecture documentation for the recursivelyEscapeUnderscores() function in candidate.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  e73ecbca_812d_ed91_0c5d_af2f6a61ea6b["recursivelyEscapeUnderscores()"]
  c155249e_9c85_fd4e_2707_8f98f0ab5228["printArbitraryValueCache()"]
  c155249e_9c85_fd4e_2707_8f98f0ab5228 -->|calls| e73ecbca_812d_ed91_0c5d_af2f6a61ea6b
  33e3118a_eb66_f6f3_13f0_817d9f76edf1["escapeUnderscore()"]
  e73ecbca_812d_ed91_0c5d_af2f6a61ea6b -->|calls| 33e3118a_eb66_f6f3_13f0_817d9f76edf1
  d5900c08_585c_be5a_eb4e_8de7916692e5["never()"]
  e73ecbca_812d_ed91_0c5d_af2f6a61ea6b -->|calls| d5900c08_585c_be5a_eb4e_8de7916692e5
  style e73ecbca_812d_ed91_0c5d_af2f6a61ea6b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/candidate.ts lines 1118–1160

function recursivelyEscapeUnderscores(ast: ValueParser.ValueAstNode[]) {
  for (let node of ast) {
    switch (node.kind) {
      case 'function': {
        if (node.value === 'url' || node.value.endsWith('_url')) {
          // Don't decode underscores in url() but do decode the function name
          node.value = escapeUnderscore(node.value)
          break
        }

        if (
          node.value === 'var' ||
          node.value.endsWith('_var') ||
          node.value === 'theme' ||
          node.value.endsWith('_theme')
        ) {
          node.value = escapeUnderscore(node.value)
          for (let i = 0; i < node.nodes.length; i++) {
            recursivelyEscapeUnderscores([node.nodes[i]])
          }
          break
        }

        node.value = escapeUnderscore(node.value)
        recursivelyEscapeUnderscores(node.nodes)
        break
      }
      case 'separator':
        node.value = escapeUnderscore(node.value)
        break
      case 'word': {
        // Dashed idents and variables `var(--my-var)` and `--my-var` should not
        // have underscores escaped
        if (node.value[0] !== '-' || node.value[1] !== '-') {
          node.value = escapeUnderscore(node.value)
        }
        break
      }
      default:
        never(node)
    }
  }
}

Subdomains

Frequently Asked Questions

What does recursivelyEscapeUnderscores() do?
recursivelyEscapeUnderscores() is a function in the tailwindcss codebase.
What does recursivelyEscapeUnderscores() call?
recursivelyEscapeUnderscores() calls 2 function(s): escapeUnderscore, never.
What calls recursivelyEscapeUnderscores()?
recursivelyEscapeUnderscores() is called by 1 function(s): printArbitraryValueCache.

Analyze Your Own Codebase

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

Try Supermodel Free