MCPcopy Create free account
hub / github.com/modem-dev/hunk / parseStyleValue

Function parseStyleValue

src/ui/diff/pierre.ts:189–215  ·  view source on GitHub ↗

Parse an inline CSS style string from Pierre's highlighted HAST output.

(styleValue: unknown)

Source from the content-addressed store, hash-verified

187
188/** Parse an inline CSS style string from Pierre's highlighted HAST output. */
189function parseStyleValue(styleValue: unknown) {
190 if (typeof styleValue !== "string") {
191 return EMPTY_STYLE_VALUES;
192 }
193
194 const cached = parsedStyleValueCache.get(styleValue);
195 if (cached) {
196 return cached;
197 }
198
199 const styles = new Map<string, string>();
200 for (const segment of styleValue.split(";")) {
201 const separator = segment.indexOf(":");
202 if (separator <= 0) {
203 continue;
204 }
205
206 const key = segment.slice(0, separator).trim();
207 const value = segment.slice(separator + 1).trim();
208 if (key && value) {
209 styles.set(key, value);
210 }
211 }
212
213 parsedStyleValueCache.set(styleValue, styles);
214 return styles;
215}
216
217const RESERVED_PIERRE_TOKEN_COLORS = {
218 dark: {

Callers 1

visitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected