mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-13 01:02:25 -06:00
refac
This commit is contained in:
@@ -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()]
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user