mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-25 22:01:13 +00:00
allow limited markdown in spoiler summary (#2126)
* allow limited markdown in spoiler summary * use const in markdown spoiler code
This commit is contained in:
parent
f9f8233d6f
commit
d7a80a184f
1 changed files with 4 additions and 3 deletions
|
@ -60,11 +60,12 @@ const spoilerConfig = {
|
||||||
},
|
},
|
||||||
|
|
||||||
render: (tokens: any, idx: any) => {
|
render: (tokens: any, idx: any) => {
|
||||||
var m = tokens[idx].info.trim().match(/^spoiler\s+(.*)$/);
|
const m = tokens[idx].info.trim().match(/^spoiler\s+(.*)$/);
|
||||||
|
const summary = mdToHtmlInline(md.utils.escapeHtml(m[1])).__html;
|
||||||
|
|
||||||
if (tokens[idx].nesting === 1) {
|
if (tokens[idx].nesting === 1) {
|
||||||
// opening tag
|
// opening tag
|
||||||
return `<details><summary> ${md.utils.escapeHtml(m[1])} </summary>\n`;
|
return `<details><summary> ${summary} </summary>\n`;
|
||||||
} else {
|
} else {
|
||||||
// closing tag
|
// closing tag
|
||||||
return "</details>\n";
|
return "</details>\n";
|
||||||
|
@ -110,7 +111,7 @@ function localInstanceLinkParser(md: MarkdownIt) {
|
||||||
newTokens.push(textToken);
|
newTokens.push(textToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
let href;
|
let href: string;
|
||||||
if (match[0].startsWith("!")) {
|
if (match[0].startsWith("!")) {
|
||||||
href = "/c/" + match[0].substring(1);
|
href = "/c/" + match[0].substring(1);
|
||||||
} else if (match[0].startsWith("/m/")) {
|
} else if (match[0].startsWith("/m/")) {
|
||||||
|
|
Loading…
Reference in a new issue