@svadmin/ai-elements 0.5.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -53
- package/THIRD_PARTY_NOTICES.md +67 -6
- package/dist/ai.css +149 -2740
- package/dist/ai.theme.css +1 -2771
- package/dist/class-properties.generated.d.ts +1 -0
- package/dist/class-properties.generated.js +2 -0
- package/dist/classnames.d.ts +8 -0
- package/dist/classnames.js +26 -0
- package/dist/components/AICommandBar.svelte +6 -4
- package/dist/components/ChatDialog.svelte +102 -125
- package/dist/components/ChatDialog.svelte.d.ts +3 -9
- package/dist/components/Conversation.svelte +34 -10
- package/dist/components/ConversationContent.svelte +1 -1
- package/dist/components/ConversationScrollButton.svelte +0 -1
- package/dist/components/CopilotPanel.svelte +8 -6
- package/dist/components/Message.svelte +1 -1
- package/dist/components/MessageActions.svelte +1 -1
- package/dist/components/MessageContent.svelte +1 -1
- package/dist/components/MessageToolbar.svelte +1 -1
- package/dist/components/Response.svelte +32 -12
- package/dist/components/Response.svelte.d.ts +3 -3
- package/dist/components/Tool.svelte +13 -13
- package/dist/components/Tool.svelte.d.ts +1 -1
- package/dist/components/action/Action.svelte +3 -1
- package/dist/components/artifact/ArtifactAction.svelte +3 -1
- package/dist/components/attachments/Attachment.svelte +4 -2
- package/dist/components/attachments/Attachments.svelte +3 -1
- package/dist/components/attachments/types.js +3 -2
- package/dist/components/audio-player/AudioPlayer.svelte.d.ts +1 -1
- package/dist/components/canvas/Canvas.svelte +1 -1
- package/dist/components/checkpoint/index.d.ts +2 -2
- package/dist/components/code/index.d.ts +9 -1
- package/dist/components/code/index.js +8 -1
- package/dist/components/code-block/CodeBlockLanguageSelector.svelte.d.ts +1 -1
- package/dist/components/code-block/highlight.js +11 -10
- package/dist/components/commit/Commit.svelte +23 -2
- package/dist/components/commit/CommitActions.svelte +2 -11
- package/dist/components/commit/CommitCopyButton.svelte +1 -1
- package/dist/components/commit/CommitHeader.svelte +12 -2
- package/dist/components/commit/context.svelte.d.ts +6 -0
- package/dist/components/commit/context.svelte.js +14 -0
- package/dist/components/context/Context.svelte +6 -4
- package/dist/components/context/TokensWithCost.svelte +2 -1
- package/dist/components/edge/Animated.svelte +6 -6
- package/dist/components/edge/Temporary.svelte +6 -5
- package/dist/components/file-tree/FileTree.svelte +7 -5
- package/dist/components/jsx-preview/parser.js +10 -10
- package/dist/components/message/MessageAction.svelte +3 -1
- package/dist/components/mic-selector/MicSelector.svelte.d.ts +1 -1
- package/dist/components/model-selector/ModelSelectorDialog.svelte +3 -1
- package/dist/components/open-in-chat/OpenInChatGPT.svelte +3 -1
- package/dist/components/open-in-chat/OpenInClaude.svelte +3 -1
- package/dist/components/open-in-chat/OpenInCursor.svelte +3 -1
- package/dist/components/open-in-chat/OpenInGitHub.svelte +3 -1
- package/dist/components/open-in-chat/OpenInScira.svelte +3 -1
- package/dist/components/open-in-chat/OpenInT3.svelte +3 -1
- package/dist/components/open-in-chat/OpenInv0.svelte +3 -1
- package/dist/components/package-info/PackageInfo.svelte +3 -1
- package/dist/components/prompt-input/PromptInput.svelte +8 -18
- package/dist/components/prompt-input/PromptInputCommand.svelte +2 -1
- package/dist/components/prompt-input/PromptInputSelect.svelte.d.ts +1 -1
- package/dist/components/prompt-input/PromptInputSubmit.svelte +5 -18
- package/dist/components/prompt-input/PromptInputTextarea.svelte +6 -11
- package/dist/components/prompt-input/context.svelte.d.ts +1 -8
- package/dist/components/prompt-input/files.js +3 -2
- package/dist/components/question/Question.svelte +3 -1
- package/dist/components/schema-display/SchemaDisplay.svelte +4 -2
- package/dist/components/schema-display/SchemaDisplayParameter.svelte +14 -1
- package/dist/components/schema-display/SchemaDisplayProperty.svelte +16 -1
- package/dist/components/snippet/index.d.ts +3 -3
- package/dist/components/stack-trace/StackTrace.svelte +7 -5
- package/dist/components/suggestion/index.d.ts +1 -1
- package/dist/components/terminal/Terminal.svelte +4 -2
- package/dist/components/terminal/ansi.js +9 -6
- package/dist/components/test-results/Test.svelte +1 -1
- package/dist/components/test-results/TestResults.svelte +1 -1
- package/dist/components/test-results/context.svelte.d.ts +1 -1
- package/dist/components/tool/ToolContent.svelte +1 -1
- package/dist/components/tool/ToolHeader.svelte +5 -5
- package/dist/components/tool/ToolInput.svelte +2 -4
- package/dist/components/tool/ToolOutput.svelte +2 -4
- package/dist/components/tool/ToolStatusBadge.svelte +2 -3
- package/dist/components/voice-selector/VoiceSelector.svelte +2 -1
- package/dist/components/voice-selector/VoiceSelector.svelte.d.ts +2 -2
- package/dist/components/voice-selector/context.svelte.d.ts +2 -1
- package/dist/components/web-preview/WebPreview.svelte +4 -3
- package/dist/contracts.d.ts +2 -2
- package/dist/generated-components.d.ts +15 -1
- package/dist/generated-components.js +20 -1
- package/dist/internal/Tooltip.svelte +2 -1
- package/dist/parity-manifest.d.ts +0 -1
- package/dist/parity-manifest.js +0 -97
- package/dist/utilities.css +3172 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +37 -22
- package/vendor/streamdown/AnimatedText.svelte +93 -0
- package/vendor/streamdown/AnimatedText.svelte.d.ts +6 -0
- package/vendor/streamdown/Block.svelte +96 -0
- package/vendor/streamdown/Block.svelte.d.ts +11 -0
- package/vendor/streamdown/Elements/Alert.svelte +69 -0
- package/vendor/streamdown/Elements/Alert.svelte.d.ts +10 -0
- package/vendor/streamdown/Elements/Citation.svelte +260 -0
- package/vendor/streamdown/Elements/Citation.svelte.d.ts +7 -0
- package/vendor/streamdown/Elements/Code.svelte +226 -0
- package/vendor/streamdown/Elements/Code.svelte.d.ts +9 -0
- package/vendor/streamdown/Elements/Element.svelte +574 -0
- package/vendor/streamdown/Elements/Element.svelte.d.ts +10 -0
- package/vendor/streamdown/Elements/FootnoteRef.svelte +30 -0
- package/vendor/streamdown/Elements/FootnoteRef.svelte.d.ts +7 -0
- package/vendor/streamdown/Elements/Footnotes.svelte +54 -0
- package/vendor/streamdown/Elements/Footnotes.svelte.d.ts +7 -0
- package/vendor/streamdown/Elements/Image.svelte +200 -0
- package/vendor/streamdown/Elements/Image.svelte.d.ts +10 -0
- package/vendor/streamdown/Elements/Link.svelte +220 -0
- package/vendor/streamdown/Elements/Link.svelte.d.ts +10 -0
- package/vendor/streamdown/Elements/LinkSafetyModal.svelte +121 -0
- package/vendor/streamdown/Elements/LinkSafetyModal.svelte.d.ts +4 -0
- package/vendor/streamdown/Elements/Math.svelte +100 -0
- package/vendor/streamdown/Elements/Math.svelte.d.ts +9 -0
- package/vendor/streamdown/Elements/Mermaid.svelte +455 -0
- package/vendor/streamdown/Elements/Mermaid.svelte.d.ts +9 -0
- package/vendor/streamdown/Elements/MermaidDownload.svelte +145 -0
- package/vendor/streamdown/Elements/MermaidDownload.svelte.d.ts +8 -0
- package/vendor/streamdown/Elements/Slot.svelte +23 -0
- package/vendor/streamdown/Elements/Slot.svelte.d.ts +10 -0
- package/vendor/streamdown/Elements/Table.svelte +195 -0
- package/vendor/streamdown/Elements/Table.svelte.d.ts +9 -0
- package/vendor/streamdown/Elements/TableDownload.svelte +221 -0
- package/vendor/streamdown/Elements/TableDownload.svelte.d.ts +8 -0
- package/vendor/streamdown/Elements/fallbacks/CodeFallback.svelte +41 -0
- package/vendor/streamdown/Elements/fallbacks/CodeFallback.svelte.d.ts +9 -0
- package/vendor/streamdown/Elements/fallbacks/MathFallback.svelte +35 -0
- package/vendor/streamdown/Elements/fallbacks/MathFallback.svelte.d.ts +8 -0
- package/vendor/streamdown/Elements/fallbacks/MermaidFallback.svelte +36 -0
- package/vendor/streamdown/Elements/fallbacks/MermaidFallback.svelte.d.ts +9 -0
- package/vendor/streamdown/Elements/fallbacks/index.d.ts +3 -0
- package/vendor/streamdown/Elements/fallbacks/index.js +3 -0
- package/vendor/streamdown/Elements/icons.d.ts +31 -0
- package/vendor/streamdown/Elements/icons.js +200 -0
- package/vendor/streamdown/Elements/index.d.ts +8 -0
- package/vendor/streamdown/Elements/index.js +8 -0
- package/vendor/streamdown/Elements/popover.svelte.d.ts +8 -0
- package/vendor/streamdown/Elements/popover.svelte.js +45 -0
- package/vendor/streamdown/Elements/stepperState.svelte.d.ts +36 -0
- package/vendor/streamdown/Elements/stepperState.svelte.js +92 -0
- package/vendor/streamdown/IconProvider.svelte +11 -0
- package/vendor/streamdown/IconProvider.svelte.d.ts +30 -0
- package/vendor/streamdown/LICENSE +202 -0
- package/vendor/streamdown/PluginProvider.svelte +11 -0
- package/vendor/streamdown/PluginProvider.svelte.d.ts +30 -0
- package/vendor/streamdown/README.svadmin.md +5 -0
- package/vendor/streamdown/Streamdown.svelte +447 -0
- package/vendor/streamdown/Streamdown.svelte.d.ts +25 -0
- package/vendor/streamdown/block/BlockTokens.svelte +45 -0
- package/vendor/streamdown/block/BlockTokens.svelte.d.ts +9 -0
- package/vendor/streamdown/block/html.d.ts +14 -0
- package/vendor/streamdown/block/html.js +27 -0
- package/vendor/streamdown/block/text.d.ts +10 -0
- package/vendor/streamdown/block/text.js +31 -0
- package/vendor/streamdown/context-key.d.ts +1 -0
- package/vendor/streamdown/context-key.js +1 -0
- package/vendor/streamdown/context.svelte.d.ts +24 -0
- package/vendor/streamdown/context.svelte.js +75 -0
- package/vendor/streamdown/contracts/plugins.d.ts +26 -0
- package/vendor/streamdown/contracts/plugins.js +1 -0
- package/vendor/streamdown/contracts/streamdown.d.ts +374 -0
- package/vendor/streamdown/contracts/streamdown.js +29 -0
- package/vendor/streamdown/detect-direction.d.ts +1 -0
- package/vendor/streamdown/detect-direction.js +1 -0
- package/vendor/streamdown/icon-context.d.ts +36 -0
- package/vendor/streamdown/icon-context.js +52 -0
- package/vendor/streamdown/incomplete-code.d.ts +6 -0
- package/vendor/streamdown/incomplete-code.js +23 -0
- package/vendor/streamdown/index.d.ts +22 -0
- package/vendor/streamdown/index.js +20 -0
- package/vendor/streamdown/markdown-parse-cache.d.ts +37 -0
- package/vendor/streamdown/markdown-parse-cache.js +109 -0
- package/vendor/streamdown/markdown.d.ts +21 -0
- package/vendor/streamdown/markdown.js +214 -0
- package/vendor/streamdown/marked/index.d.ts +44 -0
- package/vendor/streamdown/marked/index.js +228 -0
- package/vendor/streamdown/marked/marked-alert.d.ts +13 -0
- package/vendor/streamdown/marked/marked-alert.js +47 -0
- package/vendor/streamdown/marked/marked-align.d.ts +10 -0
- package/vendor/streamdown/marked/marked-align.js +45 -0
- package/vendor/streamdown/marked/marked-br.d.ts +6 -0
- package/vendor/streamdown/marked/marked-br.js +15 -0
- package/vendor/streamdown/marked/marked-citations.d.ts +8 -0
- package/vendor/streamdown/marked/marked-citations.js +53 -0
- package/vendor/streamdown/marked/marked-cjk.d.ts +2 -0
- package/vendor/streamdown/marked/marked-cjk.js +165 -0
- package/vendor/streamdown/marked/marked-dl.d.ts +23 -0
- package/vendor/streamdown/marked/marked-dl.js +44 -0
- package/vendor/streamdown/marked/marked-footnotes.d.ts +26 -0
- package/vendor/streamdown/marked/marked-footnotes.js +101 -0
- package/vendor/streamdown/marked/marked-hr.d.ts +6 -0
- package/vendor/streamdown/marked/marked-hr.js +18 -0
- package/vendor/streamdown/marked/marked-list.d.ts +31 -0
- package/vendor/streamdown/marked/marked-list.js +330 -0
- package/vendor/streamdown/marked/marked-math.d.ts +13 -0
- package/vendor/streamdown/marked/marked-math.js +129 -0
- package/vendor/streamdown/marked/marked-mdx.d.ts +12 -0
- package/vendor/streamdown/marked/marked-mdx.js +124 -0
- package/vendor/streamdown/marked/marked-subsup.d.ts +22 -0
- package/vendor/streamdown/marked/marked-subsup.js +40 -0
- package/vendor/streamdown/marked/marked-table.d.ts +80 -0
- package/vendor/streamdown/marked/marked-table.js +527 -0
- package/vendor/streamdown/plugin-context.d.ts +19 -0
- package/vendor/streamdown/plugin-context.js +40 -0
- package/vendor/streamdown/plugins/cjk-shared.d.ts +1 -0
- package/vendor/streamdown/plugins/cjk-shared.js +1 -0
- package/vendor/streamdown/plugins.d.ts +19 -0
- package/vendor/streamdown/plugins.js +107 -0
- package/vendor/streamdown/provenance.json +229 -0
- package/vendor/streamdown/remend.d.ts +2 -0
- package/vendor/streamdown/remend.js +1 -0
- package/vendor/streamdown/security/html.d.ts +19 -0
- package/vendor/streamdown/security/html.js +329 -0
- package/vendor/streamdown/security/preprocess-custom-tags.d.ts +1 -0
- package/vendor/streamdown/security/preprocess-custom-tags.js +20 -0
- package/vendor/streamdown/security/preprocess-literal-tag-content.d.ts +1 -0
- package/vendor/streamdown/security/preprocess-literal-tag-content.js +16 -0
- package/vendor/streamdown/security/types.d.ts +1 -0
- package/vendor/streamdown/security/types.js +1 -0
- package/vendor/streamdown/site/SiteHeader.svelte +94 -0
- package/vendor/streamdown/site/SiteHeader.svelte.d.ts +6 -0
- package/vendor/streamdown/site/home/HomeDemo.svelte +122 -0
- package/vendor/streamdown/site/home/HomeDemo.svelte.d.ts +3 -0
- package/vendor/streamdown/site/home/HomePage.svelte +293 -0
- package/vendor/streamdown/site/home/HomePage.svelte.d.ts +3 -0
- package/vendor/streamdown/site/home/content.d.ts +69 -0
- package/vendor/streamdown/site/home/content.js +144 -0
- package/vendor/streamdown/site/metadata.d.ts +4 -0
- package/vendor/streamdown/site/metadata.js +4 -0
- package/vendor/streamdown/site/navigation.d.ts +6 -0
- package/vendor/streamdown/site/navigation.js +22 -0
- package/vendor/streamdown/streamdown/config.d.ts +41 -0
- package/vendor/streamdown/streamdown/config.js +125 -0
- package/vendor/streamdown/streamdown/context.d.ts +12 -0
- package/vendor/streamdown/streamdown/context.js +2 -0
- package/vendor/streamdown/streamdown/incomplete-markdown.d.ts +5 -0
- package/vendor/streamdown/streamdown/incomplete-markdown.js +79 -0
- package/vendor/streamdown/streamdown/pipeline.d.ts +95 -0
- package/vendor/streamdown/streamdown/pipeline.js +138 -0
- package/vendor/streamdown/streamdown/runtime.d.ts +59 -0
- package/vendor/streamdown/streamdown/runtime.js +112 -0
- package/vendor/streamdown/streaming.d.ts +5 -0
- package/vendor/streamdown/streaming.js +5 -0
- package/vendor/streamdown/theme.d.ts +486 -0
- package/vendor/streamdown/theme.js +370 -0
- package/vendor/streamdown/translations.d.ts +43 -0
- package/vendor/streamdown/translations.js +54 -0
- package/vendor/streamdown/url-policy.d.ts +1 -0
- package/vendor/streamdown/url-policy.js +1 -0
- package/vendor/streamdown/utils/bind.d.ts +8 -0
- package/vendor/streamdown/utils/bind.js +26 -0
- package/vendor/streamdown/utils/bundledLanguages.d.ts +1 -0
- package/vendor/streamdown/utils/bundledLanguages.js +1 -0
- package/vendor/streamdown/utils/code-block.d.ts +8 -0
- package/vendor/streamdown/utils/code-block.js +38 -0
- package/vendor/streamdown/utils/copy.svelte.d.ts +7 -0
- package/vendor/streamdown/utils/copy.svelte.js +38 -0
- package/vendor/streamdown/utils/darkMode.svelte.d.ts +3 -0
- package/vendor/streamdown/utils/darkMode.svelte.js +49 -0
- package/vendor/streamdown/utils/detectDirection.d.ts +1 -0
- package/vendor/streamdown/utils/detectDirection.js +19 -0
- package/vendor/streamdown/utils/get.d.ts +1 -0
- package/vendor/streamdown/utils/get.js +25 -0
- package/vendor/streamdown/utils/hightlighter.svelte.d.ts +30 -0
- package/vendor/streamdown/utils/hightlighter.svelte.js +524 -0
- package/vendor/streamdown/utils/index.d.ts +3 -0
- package/vendor/streamdown/utils/index.js +3 -0
- package/vendor/streamdown/utils/mermaid.d.ts +13 -0
- package/vendor/streamdown/utils/mermaid.js +49 -0
- package/vendor/streamdown/utils/panzoom.svelte.d.ts +35 -0
- package/vendor/streamdown/utils/panzoom.svelte.js +556 -0
- package/vendor/streamdown/utils/parse-incomplete-markdown.d.ts +2 -0
- package/vendor/streamdown/utils/parse-incomplete-markdown.js +2 -0
- package/vendor/streamdown/utils/runtime-env.d.ts +1 -0
- package/vendor/streamdown/utils/runtime-env.js +13 -0
- package/vendor/streamdown/utils/save.d.ts +1 -0
- package/vendor/streamdown/utils/save.js +14 -0
- package/vendor/streamdown/utils/scroll-lock.d.ts +2 -0
- package/vendor/streamdown/utils/scroll-lock.js +35 -0
- package/vendor/streamdown/utils/table.d.ts +8 -0
- package/vendor/streamdown/utils/table.js +176 -0
- package/vendor/streamdown/utils/url.d.ts +22 -0
- package/vendor/streamdown/utils/url.js +98 -0
- package/vendor/streamdown/utils/useClickOutside.svelte.d.ts +8 -0
- package/vendor/streamdown/utils/useClickOutside.svelte.js +41 -0
- package/vendor/streamdown/utils/useKeyDown.svelte.d.ts +5 -0
- package/vendor/streamdown/utils/useKeyDown.svelte.js +23 -0
- package/UPSTREAM_PARITY.md +0 -69
- package/dist/ai-theme.css +0 -28
- package/dist/components/code/code-variants.d.ts +0 -25
- package/dist/components/code/code-variants.js +0 -20
- package/dist/components/conversation/scroll.d.ts +0 -4
- package/dist/components/conversation/scroll.js +0 -85
- package/dist/components/message/content-polish-html.d.ts +0 -5
- package/dist/components/message/content-polish-html.js +0 -75
- package/dist/components/tool/content-polish-scroll-region.d.ts +0 -3
- package/dist/components/tool/content-polish-scroll-region.js +0 -22
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Extension } from './index.js';
|
|
2
|
+
import type { Tokenizer, Tokens } from 'marked';
|
|
3
|
+
type variantType = 'note' | 'tip' | 'important' | 'warning' | 'caution';
|
|
4
|
+
export declare function createSyntaxPattern(type: variantType): string;
|
|
5
|
+
export declare const markedAlert: Extension;
|
|
6
|
+
export declare function processAlertToken(token: Tokens.Blockquote, tokenizer: Tokenizer): void;
|
|
7
|
+
export type AlertToken = {
|
|
8
|
+
type: 'alert';
|
|
9
|
+
variant: variantType;
|
|
10
|
+
raw: string;
|
|
11
|
+
text: string;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Lexer } from 'marked';
|
|
2
|
+
const variants = ['note', 'tip', 'important', 'warning', 'caution'];
|
|
3
|
+
export function createSyntaxPattern(type) {
|
|
4
|
+
return `^\\s*[\\*_]*\\[!${type.toUpperCase()}\\][\\*_]*\\s*`;
|
|
5
|
+
}
|
|
6
|
+
const defaultLexer = new Lexer({ gfm: true });
|
|
7
|
+
const defaultTokenizer = defaultLexer.options.tokenizer;
|
|
8
|
+
export const markedAlert = {
|
|
9
|
+
name: 'alert',
|
|
10
|
+
level: 'block',
|
|
11
|
+
tokenizer(src) {
|
|
12
|
+
const cap = defaultTokenizer.rules.block.blockquote.exec(src);
|
|
13
|
+
if (cap) {
|
|
14
|
+
const blockquoteToken = defaultTokenizer.blockquote(src);
|
|
15
|
+
blockquoteToken && processAlertToken(blockquoteToken, this.lexer.options.tokenizer);
|
|
16
|
+
return blockquoteToken;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export function processAlertToken(token, tokenizer) {
|
|
21
|
+
const matchedVariant = variants.find((type) => new RegExp(createSyntaxPattern(type), 'i').test(('text' in token && token.text) || ''));
|
|
22
|
+
if (!matchedVariant) {
|
|
23
|
+
Object.assign(token, {
|
|
24
|
+
tokens: token.tokens
|
|
25
|
+
.map((token) => {
|
|
26
|
+
return tokenizer.lexer.blockTokens(token.raw, [])[0];
|
|
27
|
+
})
|
|
28
|
+
.filter(Boolean)
|
|
29
|
+
});
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const alertPattern = new RegExp(`[\\*_]*\\[!${matchedVariant.toUpperCase()}\\][\\*_]*`, 'g');
|
|
33
|
+
const tokens = token.tokens
|
|
34
|
+
.map((token) => {
|
|
35
|
+
let cleanedRaw = token.raw;
|
|
36
|
+
// Remove alert markers with any markdown formatting (asterisks/underscores)
|
|
37
|
+
cleanedRaw = cleanedRaw.replaceAll(alertPattern, '').trim();
|
|
38
|
+
return tokenizer.lexer.blockTokens(cleanedRaw, [])[0];
|
|
39
|
+
})
|
|
40
|
+
.filter(Boolean);
|
|
41
|
+
Object.assign(token, {
|
|
42
|
+
type: 'alert',
|
|
43
|
+
variant: matchedVariant,
|
|
44
|
+
tokens,
|
|
45
|
+
text: token.text.replace(alertPattern, '').trim()
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Extension } from './index.js';
|
|
2
|
+
import type { Token } from 'marked';
|
|
3
|
+
export declare const markedAlign: Extension;
|
|
4
|
+
export type AlignToken = {
|
|
5
|
+
type: 'align';
|
|
6
|
+
align: 'center' | 'right';
|
|
7
|
+
raw: string;
|
|
8
|
+
text: string;
|
|
9
|
+
tokens: Token[];
|
|
10
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const tokenizeAlignBlock = (src, align, blockTokens) => {
|
|
2
|
+
const openingTag = `[${align}]`;
|
|
3
|
+
const closingTag = `[/${align}]`;
|
|
4
|
+
if (!src.startsWith(openingTag)) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
const lines = src.split('\n');
|
|
8
|
+
if (lines[0].trim() !== openingTag) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
let contentEndLine = -1;
|
|
12
|
+
let hasClosingTag = false;
|
|
13
|
+
for (let i = 1; i < lines.length; i++) {
|
|
14
|
+
const trimmed = lines[i].trim();
|
|
15
|
+
if (trimmed === closingTag) {
|
|
16
|
+
contentEndLine = i - 1;
|
|
17
|
+
hasClosingTag = true;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
if (trimmed === '[center]' || trimmed === '[right]') {
|
|
21
|
+
contentEndLine = i - 1;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (contentEndLine === -1 && !hasClosingTag) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const text = lines.slice(1, contentEndLine + 1).join('\n');
|
|
29
|
+
const raw = lines.slice(0, hasClosingTag ? contentEndLine + 2 : contentEndLine + 1).join('\n');
|
|
30
|
+
return {
|
|
31
|
+
type: 'align',
|
|
32
|
+
align,
|
|
33
|
+
raw,
|
|
34
|
+
text,
|
|
35
|
+
tokens: blockTokens(text, [])
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export const markedAlign = {
|
|
39
|
+
name: 'align',
|
|
40
|
+
level: 'block',
|
|
41
|
+
tokenizer(src) {
|
|
42
|
+
return (tokenizeAlignBlock(src, 'center', this.lexer.blockTokens.bind(this.lexer)) ??
|
|
43
|
+
tokenizeAlignBlock(src, 'right', this.lexer.blockTokens.bind(this.lexer)));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const markedBr = {
|
|
2
|
+
name: 'br',
|
|
3
|
+
level: 'inline',
|
|
4
|
+
tokenizer(src) {
|
|
5
|
+
// Match HTML <br> tags (with or without closing slash, case insensitive)
|
|
6
|
+
const match = src.match(/^<br\s*\/?>/i);
|
|
7
|
+
if (match) {
|
|
8
|
+
return {
|
|
9
|
+
type: 'br',
|
|
10
|
+
raw: match[0]
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const markedCitations = {
|
|
2
|
+
name: 'citations',
|
|
3
|
+
level: 'inline',
|
|
4
|
+
start(src) {
|
|
5
|
+
return src.indexOf('[') === -1 ? -1 : 0;
|
|
6
|
+
},
|
|
7
|
+
tokenizer(src) {
|
|
8
|
+
// Match inline citations like [1], [ref], [1] [2], [ref] [ref2], etc.
|
|
9
|
+
// Requires non-empty bracket contents and spaces between adjacent citation brackets
|
|
10
|
+
const match = src.match(/^\[[^\[\]]+\](?:\s+\[[^\[\]]+\])*/);
|
|
11
|
+
if (match) {
|
|
12
|
+
// Nested brackets are more likely link/image text than citation syntax.
|
|
13
|
+
const firstClosingBracketIndex = src.indexOf(']');
|
|
14
|
+
if (match[0].slice(1, firstClosingBracketIndex).includes('[')) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
// Early exit: if first closing bracket is immediately followed by '[', it's likely link-style syntax
|
|
18
|
+
if (firstClosingBracketIndex !== -1 && src[firstClosingBracketIndex + 1] === '[') {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
// If followed by parentheses, it's likely a markdown link or image, so don't treat as citation
|
|
22
|
+
const remainingSrc = src.slice(match[0].length);
|
|
23
|
+
if (remainingSrc.match(/^\s*\(/)) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
// Extract all citation keys (anything inside brackets)
|
|
27
|
+
const citations = match[0].match(/\[([^\]]+)\]/g);
|
|
28
|
+
if (citations) {
|
|
29
|
+
// Filter out task list syntax ([ ], [x], [X]) after trimming
|
|
30
|
+
const validCitations = citations.filter((citation) => {
|
|
31
|
+
const content = citation.slice(1, -1).trim();
|
|
32
|
+
return content !== '' && content !== 'x' && content !== 'X';
|
|
33
|
+
});
|
|
34
|
+
if (validCitations.length > 0) {
|
|
35
|
+
// Process each bracket content and split on spaces, commas, or semicolons
|
|
36
|
+
const keys = validCitations.flatMap((citation) => {
|
|
37
|
+
const content = citation.slice(1, -1).trim(); // Remove brackets and trim
|
|
38
|
+
// Split on spaces, commas, or semicolons and filter out empty strings
|
|
39
|
+
return content.split(/[\s,;]+/).filter((key) => key.length > 0);
|
|
40
|
+
});
|
|
41
|
+
// Deduplicate keys after trimming
|
|
42
|
+
const uniqueKeys = Array.from(new Set(keys.map((key) => key.trim()).filter((key) => key.length > 0)));
|
|
43
|
+
return {
|
|
44
|
+
type: 'inline-citations',
|
|
45
|
+
keys: uniqueKeys,
|
|
46
|
+
text: match[0],
|
|
47
|
+
raw: match[0]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
const CJK_AUTOLINK_BOUNDARY_CHARS = new Set([
|
|
2
|
+
'。',
|
|
3
|
+
'.',
|
|
4
|
+
',',
|
|
5
|
+
'、',
|
|
6
|
+
'?',
|
|
7
|
+
'!',
|
|
8
|
+
':',
|
|
9
|
+
';',
|
|
10
|
+
'(',
|
|
11
|
+
')',
|
|
12
|
+
'【',
|
|
13
|
+
'】',
|
|
14
|
+
'「',
|
|
15
|
+
'」',
|
|
16
|
+
'『',
|
|
17
|
+
'』',
|
|
18
|
+
'〈',
|
|
19
|
+
'〉',
|
|
20
|
+
'《',
|
|
21
|
+
'》'
|
|
22
|
+
]);
|
|
23
|
+
const AUTOLINK_PREFIXES = ['https://', 'http://', 'mailto:', 'www.'];
|
|
24
|
+
const DELIMITER_CONFIGS = [
|
|
25
|
+
{
|
|
26
|
+
delimiter: '***',
|
|
27
|
+
type: 'em',
|
|
28
|
+
buildText: (content) => `**${content}**`
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
delimiter: '**',
|
|
32
|
+
type: 'strong',
|
|
33
|
+
buildText: (content) => content
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
delimiter: '~~',
|
|
37
|
+
type: 'del',
|
|
38
|
+
buildText: (content) => content
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
delimiter: '*',
|
|
42
|
+
type: 'em',
|
|
43
|
+
buildText: (content) => content
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
function containsCjkBoundaryChar(value) {
|
|
47
|
+
for (const char of value) {
|
|
48
|
+
if (CJK_AUTOLINK_BOUNDARY_CHARS.has(char)) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
function hasNonWhitespaceBoundaryContent(value) {
|
|
55
|
+
return value.length > 0 && value.trim() === value;
|
|
56
|
+
}
|
|
57
|
+
function findDelimitedMatch(src, delimiter) {
|
|
58
|
+
if (!src.startsWith(delimiter)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const closingIndex = src.indexOf(delimiter, delimiter.length);
|
|
62
|
+
if (closingIndex === -1) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const content = src.slice(delimiter.length, closingIndex);
|
|
66
|
+
if (!hasNonWhitespaceBoundaryContent(content) || !containsCjkBoundaryChar(content)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
raw: src.slice(0, closingIndex + delimiter.length),
|
|
71
|
+
content
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function createInlineTextToken(text) {
|
|
75
|
+
return {
|
|
76
|
+
type: 'text',
|
|
77
|
+
raw: text,
|
|
78
|
+
text,
|
|
79
|
+
escaped: false
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function createAutolinkHref(text) {
|
|
83
|
+
return text.startsWith('www.') ? `http://${text}` : text;
|
|
84
|
+
}
|
|
85
|
+
function findAutolinkPrefixIndex(src) {
|
|
86
|
+
const indexes = AUTOLINK_PREFIXES.map((prefix) => {
|
|
87
|
+
const index = src.toLowerCase().indexOf(prefix);
|
|
88
|
+
return index === -1 ? Number.POSITIVE_INFINITY : index;
|
|
89
|
+
});
|
|
90
|
+
const firstIndex = Math.min(...indexes);
|
|
91
|
+
return Number.isFinite(firstIndex) ? firstIndex : undefined;
|
|
92
|
+
}
|
|
93
|
+
function createAutolinkToken(raw) {
|
|
94
|
+
return {
|
|
95
|
+
type: 'link',
|
|
96
|
+
raw,
|
|
97
|
+
href: createAutolinkHref(raw),
|
|
98
|
+
title: null,
|
|
99
|
+
text: raw,
|
|
100
|
+
tokens: [createInlineTextToken(raw)]
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function findAutolinkBoundaryMatch(src) {
|
|
104
|
+
const prefix = AUTOLINK_PREFIXES.find((candidate) => src.toLowerCase().startsWith(candidate));
|
|
105
|
+
if (!prefix) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
let index = prefix.length;
|
|
109
|
+
let sawBoundary = false;
|
|
110
|
+
while (index < src.length) {
|
|
111
|
+
const char = src[index];
|
|
112
|
+
if (/\s/.test(char)) {
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
if (CJK_AUTOLINK_BOUNDARY_CHARS.has(char)) {
|
|
116
|
+
sawBoundary = true;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
index += 1;
|
|
120
|
+
}
|
|
121
|
+
if (!sawBoundary || index === prefix.length) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
return src.slice(0, index);
|
|
125
|
+
}
|
|
126
|
+
function createCjkDelimitedExtension(config) {
|
|
127
|
+
return {
|
|
128
|
+
name: `cjk-${config.type}-${config.delimiter.length}`,
|
|
129
|
+
level: 'inline',
|
|
130
|
+
start(src) {
|
|
131
|
+
const firstIndex = src.indexOf(config.delimiter[0]);
|
|
132
|
+
return firstIndex === -1 ? undefined : firstIndex;
|
|
133
|
+
},
|
|
134
|
+
tokenizer(src) {
|
|
135
|
+
const match = findDelimitedMatch(src, config.delimiter);
|
|
136
|
+
if (!match) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const text = config.buildText(match.content);
|
|
140
|
+
return {
|
|
141
|
+
type: config.type,
|
|
142
|
+
raw: match.raw,
|
|
143
|
+
text,
|
|
144
|
+
tokens: this.lexer.inlineTokens(text)
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export const markedCjk = [
|
|
150
|
+
{
|
|
151
|
+
name: 'cjk-autolink-boundary',
|
|
152
|
+
level: 'inline',
|
|
153
|
+
start(src) {
|
|
154
|
+
return findAutolinkPrefixIndex(src);
|
|
155
|
+
},
|
|
156
|
+
tokenizer(src) {
|
|
157
|
+
const match = findAutolinkBoundaryMatch(src);
|
|
158
|
+
if (!match) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
return createAutolinkToken(match);
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
...DELIMITER_CONFIGS.map(createCjkDelimitedExtension)
|
|
165
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Extension, GenericToken } from './index.js';
|
|
2
|
+
export declare const markedDl: Extension;
|
|
3
|
+
export type DescriptionListToken = {
|
|
4
|
+
type: 'descriptionList';
|
|
5
|
+
raw: string;
|
|
6
|
+
text: string;
|
|
7
|
+
tokens: DescriptionToken[];
|
|
8
|
+
};
|
|
9
|
+
export type DescriptionToken = {
|
|
10
|
+
type: 'description';
|
|
11
|
+
raw: string;
|
|
12
|
+
tokens: [DescriptionTermToken, DescriptionDetailToken];
|
|
13
|
+
};
|
|
14
|
+
export type DescriptionTermToken = {
|
|
15
|
+
type: 'descriptionTerm';
|
|
16
|
+
raw: string;
|
|
17
|
+
tokens: GenericToken[];
|
|
18
|
+
};
|
|
19
|
+
export type DescriptionDetailToken = {
|
|
20
|
+
type: 'descriptionDetail';
|
|
21
|
+
raw: string;
|
|
22
|
+
tokens: GenericToken[];
|
|
23
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const markedDl = {
|
|
2
|
+
name: 'descriptionList',
|
|
3
|
+
level: 'block', // Is this a block-level or inline-level tokenizer?
|
|
4
|
+
tokenizer(src) {
|
|
5
|
+
const rule = /^(?:[ \t]*:[^:\n]+:[ \t]?[^\n]*(?:\n|$))+/;
|
|
6
|
+
const match = rule.exec(src);
|
|
7
|
+
if (match) {
|
|
8
|
+
const text = match[0].trim();
|
|
9
|
+
const tokens = [];
|
|
10
|
+
// Parse each line as a description
|
|
11
|
+
const lines = text.split('\n');
|
|
12
|
+
for (const line of lines) {
|
|
13
|
+
const lineMatch = /^\s*:([^:\n]+):([^:\n]*)(?:\n|$)/.exec(line);
|
|
14
|
+
if (lineMatch) {
|
|
15
|
+
const term = lineMatch[1].trim();
|
|
16
|
+
const detail = lineMatch[2].trim();
|
|
17
|
+
tokens.push({
|
|
18
|
+
type: 'description',
|
|
19
|
+
raw: lineMatch[0],
|
|
20
|
+
tokens: [
|
|
21
|
+
{
|
|
22
|
+
type: 'descriptionTerm',
|
|
23
|
+
raw: term,
|
|
24
|
+
tokens: this.lexer.inlineTokens(term)
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: 'descriptionDetail',
|
|
28
|
+
raw: detail,
|
|
29
|
+
tokens: this.lexer.inlineTokens(detail)
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const token = {
|
|
36
|
+
type: 'descriptionList',
|
|
37
|
+
raw: match[0],
|
|
38
|
+
text: text,
|
|
39
|
+
tokens: tokens
|
|
40
|
+
};
|
|
41
|
+
return token;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type StreamdownToken, type Extension } from './index.js';
|
|
2
|
+
type MarkedFootnoteOptions = {
|
|
3
|
+
preferContext?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function markedFootnote({ preferContext }?: MarkedFootnoteOptions): Extension[];
|
|
6
|
+
/**
|
|
7
|
+
* Represents a single footnote.
|
|
8
|
+
*/
|
|
9
|
+
export type Footnote = {
|
|
10
|
+
type: 'footnote';
|
|
11
|
+
raw: string;
|
|
12
|
+
label: string;
|
|
13
|
+
tokens: StreamdownToken[];
|
|
14
|
+
lines: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Represents a reference to a footnote.
|
|
18
|
+
*/
|
|
19
|
+
export type FootnoteRef = {
|
|
20
|
+
type: 'footnoteRef';
|
|
21
|
+
raw: string;
|
|
22
|
+
label: string;
|
|
23
|
+
content: Footnote;
|
|
24
|
+
};
|
|
25
|
+
export type FootnoteToken = Footnote | FootnoteRef;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {} from './index.js';
|
|
2
|
+
import { StreamdownContext } from '../context.svelte.js';
|
|
3
|
+
import { getContext } from 'svelte';
|
|
4
|
+
import { STREAMDOWN_CONTEXT_KEY } from '../context-key.js';
|
|
5
|
+
const footnoteRegex = /^\[\^([^\]\n]+)\]:(?:[ \t]+|\n|$)([^\n]*(?:\n(?:[ \t]+[^\n]*)?)*)/;
|
|
6
|
+
const footnoteRefRegex = /^\[\^([^\]\n]+)\](?!\()/;
|
|
7
|
+
const footNoteLastLineRegex = /^[ \t]*?[>\-*][ ]|[`]{3,}$|^[ \t]*?[|].+[|]$/;
|
|
8
|
+
const safeGetContext = () => {
|
|
9
|
+
try {
|
|
10
|
+
return getContext(STREAMDOWN_CONTEXT_KEY);
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export function markedFootnote({ preferContext = true } = {}) {
|
|
17
|
+
const ensureMaps = (tokenizer) => {
|
|
18
|
+
const streamdown = preferContext ? safeGetContext() : null;
|
|
19
|
+
if (!streamdown) {
|
|
20
|
+
if (!tokenizer.lexer.hasFootnotes) {
|
|
21
|
+
tokenizer.lexer.footnotes = {
|
|
22
|
+
refs: new Map(),
|
|
23
|
+
footnotes: new Map()
|
|
24
|
+
};
|
|
25
|
+
tokenizer.lexer.hasFootnotes = true;
|
|
26
|
+
}
|
|
27
|
+
return tokenizer.lexer.footnotes;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return streamdown.footnotes;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
name: 'footnote',
|
|
36
|
+
level: 'block',
|
|
37
|
+
tokenizer(src) {
|
|
38
|
+
const maps = ensureMaps(this);
|
|
39
|
+
const match = footnoteRegex.exec(src);
|
|
40
|
+
if (match) {
|
|
41
|
+
const [raw, label, text = ''] = match;
|
|
42
|
+
let content = text.split('\n').reduce((acc, curr) => {
|
|
43
|
+
return acc + '\n' + curr.replace(/^[ \t]+/, '');
|
|
44
|
+
}, '');
|
|
45
|
+
const contentLastLine = content.trimEnd().split('\n').pop();
|
|
46
|
+
content +=
|
|
47
|
+
// add lines after list, blockquote, codefence, and table
|
|
48
|
+
contentLastLine && footNoteLastLineRegex.test(contentLastLine) ? '\n\n' : '';
|
|
49
|
+
const lines = content.split('\n');
|
|
50
|
+
const token = {
|
|
51
|
+
type: 'footnote',
|
|
52
|
+
raw,
|
|
53
|
+
label,
|
|
54
|
+
lines,
|
|
55
|
+
tokens: []
|
|
56
|
+
};
|
|
57
|
+
maps.footnotes.set(label, token);
|
|
58
|
+
const ref = maps.refs.get(label);
|
|
59
|
+
if (ref) {
|
|
60
|
+
ref.content = token;
|
|
61
|
+
}
|
|
62
|
+
return token;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'footnoteRef',
|
|
68
|
+
level: 'inline',
|
|
69
|
+
tokenizer(src) {
|
|
70
|
+
const streamdown = preferContext ? safeGetContext() : null;
|
|
71
|
+
const maps = ensureMaps(this);
|
|
72
|
+
const match = footnoteRefRegex.exec(src);
|
|
73
|
+
if (match) {
|
|
74
|
+
const [raw, label] = match;
|
|
75
|
+
const footnote = maps.footnotes.get(label);
|
|
76
|
+
const hasResolvedStreamingContent = Boolean(footnote?.lines.join('\n').trim().length);
|
|
77
|
+
if (label === 'streamdown:footnote' ||
|
|
78
|
+
(streamdown?.mode === 'streaming' &&
|
|
79
|
+
streamdown.isAnimating &&
|
|
80
|
+
(!footnote || !hasResolvedStreamingContent))) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const token = {
|
|
84
|
+
type: 'footnoteRef',
|
|
85
|
+
raw,
|
|
86
|
+
label,
|
|
87
|
+
content: footnote || {
|
|
88
|
+
type: 'footnote',
|
|
89
|
+
raw,
|
|
90
|
+
label,
|
|
91
|
+
lines: [],
|
|
92
|
+
tokens: []
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
maps.refs.set(label, token);
|
|
96
|
+
return token;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const markedHr = {
|
|
2
|
+
name: 'hr',
|
|
3
|
+
level: 'block',
|
|
4
|
+
tokenizer(src) {
|
|
5
|
+
// Match horizontal rules according to CommonMark spec:
|
|
6
|
+
// 3 or more matching -, _, or * characters, with optional spaces between
|
|
7
|
+
// Must be at start of string and match entire line
|
|
8
|
+
const match = src.match(/^[ \t]*(-[ \t]*-[ \t]*-+|_[ \t]*_[ \t]*_+|\*[ \t]*\*[ \t]*\*+)[ \t]*(?:\n|$)/);
|
|
9
|
+
if (match) {
|
|
10
|
+
const raw = match[0].replace(/\n$/, ''); // Remove trailing newline from raw
|
|
11
|
+
return {
|
|
12
|
+
type: 'hr',
|
|
13
|
+
raw: raw
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Extension, GenericToken } from './index.js';
|
|
2
|
+
export declare function letterToInt(letter: string): number;
|
|
3
|
+
export declare function romanToInt(roman: string): number;
|
|
4
|
+
export declare const romanUpper = "(?:C|XC|L?X{0,3}(?:IX|IV|V?I{0,3}))";
|
|
5
|
+
export declare const romanLower = "(?:c|xc|l?x{0,3}(?:ix|iv|v?i{0,3}))";
|
|
6
|
+
export declare const bulletPattern = "(?:[*+-]|(?:\\d{1,9}|[a-zA-Z]|(?:C|XC|L?X{0,3}(?:IX|IV|V?I{0,3}))|(?:c|xc|l?x{0,3}(?:ix|iv|v?i{0,3})))[.)])";
|
|
7
|
+
export declare const rule = "^( {0,3}(?:[*+-]|(?:\\d{1,9}|[a-zA-Z]|(?:C|XC|L?X{0,3}(?:IX|IV|V?I{0,3}))|(?:c|xc|l?x{0,3}(?:ix|iv|v?i{0,3})))[.)]))([ \\t][^\\n]*|[ \\t])?(?:\\n|$)";
|
|
8
|
+
export declare const markedList: Extension;
|
|
9
|
+
export interface ListToken {
|
|
10
|
+
type: 'list';
|
|
11
|
+
raw: string;
|
|
12
|
+
ordered: boolean;
|
|
13
|
+
listType: 'decimal' | 'lower-alpha' | 'upper-alpha' | 'lower-roman' | 'upper-roman' | null;
|
|
14
|
+
loose: boolean;
|
|
15
|
+
start?: number;
|
|
16
|
+
tokens: ListItemToken[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Token representing an item in an extended list.
|
|
20
|
+
*/
|
|
21
|
+
export interface ListItemToken {
|
|
22
|
+
type: 'list_item';
|
|
23
|
+
raw: string;
|
|
24
|
+
task: boolean;
|
|
25
|
+
checked: boolean;
|
|
26
|
+
loose: boolean;
|
|
27
|
+
text: string;
|
|
28
|
+
value: number | null;
|
|
29
|
+
skipped: boolean;
|
|
30
|
+
tokens: GenericToken[];
|
|
31
|
+
}
|