mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-07 13:30:33 +03:00
fix: fix duplicated content in tags when using md headings
fixes #1150, fixes #1152
This commit is contained in:
parent
6d9a401b3b
commit
a260c8414c
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user