refac
This commit is contained in:
1 parent
0169b10979
commit
11db926a7b
3 files changed
+27
-1
No files matched your search
@@ -107,6 +107,8 @@
|
|||||||
<br />
|
<br />
|
||||||
{:else if token.type === 'del'}
|
{:else if token.type === 'del'}
|
||||||
<del><svelte:self id={`${id}-del`} tokens={token.tokens} {onSourceClick} /></del>
|
<del><svelte:self id={`${id}-del`} tokens={token.tokens} {onSourceClick} /></del>
|
||||||
|
{:else if token.type === 'underline'}
|
||||||
|
<u><svelte:self id={`${id}-underline`} tokens={token.tokens} {onSourceClick} /></u>
|
||||||
{:else if token.type === 'inlineKatex'}
|
{:else if token.type === 'inlineKatex'}
|
||||||
{#if token.text}
|
{#if token.text}
|
||||||
<KatexRenderer content={token.text} displayMode={token?.displayMode ?? false} />
|
<KatexRenderer content={token.text} displayMode={token?.displayMode ?? false} />
|
||||||
|
|||||||
@@ -125,6 +125,11 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
turndownService.addRule('underline', {
|
||||||
|
filter: 'u',
|
||||||
|
replacement: (content) => `<u>${content}</u>`
|
||||||
|
});
|
||||||
|
|
||||||
import { onMount, onDestroy, tick, getContext } from 'svelte';
|
import { onMount, onDestroy, tick, getContext } from 'svelte';
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
|
||||||
|
|||||||
@@ -102,11 +102,30 @@ function detailsExtension() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function underlineExtension() {
|
||||||
|
return {
|
||||||
|
name: 'underline',
|
||||||
|
level: 'inline',
|
||||||
|
start: (src: string) => src.indexOf('<u>'),
|
||||||
|
tokenizer(this: any, src: string) {
|
||||||
|
const match = /^<u>([\s\S]+?)<\/u>/.exec(src);
|
||||||
|
if (!match) return;
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: 'underline',
|
||||||
|
raw: match[0],
|
||||||
|
text: match[1],
|
||||||
|
tokens: this.lexer.inlineTokens(match[1])
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export default function (options = {}) {
|
export default function (options = {}) {
|
||||||
return {
|
return {
|
||||||
tokenizer: {
|
tokenizer: {
|
||||||
lheading: lheadingTokenizer as any
|
lheading: lheadingTokenizer as any
|
||||||
},
|
},
|
||||||
extensions: [detailsExtension()]
|
extensions: [detailsExtension(), underlineExtension()]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user