This commit is contained in:
Timothy Jaeryang Baek
2026-07-27 02:47:09 -04:00
parent 8e74cac8de
commit 7d77efe0f1
+19 -1
View File
@@ -63,6 +63,21 @@ function detailsStart(src: string) {
return src.match(/^<details[\s>]/) ? 0 : -1;
}
function lheadingTokenizer(this: any, src: string): any {
const cap = this.rules.block.lheading.exec(src);
const detailsIndex = cap?.[1]?.search(/\n<details[\s>]/) ?? -1;
if (!cap || detailsIndex === -1) return false;
const raw = cap[1].slice(0, detailsIndex + 1);
const text = raw.slice(0, -1);
return {
type: 'paragraph',
raw,
text,
tokens: this.lexer.inline(text)
};
}
function detailsRenderer(token: any) {
const attributesString = token.attributes
? Object.entries(token.attributes)
@@ -89,6 +104,9 @@ function detailsExtension() {
export default function (options = {}) {
return {
extensions: [detailsExtension(options)]
tokenizer: {
lheading: lheadingTokenizer as any
},
extensions: [detailsExtension()]
};
}