MCPcopy
hub / github.com/tailwindlabs/tailwindcss / stringify

Function stringify

packages/tailwindcss/src/ast.ts:693–879  ·  view source on GitHub ↗
(node: AstNode, depth = 0)

Source from the content-addressed store, hash-verified

691 }
692
693 function stringify(node: AstNode, depth = 0): string {
694 let css = ''
695 let indent = ' '.repeat(depth)
696
697 // Declaration
698 if (node.kind === 'declaration') {
699 css += `${indent}${node.property}: ${node.value}${node.important ? ' !important' : ''};\n`
700
701 if (track) {
702 // indent
703 pos += indent.length
704
705 // node.property
706 let start = pos
707 pos += node.property.length
708
709 // `: `
710 pos += 2
711
712 // node.value
713 pos += node.value?.length ?? 0
714
715 // !important
716 if (node.important) {
717 pos += 11
718 }
719
720 let end = pos
721
722 // `;\n`
723 pos += 2
724
725 node.dst = [source, start, end]
726 }
727 }
728
729 // Rule
730 else if (node.kind === 'rule') {
731 css += `${indent}${node.selector} {\n`
732
733 if (track) {
734 // indent
735 pos += indent.length
736
737 // node.selector
738 let start = pos
739 pos += node.selector.length
740
741 // ` `
742 pos += 1
743
744 let end = pos
745 node.dst = [source, start, end]
746
747 // `{\n`
748 pos += 2
749 }
750

Callers 1

toCssFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected