MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / script_embedded_language

Function script_embedded_language

internal/cbm/extract_imports.c:2069–2091  ·  view source on GitHub ↗

Markup hosts (Vue, Svelte, HTML, Astro) hang the attributes that decide * whether and how an inline program is parsed off the start tag. * *language enters holding the spec row's default and leaves holding the * grammar to parse with; an attribute-free block (Astro's frontmatter fence) * keeps the row's language rather than falling through to JavaScript. */

Source from the content-addressed store, hash-verified

2067 * grammar to parse with; an attribute-free block (Astro's frontmatter fence)
2068 * keeps the row's language rather than falling through to JavaScript. */
2069static bool script_embedded_language(CBMExtractCtx *ctx, TSNode script, CBMLanguage *language) {
2070 enum { SCRIPT_ATTR_STACK_CAP = 128 };
2071 TSNode stack[SCRIPT_ATTR_STACK_CAP];
2072 int top = 0;
2073 stack[top++] = script;
2074 while (top > 0) {
2075 TSNode node = stack[--top];
2076 if (strcmp(ts_node_type(node), "attribute") == 0) {
2077 if (!apply_script_attribute(ctx, node, language)) {
2078 return false;
2079 }
2080 continue;
2081 }
2082 uint32_t count = ts_node_named_child_count(node);
2083 if ((int)count > SCRIPT_ATTR_STACK_CAP - top) {
2084 return false;
2085 }
2086 for (int i = (int)count - 1; i >= 0; i--) {
2087 stack[top++] = ts_node_named_child(node, (uint32_t)i);
2088 }
2089 }
2090 return true;
2091}
2092
2093/* CFML's <cfscript> carries no attributes and its embedded language is fixed
2094 * by the spec row; only the markup hosts consult the <script> tag. */

Callers 1

parse_embedded_importsFunction · 0.85

Calls 1

apply_script_attributeFunction · 0.85

Tested by

no test coverage detected