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 27 28 29 30 31 32 33 34 35 36 37 38 39 | 5x 71x 71x 71x 71x 71x 953x 7x 953x 36x 917x 917x 5x 10x 5x 912x 1x | export class FormatProcessor {
private boldRegex = /(?<=[^_]|^)__([^_]+)__(?!_)/gm;
private markRegex = /==([^=]*)==/gm;
private commentRegex = /%%([^%]*)%%/gm;
process(markdown: string) {
let insideCodeBlock = false;
return markdown.split('\n')
.map((line) => {
if (line.indexOf('```') > -1) {
insideCodeBlock = !insideCodeBlock;
}
if (insideCodeBlock) {
return line;
}
else {
const split = line.split('`');
if (split.length > 1) {
for (let i = 0; i < split.length; i = i + 2) {
split[i] = split[i].replaceAll(this.boldRegex, (sub, args) => `**${args.trim()}**`)
.replaceAll(this.markRegex, '<mark>$1</mark>')
.replaceAll(this.commentRegex, '');
}
return split.join('`');
} else {
return line
.replaceAll(this.boldRegex, (sub, args) => `**${args.trim()}**`)
.replaceAll(this.markRegex, '<mark>$1</mark>')
.replaceAll(this.commentRegex, '');
}
}
})
.join('\n')
.replaceAll(this.commentRegex, '');
}
}
|