All files / src/processors commentProcessor.ts

100% Statements 8/8
100% Branches 2/2
100% Functions 3/3
100% Lines 8/8

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 215x   5x 71x   71x     71x     1294x 126x   1168x            
import { CommentParser } from 'src/comment';
 
export class CommentProcessor {
	private readCommentRegex = /<!--.*-->/;
 
	private parser: CommentParser = new CommentParser();
 
	process(markdown: string) {
		return markdown
			.split('\n')
			.map(line => {
				if (this.parser.lineHasComment(line)) {
					return line.replace(this.readCommentRegex, this.parser.commentToString(this.parser.parseLine(line)));
				} else {
					return line;
				}
			})
			.join('\n');
	}
}