MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / tagEnd

Function tagEnd

src/extraction/sfc-script.ts:348–372  ·  view source on GitHub ↗
(at: number)

Source from the content-addressed store, hash-verified

346
347 /** The offset after the tag that starts at `at`, or `at + 1` when no tag does (`a < b`). */
348 const tagEnd = (at: number): number => {
349 let j = at + 1;
350 let c = source.charCodeAt(j);
351 if (c === Ch.Slash) c = source.charCodeAt(++j);
352 if (!((c >= 65 && c <= 90) || (c >= 97 && c <= 122)) || wasted > limit) return at + 1;
353 // A quote opens a value only after `=`.
354 let afterEquals = false;
355 for (j++; j < n; j++) {
356 c = source.charCodeAt(j);
357 if (c === Ch.Greater) return j + 1;
358 // A second tag before this one closed: this was text.
359 if (c === Ch.Less) break;
360 if (c === Ch.OpenBrace) {
361 const end = expressionEnd(j, 0);
362 if (end > 0) j = end - 1;
363 } else if (afterEquals && (c === Ch.DoubleQuote || c === Ch.SingleQuote || (c === Ch.Backtick && host === 'astro'))) {
364 const end = c === Ch.Backtick ? templateEnd(j, 0) : attributeEnd(j, c);
365 if (end > 0) j = end - 1;
366 }
367 if (c === Ch.Equals) afterEquals = true;
368 else if (c > 32) afterEquals = false;
369 }
370 wasted += j - at;
371 return at + 1;
372 };
373
374 let i = host === 'astro' ? astroFrontmatterEnd(source) : 0;
375 while (i < n) {

Callers 1

sfcMarkupElementsFunction · 0.85

Calls 3

expressionEndFunction · 0.70
templateEndFunction · 0.70
attributeEndFunction · 0.70

Tested by

no test coverage detected