All files / src/processors mermaidProcessor.ts

92.3% Statements 12/13
66.66% Branches 2/3
100% Functions 2/2
92.3% Lines 12/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 275x   71x       72x   72x 71x   1x 1x       1x 1x 1x   1x   1x        
export class MermaidProcessor {
	process(markdown: string) {
		return this.transformMermaid(markdown);
	}
 
	transformMermaid(markdown: string): string {
		const startIdx = markdown.indexOf('```mermaid');
 
		if (startIdx < 0) {
			return markdown;
		} else {
			const endIdx = markdown.indexOf('```', startIdx + 11);
			Iif (endIdx < 0) {
				return markdown;
			}
 
			const before = markdown.substring(0, startIdx);
			const after = markdown.substring(endIdx + 3);
			const content = markdown.substring(startIdx + 11, endIdx);
 
			const result = before + '\n' + '<div class="mermaid">' + '\n' + content + '\n' + '</div>' + '\n' + after;
 
			return this.transformMermaid(result);
		}
	}
}