fix: attachHeadingsDescriptions match headings incorrectly (#1845)

* fix: attachHeadingsDescriptions match headings incorrectly

* fix: match new line instead of `$` in MarkdownRenderer.attachHeadingsDescriptions

Co-authored-by: TJT <tjt@maimemo.com>
This commit is contained in:
TJT 2021-12-31 19:00:09 +08:00 committed by GitHub
parent 831b207715
commit ea8573dbd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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