MCPcopy Create free account
hub / github.com/Alphanimble/htmlstream / sliceImplicitTbody

Function sliceImplicitTbody

src/patch-streaming-html.ts:515–531  ·  view source on GitHub ↗

Body rows without an explicit wrapper

(tableSection: string)

Source from the content-addressed store, hash-verified

513
514/** Body rows without an explicit <tbody> wrapper */
515function sliceImplicitTbody(tableSection: string): string {
516 const afterThead = tableSection.match(/<\/thead>/i);
517 if (!afterThead && /<thead\b/i.test(tableSection)) {
518 // Open thead — rows still belong to header, not implicit tbody
519 return "";
520 }
521
522 const start = afterThead
523 ? afterThead.index! + afterThead[0].length
524 : tableSection.search(/<tr\b/i);
525 if (start === -1) {
526 return "";
527 }
528 const slice = tableSection.slice(start);
529 const tableEnd = slice.search(/<\/table>/i);
530 return tableEnd === -1 ? slice : slice.slice(0, tableEnd);
531}
532
533function splitTableStream(tableSection: string): TableStreamParts {
534 const theadPart = sliceTagSection(tableSection, "thead");

Callers 1

sliceTagSectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected