Files
familienarchiv/frontend/src/lib/document/transcription/transcriptionMarkers.ts
Marcel 1e656d2db4 refactor: move document transcription, annotation, viewer sub-packages
- transcription/: TranscriptionBlock, Column, EditView, PanelHeader, ReadView,
  Section + transcriptionMarkers, blockConflictMerge, saveBlockWithConflictRetry
  + useBlockAutoSave, useBlockDragDrop hooks
- annotation/: AnnotationLayer, AnnotationShape, AnnotationEditOverlay
- viewer/: PdfViewer, PdfControls + useFileLoader, usePdfRenderer hooks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 14:01:39 +02:00

26 lines
698 B
TypeScript

export type TextSegment = { type: 'text' | 'marker'; text: string };
const MARKER_PATTERN = /(\[unleserlich\]|\[\.{3}\])/g;
export function splitByMarkers(input: string): TextSegment[] {
if (!input) return [];
const segments: TextSegment[] = [];
let lastIndex = 0;
for (const match of input.matchAll(MARKER_PATTERN)) {
const matchStart = match.index;
if (matchStart > lastIndex) {
segments.push({ type: 'text', text: input.slice(lastIndex, matchStart) });
}
segments.push({ type: 'marker', text: match[0] });
lastIndex = matchStart + match[0].length;
}
if (lastIndex < input.length) {
segments.push({ type: 'text', text: input.slice(lastIndex) });
}
return segments;
}