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
  7cb24904_9371_1e21_df0f_10f340632987["recursivelyEscapeUnderscores()"]
  258ace88_f7c6_412f_9b37_95e1bd249268["printArbitraryValueCache()"]
  258ace88_f7c6_412f_9b37_95e1bd249268 -->|calls| 7cb24904_9371_1e21_df0f_10f340632987
  e75d4265_5519_1d02_0a9d_aea6bf08284d["escapeUnderscore()"]
  7cb24904_9371_1e21_df0f_10f340632987 -->|calls| e75d4265_5519_1d02_0a9d_aea6bf08284d
  a52e2033_0772_657a_056f_09549bf75895["never()"]
  7cb24904_9371_1e21_df0f_10f340632987 -->|calls| a52e2033_0772_657a_056f_09549bf75895
  style 7cb24904_9371_1e21_df0f_10f340632987 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)
    }
  }
}

Domain

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