F10 SLICE-2: extract colorByAuthor from renderAuthorship sentinels (#29)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -351,6 +351,22 @@ function sentinelsToSpans(html: string): string {
|
||||
.split(SENT.human.close).join("</span>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Color one prose block's HTML by F3 author spans (PUA-sentinel technique,
|
||||
* salvaged from F9 renderAuthorship). `blockStart` is the block's char offset in
|
||||
* the source so spans map correctly. Pure; deterministic.
|
||||
*/
|
||||
export function colorByAuthor(
|
||||
raw: string,
|
||||
blockStart: number,
|
||||
spans: AuthorSpan[],
|
||||
render: (src: string) => string,
|
||||
): string {
|
||||
const overlapping = spans.filter((s) => s.end > blockStart && s.start < blockStart + raw.length);
|
||||
const injected = injectSentinels(raw, blockStart, overlapping);
|
||||
return sentinelsToSpans(render(injected));
|
||||
}
|
||||
|
||||
/**
|
||||
* Pure authorship render (INV-26/28): the CURRENT text with each F3-attributed
|
||||
* span colored by author. Prose blocks get inline `<span class="cw-by-*">`;
|
||||
@@ -379,8 +395,7 @@ export function renderAuthorship(
|
||||
if (!badge) return `<div class="cw-blk">${inner}</div>`;
|
||||
return `<div class="cw-blk ${badge.cls}"><span class="cw-badge">${badge.label}</span>${inner}</div>`;
|
||||
}
|
||||
const injected = injectSentinels(b.raw, b.start, overlapping);
|
||||
return `<div class="cw-blk">${sentinelsToSpans(safe(injected))}</div>`;
|
||||
return `<div class="cw-blk">${colorByAuthor(b.raw, b.start, overlapping, safe)}</div>`;
|
||||
})
|
||||
.join("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user