fix: broken rendering of headings with regexp characters

This commit is contained in:
Roman Hotsiy 2018-08-11 23:14:09 +03:00
parent ec8f6dc09e
commit e660517a2a
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -78,7 +78,9 @@ export class MarkdownRenderer {
}
attachHeadingsDescriptions(rawText: string) {
const buildRegexp = heading => new RegExp(`##?\\s+${heading.name}`);
const buildRegexp = heading => {
return new RegExp(`##?\\s+${heading.name.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')}`);
};
const flatHeadings = this.flattenHeadings(this.headings);
if (flatHeadings.length < 1) {