fix: fix duplicated content in tags when using md headings

fixes #1150, fixes #1152
This commit is contained in:
Roman Hotsiy 2020-01-10 15:18:32 +02:00
parent 6d9a401b3b
commit a260c8414c
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 8 additions and 1 deletions

View File

@ -46,7 +46,7 @@ export class MarkdownRenderer {
} }
static getTextBeforeHading(md: string, heading: string): string { static getTextBeforeHading(md: string, heading: string): string {
const headingLinePos = md.search(new RegExp(`^##?\s+${heading}`, 'm')); const headingLinePos = md.search(new RegExp(`^##?\\s+${heading}`, 'm'));
if (headingLinePos > -1) { if (headingLinePos > -1) {
return md.substring(0, headingLinePos); return md.substring(0, headingLinePos);
} }

View File

@ -66,6 +66,13 @@ export class MenuBuilder {
const renderer = new MarkdownRenderer(options); const renderer = new MarkdownRenderer(options);
const headings = renderer.extractHeadings(description || ''); const headings = renderer.extractHeadings(description || '');
if (headings.length && parent && parent.description) {
parent.description = MarkdownRenderer.getTextBeforeHading(
parent.description,
headings[0].name,
);
}
const mapHeadingsDeep = (_parent, items, depth = 1) => const mapHeadingsDeep = (_parent, items, depth = 1) =>
items.map(heading => { items.map(heading => {
const group = new GroupModel('section', heading, _parent); const group = new GroupModel('section', heading, _parent);