mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-29 01:41:13 +00:00
* fix: render assistant transcript headers safely Co-authored-by: snowzlmbot <293528334+snowzlmbot@users.noreply.github.com> * fix(markdown): nest crossing annotation spans * fix(markdown): protect final transport projections * refactor(markdown): split transcript render ownership * test(ui): cover assistant transcript render flag * refactor(markdown): keep transcript helpers private * docs(changelog): note assistant transcript headers * chore(plugin-sdk): refresh transcript annotation baseline * fix(markdown): harden final transcript projections * docs(changelog): defer transcript note to release * refactor(markdown): centralize HTML tokenization * fix(markdown): satisfy lint gates --------- Co-authored-by: Peter Steinberger <steipete@gmail.com> Co-authored-by: snowzlmbot <293528334+snowzlmbot@users.noreply.github.com>
29 lines
935 B
TypeScript
29 lines
935 B
TypeScript
type SourceMappedToken = {
|
|
map?: [number, number] | null;
|
|
};
|
|
|
|
/** Prepare the next mapped block start for each token in one reverse pass. */
|
|
export function computeNextMappedBlockStarts(tokens: readonly SourceMappedToken[]) {
|
|
const nextStarts: Array<number | undefined> = [];
|
|
let nextStart: number | undefined;
|
|
for (let index = tokens.length - 1; index >= 0; index -= 1) {
|
|
nextStarts[index] = nextStart;
|
|
const currentStart = tokens[index]?.map?.[0];
|
|
if (currentStart !== undefined) {
|
|
nextStart = currentStart;
|
|
}
|
|
}
|
|
return nextStarts;
|
|
}
|
|
|
|
export function sourceBlockNewlineCount(
|
|
preserveSourceBlockSpacing: boolean,
|
|
nextBlockStart: number | undefined,
|
|
blockLineEnd: number | undefined,
|
|
): number | undefined {
|
|
if (!preserveSourceBlockSpacing || blockLineEnd === undefined) {
|
|
return undefined;
|
|
}
|
|
return nextBlockStart === undefined ? 0 : Math.max(1, nextBlockStart - blockLineEnd + 1);
|
|
}
|