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

Function apply_script_attribute

internal/cbm/extract_imports.c:2035–2062  ·  view source on GitHub ↗

Apply one attribute to the parse decision. Returns false when the * attribute rules the block out of inline extraction: * src= always names an external program, so nothing inline is extracted, * even for malformed mixed markup; * lang= selects the JavaScript or TypeScript grammar; any other language * has no parser here; * type= plain HTML routinely carri

Source from the content-addressed store, hash-verified

2033 * current use pass — absent or empty, module, text/javascript,
2034 * application/javascript — and the rest bail. */
2035static bool apply_script_attribute(CBMExtractCtx *ctx, TSNode attribute, CBMLanguage *language) {
2036 if (ts_node_named_child_count(attribute) == 0) {
2037 return false;
2038 }
2039 const char *name = cbm_node_text(ctx->arena, ts_node_named_child(attribute, 0), ctx->source);
2040 if (ascii_trimmed_equals(name, "src")) {
2041 return false;
2042 }
2043 if (ascii_trimmed_equals(name, "lang")) {
2044 const char *value = script_attribute_value(ctx, attribute);
2045 if (ascii_trimmed_equals(value, "js") || ascii_trimmed_equals(value, "javascript")) {
2046 *language = CBM_LANG_JAVASCRIPT;
2047 return true;
2048 }
2049 if (ascii_trimmed_equals(value, "ts") || ascii_trimmed_equals(value, "typescript")) {
2050 *language = CBM_LANG_TYPESCRIPT;
2051 return true;
2052 }
2053 return false;
2054 }
2055 if (ascii_trimmed_equals(name, "type")) {
2056 const char *value = script_attribute_value(ctx, attribute);
2057 return ascii_trimmed_equals(value, "") || ascii_trimmed_equals(value, "module") ||
2058 ascii_trimmed_equals(value, "text/javascript") ||
2059 ascii_trimmed_equals(value, "application/javascript");
2060 }
2061 return true;
2062}
2063
2064/* Markup hosts (Vue, Svelte, HTML, Astro) hang the attributes that decide
2065 * whether and how an inline program is parsed off the <script> start tag.

Callers 1

script_embedded_languageFunction · 0.85

Calls 3

cbm_node_textFunction · 0.85
ascii_trimmed_equalsFunction · 0.85
script_attribute_valueFunction · 0.85

Tested by

no test coverage detected