mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 13:44:54 +03:00
Fix broken Markdown headings with quotes
This commit is contained in:
parent
755a9095f5
commit
d66a05cf57
|
@ -46,7 +46,7 @@ export class MenuStore {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scroll.scrollIntoViewBySelector(`[${SECTION_ATTR}="${id}"]`);
|
scroll.scrollIntoViewBySelector(`[${SECTION_ATTR}="${MenuStore.escapeQuotes(id)}"]`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,7 +152,7 @@ export class MenuStore {
|
||||||
item = this.flatItems.find(i => SECURITY_SCHEMES_SECTION_PREFIX.startsWith(i.id));
|
item = this.flatItems.find(i => SECURITY_SCHEMES_SECTION_PREFIX.startsWith(i.id));
|
||||||
this.activate(item);
|
this.activate(item);
|
||||||
}
|
}
|
||||||
this.scroll.scrollIntoViewBySelector(`[${SECTION_ATTR}="${id}"]`);
|
this.scroll.scrollIntoViewBySelector(`[${SECTION_ATTR}="${MenuStore.escapeQuotes(id)}"]`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ export class MenuStore {
|
||||||
*/
|
*/
|
||||||
getElementAt(idx: number): Element | null {
|
getElementAt(idx: number): Element | null {
|
||||||
const item = this.flatItems[idx];
|
const item = this.flatItems[idx];
|
||||||
return (item && querySelector(`[${SECTION_ATTR}="${item.id}"]`)) || null;
|
return (item && querySelector(`[${SECTION_ATTR}="${MenuStore.escapeQuotes(item.id)}"]`)) || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,7 +174,7 @@ export class MenuStore {
|
||||||
if (item && item.type === 'group') {
|
if (item && item.type === 'group') {
|
||||||
item = item.items[0];
|
item = item.items[0];
|
||||||
}
|
}
|
||||||
return (item && querySelector(`[${SECTION_ATTR}="${item.id}"]`)) || null;
|
return (item && querySelector(`[${SECTION_ATTR}="${MenuStore.escapeQuotes(item.id)}"]`)) || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -274,4 +274,12 @@ export class MenuStore {
|
||||||
this._unsubscribe();
|
this._unsubscribe();
|
||||||
this._hashUnsubscribe();
|
this._hashUnsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static escapeQuotes(str: string) : string {
|
||||||
|
if (typeof str != 'undefined') {
|
||||||
|
str = str.replace(/["\\]/g, '\\$&');
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,5 +198,6 @@ function parseURL(url: string) {
|
||||||
export function unescapeHTMLChars(str: string): string {
|
export function unescapeHTMLChars(str: string): string {
|
||||||
return str
|
return str
|
||||||
.replace(/&#(\d+);/g, (_m, code) => String.fromCharCode(parseInt(code, 10)))
|
.replace(/&#(\d+);/g, (_m, code) => String.fromCharCode(parseInt(code, 10)))
|
||||||
.replace(/&/g, '&');
|
.replace(/&/g, '&')
|
||||||
|
.replace(/"/g, '"');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user