Skip to content

Commit

Permalink
fix: fix duplicated content in tags when using md headings
Browse files Browse the repository at this point in the history
fixes #1150, fixes #1152
  • Loading branch information
RomanHotsiy committed Jan 10, 2020
1 parent 6d9a401 commit a260c84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/MarkdownRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class MarkdownRenderer {
}

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) {
return md.substring(0, headingLinePos);
}
Expand Down
7 changes: 7 additions & 0 deletions src/services/MenuBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ export class MenuBuilder {
const renderer = new MarkdownRenderer(options);
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) =>
items.map(heading => {
const group = new GroupModel('section', heading, _parent);
Expand Down

0 comments on commit a260c84

Please sign in to comment.