refac
This commit is contained in:
1 parent
8e74cac8de
commit
7d77efe0f1
1 file changed
+19
-1
@@ -63,6 +63,21 @@ function detailsStart(src: string) {
|
|||||||
return src.match(/^<details[\s>]/) ? 0 : -1;
|
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) {
|
function detailsRenderer(token: any) {
|
||||||
const attributesString = token.attributes
|
const attributesString = token.attributes
|
||||||
? Object.entries(token.attributes)
|
? Object.entries(token.attributes)
|
||||||
@@ -89,6 +104,9 @@ function detailsExtension() {
|
|||||||
|
|
||||||
export default function (options = {}) {
|
export default function (options = {}) {
|
||||||
return {
|
return {
|
||||||
extensions: [detailsExtension(options)]
|
tokenizer: {
|
||||||
|
lheading: lheadingTokenizer as any
|
||||||
|
},
|
||||||
|
extensions: [detailsExtension()]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user