MCPcopy Index your code
hub / github.com/coder/coder / extractBlock

Function extractBlock

site/src/theme/cssVariables.test.ts:71–86  ·  view source on GitHub ↗
(css: string, selector: string)

Source from the content-addressed store, hash-verified

69}
70
71function extractBlock(css: string, selector: string): string | null {
72 const cssWithoutComments = stripCssComments(css);
73 for (const match of cssWithoutComments.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
74 const selectorList = match[1];
75 const block = match[2];
76 if (selectorList === undefined || block === undefined) {
77 continue;
78 }
79
80 const selectors = selectorList.split(",").map((value) => value.trim());
81 if (selectors.includes(selector)) {
82 return block;
83 }
84 }
85 return null;
86}
87
88function extractVariable(block: string, variable: string): string | null {
89 return extractVariables(block).get(variable) ?? null;

Callers 2

extractEffectiveBlockFunction · 0.85

Calls 1

stripCssCommentsFunction · 0.85

Tested by

no test coverage detected