shortcutxl 0.2.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 +59 -0
- package/agent-docs/README.md +397 -0
- package/agent-docs/docs/compaction.md +390 -0
- package/agent-docs/docs/custom-provider.md +580 -0
- package/agent-docs/docs/development.md +69 -0
- package/agent-docs/docs/extensions.md +1971 -0
- package/agent-docs/docs/json.md +79 -0
- package/agent-docs/docs/keybindings.md +174 -0
- package/agent-docs/docs/models.md +293 -0
- package/agent-docs/docs/packages.md +209 -0
- package/agent-docs/docs/prompt-templates.md +67 -0
- package/agent-docs/docs/providers.md +186 -0
- package/agent-docs/docs/rpc.md +1317 -0
- package/agent-docs/docs/sdk.md +962 -0
- package/agent-docs/docs/session.md +412 -0
- package/agent-docs/docs/settings.md +223 -0
- package/agent-docs/docs/shell-aliases.md +13 -0
- package/agent-docs/docs/skills.md +231 -0
- package/agent-docs/docs/terminal-setup.md +70 -0
- package/agent-docs/docs/termux.md +127 -0
- package/agent-docs/docs/themes.md +295 -0
- package/agent-docs/docs/tree.md +219 -0
- package/agent-docs/docs/tui.md +887 -0
- package/agent-docs/docs/windows.md +17 -0
- package/agent-docs/examples/README.md +25 -0
- package/agent-docs/examples/extensions/README.md +205 -0
- package/agent-docs/examples/extensions/antigravity-image-gen.ts +447 -0
- package/agent-docs/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/agent-docs/examples/extensions/bash-spawn-hook.ts +30 -0
- package/agent-docs/examples/extensions/bookmark.ts +50 -0
- package/agent-docs/examples/extensions/built-in-tool-renderer.ts +256 -0
- package/agent-docs/examples/extensions/claude-rules.ts +86 -0
- package/agent-docs/examples/extensions/commands.ts +75 -0
- package/agent-docs/examples/extensions/confirm-destructive.ts +59 -0
- package/agent-docs/examples/extensions/custom-compaction.ts +126 -0
- package/agent-docs/examples/extensions/custom-footer.ts +63 -0
- package/agent-docs/examples/extensions/custom-header.ts +73 -0
- package/agent-docs/examples/extensions/custom-provider-anthropic/index.ts +660 -0
- package/agent-docs/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/agent-docs/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/agent-docs/examples/extensions/custom-provider-gitlab-duo/index.ts +362 -0
- package/agent-docs/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/agent-docs/examples/extensions/custom-provider-gitlab-duo/test.ts +88 -0
- package/agent-docs/examples/extensions/custom-provider-qwen-cli/index.ts +349 -0
- package/agent-docs/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
- package/agent-docs/examples/extensions/dirty-repo-guard.ts +56 -0
- package/agent-docs/examples/extensions/doom-overlay/README.md +46 -0
- package/agent-docs/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/agent-docs/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/agent-docs/examples/extensions/doom-overlay/doom-component.ts +133 -0
- package/agent-docs/examples/extensions/doom-overlay/doom-engine.ts +186 -0
- package/agent-docs/examples/extensions/doom-overlay/doom-keys.ts +108 -0
- package/agent-docs/examples/extensions/doom-overlay/index.ts +74 -0
- package/agent-docs/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/agent-docs/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/agent-docs/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/agent-docs/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/agent-docs/examples/extensions/dynamic-resources/index.ts +15 -0
- package/agent-docs/examples/extensions/dynamic-tools.ts +77 -0
- package/agent-docs/examples/extensions/event-bus.ts +43 -0
- package/agent-docs/examples/extensions/file-trigger.ts +41 -0
- package/agent-docs/examples/extensions/git-checkpoint.ts +53 -0
- package/agent-docs/examples/extensions/handoff.ts +155 -0
- package/agent-docs/examples/extensions/hello.ts +25 -0
- package/agent-docs/examples/extensions/inline-bash.ts +94 -0
- package/agent-docs/examples/extensions/input-transform.ts +43 -0
- package/agent-docs/examples/extensions/interactive-shell.ts +209 -0
- package/agent-docs/examples/extensions/mac-system-theme.ts +47 -0
- package/agent-docs/examples/extensions/message-renderer.ts +59 -0
- package/agent-docs/examples/extensions/minimal-mode.ts +430 -0
- package/agent-docs/examples/extensions/modal-editor.ts +90 -0
- package/agent-docs/examples/extensions/model-status.ts +31 -0
- package/agent-docs/examples/extensions/notify.ts +55 -0
- package/agent-docs/examples/extensions/overlay-qa-tests.ts +936 -0
- package/agent-docs/examples/extensions/overlay-test.ts +159 -0
- package/agent-docs/examples/extensions/permission-gate.ts +37 -0
- package/agent-docs/examples/extensions/pirate.ts +47 -0
- package/agent-docs/examples/extensions/plan-mode/README.md +65 -0
- package/agent-docs/examples/extensions/plan-mode/index.ts +363 -0
- package/agent-docs/examples/extensions/plan-mode/utils.ts +173 -0
- package/agent-docs/examples/extensions/preset.ts +418 -0
- package/agent-docs/examples/extensions/protected-paths.ts +30 -0
- package/agent-docs/examples/extensions/qna.ts +122 -0
- package/agent-docs/examples/extensions/question.ts +278 -0
- package/agent-docs/examples/extensions/questionnaire.ts +440 -0
- package/agent-docs/examples/extensions/rainbow-editor.ts +90 -0
- package/agent-docs/examples/extensions/reload-runtime.ts +37 -0
- package/agent-docs/examples/extensions/rpc-demo.ts +124 -0
- package/agent-docs/examples/extensions/sandbox/index.ts +324 -0
- package/agent-docs/examples/extensions/sandbox/package-lock.json +92 -0
- package/agent-docs/examples/extensions/sandbox/package.json +19 -0
- package/agent-docs/examples/extensions/send-user-message.ts +97 -0
- package/agent-docs/examples/extensions/session-name.ts +27 -0
- package/agent-docs/examples/extensions/shutdown-command.ts +69 -0
- package/agent-docs/examples/extensions/snake.ts +343 -0
- package/agent-docs/examples/extensions/space-invaders.ts +566 -0
- package/agent-docs/examples/extensions/ssh.ts +233 -0
- package/agent-docs/examples/extensions/status-line.ts +40 -0
- package/agent-docs/examples/extensions/subagent/README.md +172 -0
- package/agent-docs/examples/extensions/subagent/agents/planner.md +37 -0
- package/agent-docs/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/agent-docs/examples/extensions/subagent/agents/scout.md +50 -0
- package/agent-docs/examples/extensions/subagent/agents/worker.md +24 -0
- package/agent-docs/examples/extensions/subagent/agents.ts +130 -0
- package/agent-docs/examples/extensions/subagent/index.ts +1068 -0
- package/agent-docs/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/agent-docs/examples/extensions/subagent/prompts/implement.md +10 -0
- package/agent-docs/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/agent-docs/examples/extensions/summarize.ts +206 -0
- package/agent-docs/examples/extensions/system-prompt-header.ts +17 -0
- package/agent-docs/examples/extensions/timed-confirm.ts +72 -0
- package/agent-docs/examples/extensions/titlebar-spinner.ts +58 -0
- package/agent-docs/examples/extensions/todo.ts +314 -0
- package/agent-docs/examples/extensions/tool-override.ts +146 -0
- package/agent-docs/examples/extensions/tools.ts +145 -0
- package/agent-docs/examples/extensions/trigger-compact.ts +40 -0
- package/agent-docs/examples/extensions/truncated-tool.ts +194 -0
- package/agent-docs/examples/extensions/widget-placement.ts +17 -0
- package/agent-docs/examples/extensions/with-deps/index.ts +37 -0
- package/agent-docs/examples/extensions/with-deps/package-lock.json +31 -0
- package/agent-docs/examples/extensions/with-deps/package.json +22 -0
- package/agent-docs/examples/rpc-extension-ui.ts +654 -0
- package/agent-docs/examples/sdk/01-minimal.ts +22 -0
- package/agent-docs/examples/sdk/02-custom-model.ts +48 -0
- package/agent-docs/examples/sdk/03-custom-prompt.ts +55 -0
- package/agent-docs/examples/sdk/04-skills.ts +53 -0
- package/agent-docs/examples/sdk/05-tools.ts +56 -0
- package/agent-docs/examples/sdk/06-extensions.ts +88 -0
- package/agent-docs/examples/sdk/07-context-files.ts +40 -0
- package/agent-docs/examples/sdk/08-prompt-templates.ts +47 -0
- package/agent-docs/examples/sdk/09-api-keys-and-oauth.ts +48 -0
- package/agent-docs/examples/sdk/10-settings.ts +54 -0
- package/agent-docs/examples/sdk/11-sessions.ts +48 -0
- package/agent-docs/examples/sdk/12-full-control.ts +82 -0
- package/agent-docs/examples/sdk/README.md +144 -0
- package/agent-docs/xll-skill.md +61 -0
- package/agent-docs/xll-spec.md +110 -0
- package/dist/cli/args.js +290 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/file-processor.js +79 -0
- package/dist/cli/list-models.js +92 -0
- package/dist/cli/package-commands.js +210 -0
- package/dist/cli/report-settings-errors.js +11 -0
- package/dist/cli/session-picker.js +34 -0
- package/dist/cli.js +19 -0
- package/dist/config.js +288 -0
- package/dist/core/abort.js +15 -0
- package/dist/core/agent-loop.js +352 -0
- package/dist/core/agent-session.js +2019 -0
- package/dist/core/agent.js +410 -0
- package/dist/core/auth-storage.js +456 -0
- package/dist/core/bash-executor.js +222 -0
- package/dist/core/compaction/branch-summarization.js +242 -0
- package/dist/core/compaction/compaction.js +610 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/utils.js +139 -0
- package/dist/core/defaults.js +6 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/exec.js +71 -0
- package/dist/core/export-html/ansi-to-html.js +256 -0
- package/dist/core/export-html/index.js +238 -0
- package/dist/core/export-html/session-view-model.js +342 -0
- package/dist/core/export-html/template.css +1110 -0
- package/dist/core/export-html/template.html +76 -0
- package/dist/core/export-html/template.js +1990 -0
- package/dist/core/export-html/tool-renderer.js +63 -0
- package/dist/core/export-html/vendor/highlight.min.js +7725 -0
- package/dist/core/export-html/vendor/marked.min.js +1803 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/loader.js +422 -0
- package/dist/core/extensions/runner.js +651 -0
- package/dist/core/extensions/types.js +35 -0
- package/dist/core/extensions/wrapper.js +102 -0
- package/dist/core/footer-data-provider.js +162 -0
- package/dist/core/index.js +9 -0
- package/dist/core/keybindings.js +153 -0
- package/dist/core/messages.js +133 -0
- package/dist/core/model-registry.js +539 -0
- package/dist/core/model-resolver.js +370 -0
- package/dist/core/package-manager.js +1485 -0
- package/dist/core/prompt-templates.js +253 -0
- package/dist/core/resolve-config-value.js +59 -0
- package/dist/core/resource-loader.js +700 -0
- package/dist/core/sdk.js +197 -0
- package/dist/core/session-bash.js +99 -0
- package/dist/core/session-compaction.js +165 -0
- package/dist/core/session-manager.js +1153 -0
- package/dist/core/session-models.js +99 -0
- package/dist/core/session-retry.js +155 -0
- package/dist/core/settings-manager.js +572 -0
- package/dist/core/skills.js +382 -0
- package/dist/core/slash-commands.js +31 -0
- package/dist/core/system-prompt.js +161 -0
- package/dist/core/theme.js +770 -0
- package/dist/core/timings.js +26 -0
- package/dist/core/tools/bash.js +258 -0
- package/dist/core/tools/edit-diff.js +245 -0
- package/dist/core/tools/edit.js +148 -0
- package/dist/core/tools/find.js +208 -0
- package/dist/core/tools/grep.js +246 -0
- package/dist/core/tools/index.js +67 -0
- package/dist/core/tools/ls.js +123 -0
- package/dist/core/tools/path-utils.js +81 -0
- package/dist/core/tools/read.js +160 -0
- package/dist/core/tools/truncate.js +70 -0
- package/dist/core/tools/write.js +82 -0
- package/dist/custom/agents/action.js +13 -0
- package/dist/custom/agents/document-reader.js +70 -0
- package/dist/custom/agents/general.js +26 -0
- package/dist/custom/agents/index.js +49 -0
- package/dist/custom/agents/installation.js +13 -0
- package/dist/custom/agents/types.js +7 -0
- package/dist/custom/auth/refresh-timer.js +33 -0
- package/dist/custom/auth/shortcut-oauth.js +145 -0
- package/dist/custom/constants.js +21 -0
- package/dist/custom/context/workbook-summary.js +73 -0
- package/dist/custom/credits/shortcut-credits.js +29 -0
- package/dist/custom/cron/cron-daemon-entry.js +18 -0
- package/dist/custom/cron/daemon-ipc.js +131 -0
- package/dist/custom/cron/daemon.js +224 -0
- package/dist/custom/cron/jobs.js +226 -0
- package/dist/custom/cron/run-log.js +51 -0
- package/dist/custom/cron/schedule.js +72 -0
- package/dist/custom/cron/status-line.js +98 -0
- package/dist/custom/cron/store.js +87 -0
- package/dist/custom/cron/types.js +8 -0
- package/dist/custom/dev/index.js +59 -0
- package/dist/custom/dev/trace-export.js +58 -0
- package/dist/custom/ensure-excel.js +63 -0
- package/dist/custom/excel-config.js +36 -0
- package/dist/custom/preflight.js +422 -0
- package/dist/custom/prompts/action.js +100 -0
- package/dist/custom/prompts/api.js +66 -0
- package/dist/custom/prompts/installation.js +124 -0
- package/dist/custom/prompts/shared.js +138 -0
- package/dist/custom/providers/llm-usage.js +42 -0
- package/dist/custom/providers/message-converter.js +74 -0
- package/dist/custom/providers/provider-ids.js +9 -0
- package/dist/custom/providers/register-openai-codex-provider.js +27 -0
- package/dist/custom/providers/register-shortcut-provider.js +52 -0
- package/dist/custom/providers/shortcut-invoke.js +117 -0
- package/dist/custom/providers/shortcut-stream.js +252 -0
- package/dist/custom/providers/sse-protocol.js +38 -0
- package/dist/custom/sync-xll.js +130 -0
- package/dist/custom/tools/cron.js +413 -0
- package/dist/custom/tools/excel-exec.js +167 -0
- package/dist/custom/tools/excel-range.js +50 -0
- package/dist/custom/tools/llm-analysis.js +265 -0
- package/dist/custom/tools/render-helpers.js +38 -0
- package/dist/custom/tools/switch-mode.js +94 -0
- package/dist/custom/tools/task/agents.js +6 -0
- package/dist/custom/tools/task/index.js +8 -0
- package/dist/custom/tools/task/render.js +348 -0
- package/dist/custom/tools/task/subprocess.js +320 -0
- package/dist/custom/tools/task/task.js +205 -0
- package/dist/custom/tools/todo-list.js +195 -0
- package/dist/custom/tracing/session-upload.js +93 -0
- package/dist/index.js +45 -0
- package/dist/main.js +613 -0
- package/dist/migrations.js +265 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/interactive/components/armin.js +337 -0
- package/dist/modes/interactive/components/assistant-message.js +94 -0
- package/dist/modes/interactive/components/bash-execution.js +171 -0
- package/dist/modes/interactive/components/bordered-loader.js +51 -0
- package/dist/modes/interactive/components/branch-summary-message.js +45 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +46 -0
- package/dist/modes/interactive/components/config-selector.js +488 -0
- package/dist/modes/interactive/components/countdown-timer.js +33 -0
- package/dist/modes/interactive/components/custom-editor.js +93 -0
- package/dist/modes/interactive/components/custom-message.js +81 -0
- package/dist/modes/interactive/components/daxnuts.js +140 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/dynamic-border.js +21 -0
- package/dist/modes/interactive/components/extension-editor.js +105 -0
- package/dist/modes/interactive/components/extension-input.js +61 -0
- package/dist/modes/interactive/components/extension-selector.js +78 -0
- package/dist/modes/interactive/components/footer.js +309 -0
- package/dist/modes/interactive/components/index.js +33 -0
- package/dist/modes/interactive/components/keybinding-hints.js +61 -0
- package/dist/modes/interactive/components/layout.js +64 -0
- package/dist/modes/interactive/components/login-dialog.js +148 -0
- package/dist/modes/interactive/components/model-selector.js +237 -0
- package/dist/modes/interactive/components/oauth-selector.js +111 -0
- package/dist/modes/interactive/components/session-selector-search.js +157 -0
- package/dist/modes/interactive/components/session-selector.js +860 -0
- package/dist/modes/interactive/components/settings-selector.js +123 -0
- package/dist/modes/interactive/components/show-images-selector.js +35 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +48 -0
- package/dist/modes/interactive/components/theme-selector.js +47 -0
- package/dist/modes/interactive/components/thinking-selector.js +47 -0
- package/dist/modes/interactive/components/tool-execution.js +789 -0
- package/dist/modes/interactive/components/tool-group.js +106 -0
- package/dist/modes/interactive/components/tree-selector.js +962 -0
- package/dist/modes/interactive/components/user-message-selector.js +115 -0
- package/dist/modes/interactive/components/user-message.js +48 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/file-attachments.js +135 -0
- package/dist/modes/interactive/interactive-mode.js +3775 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +85 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.js +177 -0
- package/dist/modes/print-mode.js +101 -0
- package/dist/modes/rpc/rpc-client.js +387 -0
- package/dist/modes/rpc/rpc-mode.js +509 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/subagent-entry.js +145 -0
- package/dist/tool-names.js +34 -0
- package/dist/tui/autocomplete.js +596 -0
- package/dist/tui/components/box.js +104 -0
- package/dist/tui/components/cancellable-loader.js +35 -0
- package/dist/tui/components/editor.js +1679 -0
- package/dist/tui/components/image.js +69 -0
- package/dist/tui/components/input.js +433 -0
- package/dist/tui/components/loader.js +49 -0
- package/dist/tui/components/markdown.js +629 -0
- package/dist/tui/components/select-list.js +152 -0
- package/dist/tui/components/settings-list.js +185 -0
- package/dist/tui/components/spacer.js +23 -0
- package/dist/tui/components/text.js +89 -0
- package/dist/tui/components/truncated-text.js +51 -0
- package/dist/tui/editor-component.js +2 -0
- package/dist/tui/fuzzy.js +107 -0
- package/dist/tui/get-east-asian-width/index.js +32 -0
- package/dist/tui/get-east-asian-width/lookup.js +404 -0
- package/dist/tui/index.js +32 -0
- package/dist/tui/keybindings.js +114 -0
- package/dist/tui/keys.js +959 -0
- package/dist/tui/kill-ring.js +44 -0
- package/dist/tui/stdin-buffer.js +317 -0
- package/dist/tui/terminal-image.js +288 -0
- package/dist/tui/terminal.js +249 -0
- package/dist/tui/tui/autocomplete.js +596 -0
- package/dist/tui/tui/components/box.js +106 -0
- package/dist/tui/tui/components/cancellable-loader.js +35 -0
- package/dist/tui/tui/components/editor.js +1679 -0
- package/dist/tui/tui/components/image.js +69 -0
- package/dist/tui/tui/components/input.js +433 -0
- package/dist/tui/tui/components/loader.js +49 -0
- package/dist/tui/tui/components/markdown.js +629 -0
- package/dist/tui/tui/components/select-list.js +152 -0
- package/dist/tui/tui/components/settings-list.js +185 -0
- package/dist/tui/tui/components/spacer.js +23 -0
- package/dist/tui/tui/components/text.js +91 -0
- package/dist/tui/tui/components/truncated-text.js +51 -0
- package/dist/tui/tui/editor-component.js +2 -0
- package/dist/tui/tui/fuzzy.js +107 -0
- package/dist/tui/tui/get-east-asian-width/index.js +32 -0
- package/dist/tui/tui/get-east-asian-width/lookup.js +404 -0
- package/dist/tui/tui/index.js +32 -0
- package/dist/tui/tui/keybindings.js +114 -0
- package/dist/tui/tui/keys.js +959 -0
- package/dist/tui/tui/kill-ring.js +44 -0
- package/dist/tui/tui/stdin-buffer.js +317 -0
- package/dist/tui/tui/terminal-image.js +288 -0
- package/dist/tui/tui/terminal.js +249 -0
- package/dist/tui/tui/tui.js +955 -0
- package/dist/tui/tui/undo-stack.js +25 -0
- package/dist/tui/tui/utils.js +800 -0
- package/dist/tui/tui.js +955 -0
- package/dist/tui/undo-stack.js +25 -0
- package/dist/tui/utils.js +800 -0
- package/dist/utils/changelog.js +87 -0
- package/dist/utils/clipboard-image.js +164 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard.js +67 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/git.js +166 -0
- package/dist/utils/image-convert.js +35 -0
- package/dist/utils/image-resize.js +183 -0
- package/dist/utils/mime.js +26 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/shell.js +217 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/tools-manager.js +259 -0
- package/package.json +78 -0
- package/skills/excel-com-api/SKILL.md +74 -0
- package/skills/excel-com-api/excel-type-library.py +27767 -0
- package/skills/excel-com-api/office-type-library.py +10867 -0
- package/skills/integrations/SKILL.md +138 -0
- package/skills/integrations/alphasense.md +457 -0
- package/skills/integrations/bloomberg.md +803 -0
- package/skills/integrations/calcbench.md +315 -0
- package/skills/integrations/capiq.md +848 -0
- package/skills/integrations/dynamics-365-finance.md +354 -0
- package/skills/integrations/earnings_transcripts.md +387 -0
- package/skills/integrations/factset.md +758 -0
- package/skills/integrations/ice-fixed-income.md +344 -0
- package/skills/integrations/moodys-analytics.md +313 -0
- package/skills/integrations/morningstar.md +433 -0
- package/skills/integrations/nasdaq-data-link.md +249 -0
- package/skills/integrations/pitchbook.md +413 -0
- package/skills/integrations/preqin.md +422 -0
- package/skills/integrations/quickbooks.md +289 -0
- package/skills/integrations/quickfs.md +314 -0
- package/skills/integrations/refinitiv.md +473 -0
- package/skills/integrations/sage-intacct.md +401 -0
- package/skills/integrations/visible-alpha.md +320 -0
- package/skills/integrations/xero.md +393 -0
- package/skills/integrations/ycharts.md +306 -0
- package/skills/pdf-creation/SKILL.md +93 -0
- package/skills/pdf-extraction/SKILL.md +32 -0
- package/skills/powerpoint-creation/SKILL.md +110 -0
- package/skills/sec-edgar/SKILL.md +127 -0
- package/skills/sec-edgar/sec_to_pdf.py +109 -0
- package/xll/ShortcutXL.xll +0 -0
- package/xll/modules/debug_render.py +272 -0
- package/xll/modules/gameboy.py +241 -0
- package/xll/modules/pong.py +188 -0
- package/xll/modules/shortcut_xl/__init__.py +18 -0
- package/xll/modules/shortcut_xl/_categorize.py +200 -0
- package/xll/modules/shortcut_xl/_com.py +108 -0
- package/xll/modules/shortcut_xl/_format.py +252 -0
- package/xll/modules/shortcut_xl/_log.py +12 -0
- package/xll/modules/shortcut_xl/_managed.py +116 -0
- package/xll/modules/shortcut_xl/_registry.py +44 -0
- package/xll/modules/shortcut_xl/_threading.py +161 -0
- package/xll/modules/shortcut_xl/_tracking.py +283 -0
- package/xll/modules/stocks.py +100 -0
- package/xll/python3.dll +0 -0
- package/xll/python312.dll +0 -0
|
@@ -0,0 +1,1803 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* marked v15.0.4 - a markdown parser
|
|
3
|
+
* Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
|
|
4
|
+
* https://github.com/markedjs/marked
|
|
5
|
+
*/
|
|
6
|
+
!(function (e, t) {
|
|
7
|
+
'object' == typeof exports && 'undefined' != typeof module
|
|
8
|
+
? t(exports)
|
|
9
|
+
: 'function' == typeof define && define.amd
|
|
10
|
+
? define(['exports'], t)
|
|
11
|
+
: t(((e = 'undefined' != typeof globalThis ? globalThis : e || self).marked = {}));
|
|
12
|
+
})(this, function (e) {
|
|
13
|
+
'use strict';
|
|
14
|
+
function t() {
|
|
15
|
+
return {
|
|
16
|
+
async: !1,
|
|
17
|
+
breaks: !1,
|
|
18
|
+
extensions: null,
|
|
19
|
+
gfm: !0,
|
|
20
|
+
hooks: null,
|
|
21
|
+
pedantic: !1,
|
|
22
|
+
renderer: null,
|
|
23
|
+
silent: !1,
|
|
24
|
+
tokenizer: null,
|
|
25
|
+
walkTokens: null
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function n(t) {
|
|
29
|
+
e.defaults = t;
|
|
30
|
+
}
|
|
31
|
+
e.defaults = {
|
|
32
|
+
async: !1,
|
|
33
|
+
breaks: !1,
|
|
34
|
+
extensions: null,
|
|
35
|
+
gfm: !0,
|
|
36
|
+
hooks: null,
|
|
37
|
+
pedantic: !1,
|
|
38
|
+
renderer: null,
|
|
39
|
+
silent: !1,
|
|
40
|
+
tokenizer: null,
|
|
41
|
+
walkTokens: null
|
|
42
|
+
};
|
|
43
|
+
const s = { exec: () => null };
|
|
44
|
+
function r(e, t = '') {
|
|
45
|
+
let n = 'string' == typeof e ? e : e.source;
|
|
46
|
+
const s = {
|
|
47
|
+
replace: (e, t) => {
|
|
48
|
+
let r = 'string' == typeof t ? t : t.source;
|
|
49
|
+
return ((r = r.replace(i.caret, '$1')), (n = n.replace(e, r)), s);
|
|
50
|
+
},
|
|
51
|
+
getRegex: () => new RegExp(n, t)
|
|
52
|
+
};
|
|
53
|
+
return s;
|
|
54
|
+
}
|
|
55
|
+
const i = {
|
|
56
|
+
codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
|
|
57
|
+
outputLinkReplace: /\\([\[\]])/g,
|
|
58
|
+
indentCodeCompensation: /^(\s+)(?:```)/,
|
|
59
|
+
beginningSpace: /^\s+/,
|
|
60
|
+
endingHash: /#$/,
|
|
61
|
+
startingSpaceChar: /^ /,
|
|
62
|
+
endingSpaceChar: / $/,
|
|
63
|
+
nonSpaceChar: /[^ ]/,
|
|
64
|
+
newLineCharGlobal: /\n/g,
|
|
65
|
+
tabCharGlobal: /\t/g,
|
|
66
|
+
multipleSpaceGlobal: /\s+/g,
|
|
67
|
+
blankLine: /^[ \t]*$/,
|
|
68
|
+
doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
|
|
69
|
+
blockquoteStart: /^ {0,3}>/,
|
|
70
|
+
blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
|
|
71
|
+
blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
|
|
72
|
+
listReplaceTabs: /^\t+/,
|
|
73
|
+
listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
|
|
74
|
+
listIsTask: /^\[[ xX]\] /,
|
|
75
|
+
listReplaceTask: /^\[[ xX]\] +/,
|
|
76
|
+
anyLine: /\n.*\n/,
|
|
77
|
+
hrefBrackets: /^<(.*)>$/,
|
|
78
|
+
tableDelimiter: /[:|]/,
|
|
79
|
+
tableAlignChars: /^\||\| *$/g,
|
|
80
|
+
tableRowBlankLine: /\n[ \t]*$/,
|
|
81
|
+
tableAlignRight: /^ *-+: *$/,
|
|
82
|
+
tableAlignCenter: /^ *:-+: *$/,
|
|
83
|
+
tableAlignLeft: /^ *:-+ *$/,
|
|
84
|
+
startATag: /^<a /i,
|
|
85
|
+
endATag: /^<\/a>/i,
|
|
86
|
+
startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
|
|
87
|
+
endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
|
|
88
|
+
startAngleBracket: /^</,
|
|
89
|
+
endAngleBracket: />$/,
|
|
90
|
+
pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
|
|
91
|
+
unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
|
|
92
|
+
escapeTest: /[&<>"']/,
|
|
93
|
+
escapeReplace: /[&<>"']/g,
|
|
94
|
+
escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
|
|
95
|
+
escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
|
|
96
|
+
unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,
|
|
97
|
+
caret: /(^|[^\[])\^/g,
|
|
98
|
+
percentDecode: /%25/g,
|
|
99
|
+
findPipe: /\|/g,
|
|
100
|
+
splitPipe: / \|/,
|
|
101
|
+
slashPipe: /\\\|/g,
|
|
102
|
+
carriageReturn: /\r\n|\r/g,
|
|
103
|
+
spaceLine: /^ +$/gm,
|
|
104
|
+
notSpaceStart: /^\S*/,
|
|
105
|
+
endingNewline: /\n$/,
|
|
106
|
+
listItemRegex: (e) => new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),
|
|
107
|
+
nextBulletRegex: (e) =>
|
|
108
|
+
new RegExp(`^ {0,${Math.min(3, e - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),
|
|
109
|
+
hrRegex: (e) =>
|
|
110
|
+
new RegExp(`^ {0,${Math.min(3, e - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
|
|
111
|
+
fencesBeginRegex: (e) => new RegExp(`^ {0,${Math.min(3, e - 1)}}(?:\`\`\`|~~~)`),
|
|
112
|
+
headingBeginRegex: (e) => new RegExp(`^ {0,${Math.min(3, e - 1)}}#`),
|
|
113
|
+
htmlBeginRegex: (e) => new RegExp(`^ {0,${Math.min(3, e - 1)}}<(?:[a-z].*>|!--)`, 'i')
|
|
114
|
+
},
|
|
115
|
+
l = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
|
|
116
|
+
o = /(?:[*+-]|\d{1,9}[.)])/,
|
|
117
|
+
a = r(
|
|
118
|
+
/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/
|
|
119
|
+
)
|
|
120
|
+
.replace(/bull/g, o)
|
|
121
|
+
.replace(/blockCode/g, /(?: {4}| {0,3}\t)/)
|
|
122
|
+
.replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/)
|
|
123
|
+
.replace(/blockquote/g, / {0,3}>/)
|
|
124
|
+
.replace(/heading/g, / {0,3}#{1,6}/)
|
|
125
|
+
.replace(/html/g, / {0,3}<[^\n>]+>\n/)
|
|
126
|
+
.getRegex(),
|
|
127
|
+
c = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
|
|
128
|
+
h = /(?!\s*\])(?:\\.|[^\[\]\\])+/,
|
|
129
|
+
p = r(
|
|
130
|
+
/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/
|
|
131
|
+
)
|
|
132
|
+
.replace('label', h)
|
|
133
|
+
.replace('title', /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/)
|
|
134
|
+
.getRegex(),
|
|
135
|
+
u = r(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/)
|
|
136
|
+
.replace(/bull/g, o)
|
|
137
|
+
.getRegex(),
|
|
138
|
+
g =
|
|
139
|
+
'address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul',
|
|
140
|
+
k = /<!--(?:-?>|[\s\S]*?(?:-->|$))/,
|
|
141
|
+
f = r(
|
|
142
|
+
'^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))',
|
|
143
|
+
'i'
|
|
144
|
+
)
|
|
145
|
+
.replace('comment', k)
|
|
146
|
+
.replace('tag', g)
|
|
147
|
+
.replace(
|
|
148
|
+
'attribute',
|
|
149
|
+
/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/
|
|
150
|
+
)
|
|
151
|
+
.getRegex(),
|
|
152
|
+
d = r(c)
|
|
153
|
+
.replace('hr', l)
|
|
154
|
+
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
|
155
|
+
.replace('|lheading', '')
|
|
156
|
+
.replace('|table', '')
|
|
157
|
+
.replace('blockquote', ' {0,3}>')
|
|
158
|
+
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
159
|
+
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ')
|
|
160
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
161
|
+
.replace('tag', g)
|
|
162
|
+
.getRegex(),
|
|
163
|
+
x = {
|
|
164
|
+
blockquote: r(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/)
|
|
165
|
+
.replace('paragraph', d)
|
|
166
|
+
.getRegex(),
|
|
167
|
+
code: /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,
|
|
168
|
+
def: p,
|
|
169
|
+
fences:
|
|
170
|
+
/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
171
|
+
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
172
|
+
hr: l,
|
|
173
|
+
html: f,
|
|
174
|
+
lheading: a,
|
|
175
|
+
list: u,
|
|
176
|
+
newline: /^(?:[ \t]*(?:\n|$))+/,
|
|
177
|
+
paragraph: d,
|
|
178
|
+
table: s,
|
|
179
|
+
text: /^[^\n]+/
|
|
180
|
+
},
|
|
181
|
+
b = r(
|
|
182
|
+
'^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)'
|
|
183
|
+
)
|
|
184
|
+
.replace('hr', l)
|
|
185
|
+
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
|
186
|
+
.replace('blockquote', ' {0,3}>')
|
|
187
|
+
.replace('code', '(?: {4}| {0,3}\t)[^\\n]')
|
|
188
|
+
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
189
|
+
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ')
|
|
190
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
191
|
+
.replace('tag', g)
|
|
192
|
+
.getRegex(),
|
|
193
|
+
w = {
|
|
194
|
+
...x,
|
|
195
|
+
table: b,
|
|
196
|
+
paragraph: r(c)
|
|
197
|
+
.replace('hr', l)
|
|
198
|
+
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
|
199
|
+
.replace('|lheading', '')
|
|
200
|
+
.replace('table', b)
|
|
201
|
+
.replace('blockquote', ' {0,3}>')
|
|
202
|
+
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
203
|
+
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ')
|
|
204
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
205
|
+
.replace('tag', g)
|
|
206
|
+
.getRegex()
|
|
207
|
+
},
|
|
208
|
+
m = {
|
|
209
|
+
...x,
|
|
210
|
+
html: r(
|
|
211
|
+
'^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))'
|
|
212
|
+
)
|
|
213
|
+
.replace('comment', k)
|
|
214
|
+
.replace(
|
|
215
|
+
/tag/g,
|
|
216
|
+
'(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b'
|
|
217
|
+
)
|
|
218
|
+
.getRegex(),
|
|
219
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
220
|
+
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
221
|
+
fences: s,
|
|
222
|
+
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
223
|
+
paragraph: r(c)
|
|
224
|
+
.replace('hr', l)
|
|
225
|
+
.replace('heading', ' *#{1,6} *[^\n]')
|
|
226
|
+
.replace('lheading', a)
|
|
227
|
+
.replace('|table', '')
|
|
228
|
+
.replace('blockquote', ' {0,3}>')
|
|
229
|
+
.replace('|fences', '')
|
|
230
|
+
.replace('|list', '')
|
|
231
|
+
.replace('|html', '')
|
|
232
|
+
.replace('|tag', '')
|
|
233
|
+
.getRegex()
|
|
234
|
+
},
|
|
235
|
+
y = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
236
|
+
$ = /^( {2,}|\\)\n(?!\s*$)/,
|
|
237
|
+
R = /[\p{P}\p{S}]/u,
|
|
238
|
+
S = /[\s\p{P}\p{S}]/u,
|
|
239
|
+
T = /[^\s\p{P}\p{S}]/u,
|
|
240
|
+
z = r(/^((?![*_])punctSpace)/, 'u')
|
|
241
|
+
.replace(/punctSpace/g, S)
|
|
242
|
+
.getRegex(),
|
|
243
|
+
A = r(/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, 'u')
|
|
244
|
+
.replace(/punct/g, R)
|
|
245
|
+
.getRegex(),
|
|
246
|
+
_ = r(
|
|
247
|
+
'^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)',
|
|
248
|
+
'gu'
|
|
249
|
+
)
|
|
250
|
+
.replace(/notPunctSpace/g, T)
|
|
251
|
+
.replace(/punctSpace/g, S)
|
|
252
|
+
.replace(/punct/g, R)
|
|
253
|
+
.getRegex(),
|
|
254
|
+
P = r(
|
|
255
|
+
'^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)',
|
|
256
|
+
'gu'
|
|
257
|
+
)
|
|
258
|
+
.replace(/notPunctSpace/g, T)
|
|
259
|
+
.replace(/punctSpace/g, S)
|
|
260
|
+
.replace(/punct/g, R)
|
|
261
|
+
.getRegex(),
|
|
262
|
+
I = r(/\\(punct)/, 'gu')
|
|
263
|
+
.replace(/punct/g, R)
|
|
264
|
+
.getRegex(),
|
|
265
|
+
L = r(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/)
|
|
266
|
+
.replace('scheme', /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/)
|
|
267
|
+
.replace(
|
|
268
|
+
'email',
|
|
269
|
+
/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/
|
|
270
|
+
)
|
|
271
|
+
.getRegex(),
|
|
272
|
+
B = r(k).replace('(?:--\x3e|$)', '--\x3e').getRegex(),
|
|
273
|
+
C = r(
|
|
274
|
+
'^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>'
|
|
275
|
+
)
|
|
276
|
+
.replace('comment', B)
|
|
277
|
+
.replace(
|
|
278
|
+
'attribute',
|
|
279
|
+
/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/
|
|
280
|
+
)
|
|
281
|
+
.getRegex(),
|
|
282
|
+
E = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,
|
|
283
|
+
q = r(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/)
|
|
284
|
+
.replace('label', E)
|
|
285
|
+
.replace('href', /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/)
|
|
286
|
+
.replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/)
|
|
287
|
+
.getRegex(),
|
|
288
|
+
Z = r(/^!?\[(label)\]\[(ref)\]/)
|
|
289
|
+
.replace('label', E)
|
|
290
|
+
.replace('ref', h)
|
|
291
|
+
.getRegex(),
|
|
292
|
+
v = r(/^!?\[(ref)\](?:\[\])?/)
|
|
293
|
+
.replace('ref', h)
|
|
294
|
+
.getRegex(),
|
|
295
|
+
D = {
|
|
296
|
+
_backpedal: s,
|
|
297
|
+
anyPunctuation: I,
|
|
298
|
+
autolink: L,
|
|
299
|
+
blockSkip: /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,
|
|
300
|
+
br: $,
|
|
301
|
+
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
302
|
+
del: s,
|
|
303
|
+
emStrongLDelim: A,
|
|
304
|
+
emStrongRDelimAst: _,
|
|
305
|
+
emStrongRDelimUnd: P,
|
|
306
|
+
escape: y,
|
|
307
|
+
link: q,
|
|
308
|
+
nolink: v,
|
|
309
|
+
punctuation: z,
|
|
310
|
+
reflink: Z,
|
|
311
|
+
reflinkSearch: r('reflink|nolink(?!\\()', 'g')
|
|
312
|
+
.replace('reflink', Z)
|
|
313
|
+
.replace('nolink', v)
|
|
314
|
+
.getRegex(),
|
|
315
|
+
tag: C,
|
|
316
|
+
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
317
|
+
url: s
|
|
318
|
+
},
|
|
319
|
+
M = {
|
|
320
|
+
...D,
|
|
321
|
+
link: r(/^!?\[(label)\]\((.*?)\)/)
|
|
322
|
+
.replace('label', E)
|
|
323
|
+
.getRegex(),
|
|
324
|
+
reflink: r(/^!?\[(label)\]\s*\[([^\]]*)\]/)
|
|
325
|
+
.replace('label', E)
|
|
326
|
+
.getRegex()
|
|
327
|
+
},
|
|
328
|
+
O = {
|
|
329
|
+
...D,
|
|
330
|
+
escape: r(y).replace('])', '~|])').getRegex(),
|
|
331
|
+
url: r(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, 'i')
|
|
332
|
+
.replace(
|
|
333
|
+
'email',
|
|
334
|
+
/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/
|
|
335
|
+
)
|
|
336
|
+
.getRegex(),
|
|
337
|
+
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
338
|
+
del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
|
|
339
|
+
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
340
|
+
},
|
|
341
|
+
Q = {
|
|
342
|
+
...O,
|
|
343
|
+
br: r($).replace('{2,}', '*').getRegex(),
|
|
344
|
+
text: r(O.text)
|
|
345
|
+
.replace('\\b_', '\\b_| {2,}\\n')
|
|
346
|
+
.replace(/\{2,\}/g, '*')
|
|
347
|
+
.getRegex()
|
|
348
|
+
},
|
|
349
|
+
j = { normal: x, gfm: w, pedantic: m },
|
|
350
|
+
N = { normal: D, gfm: O, breaks: Q, pedantic: M },
|
|
351
|
+
G = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' },
|
|
352
|
+
H = (e) => G[e];
|
|
353
|
+
function X(e, t) {
|
|
354
|
+
if (t) {
|
|
355
|
+
if (i.escapeTest.test(e)) return e.replace(i.escapeReplace, H);
|
|
356
|
+
} else if (i.escapeTestNoEncode.test(e)) return e.replace(i.escapeReplaceNoEncode, H);
|
|
357
|
+
return e;
|
|
358
|
+
}
|
|
359
|
+
function F(e) {
|
|
360
|
+
try {
|
|
361
|
+
e = encodeURI(e).replace(i.percentDecode, '%');
|
|
362
|
+
} catch {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
return e;
|
|
366
|
+
}
|
|
367
|
+
function U(e, t) {
|
|
368
|
+
const n = e
|
|
369
|
+
.replace(i.findPipe, (e, t, n) => {
|
|
370
|
+
let s = !1,
|
|
371
|
+
r = t;
|
|
372
|
+
for (; --r >= 0 && '\\' === n[r]; ) s = !s;
|
|
373
|
+
return s ? '|' : ' |';
|
|
374
|
+
})
|
|
375
|
+
.split(i.splitPipe);
|
|
376
|
+
let s = 0;
|
|
377
|
+
if ((n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), t))
|
|
378
|
+
if (n.length > t) n.splice(t);
|
|
379
|
+
else for (; n.length < t; ) n.push('');
|
|
380
|
+
for (; s < n.length; s++) n[s] = n[s].trim().replace(i.slashPipe, '|');
|
|
381
|
+
return n;
|
|
382
|
+
}
|
|
383
|
+
function J(e, t, n) {
|
|
384
|
+
const s = e.length;
|
|
385
|
+
if (0 === s) return '';
|
|
386
|
+
let r = 0;
|
|
387
|
+
for (; r < s; ) {
|
|
388
|
+
const i = e.charAt(s - r - 1);
|
|
389
|
+
if (i !== t || n) {
|
|
390
|
+
if (i === t || !n) break;
|
|
391
|
+
r++;
|
|
392
|
+
} else r++;
|
|
393
|
+
}
|
|
394
|
+
return e.slice(0, s - r);
|
|
395
|
+
}
|
|
396
|
+
function K(e, t, n, s, r) {
|
|
397
|
+
const i = t.href,
|
|
398
|
+
l = t.title || null,
|
|
399
|
+
o = e[1].replace(r.other.outputLinkReplace, '$1');
|
|
400
|
+
if ('!' !== e[0].charAt(0)) {
|
|
401
|
+
s.state.inLink = !0;
|
|
402
|
+
const e = { type: 'link', raw: n, href: i, title: l, text: o, tokens: s.inlineTokens(o) };
|
|
403
|
+
return ((s.state.inLink = !1), e);
|
|
404
|
+
}
|
|
405
|
+
return { type: 'image', raw: n, href: i, title: l, text: o };
|
|
406
|
+
}
|
|
407
|
+
class V {
|
|
408
|
+
options;
|
|
409
|
+
rules;
|
|
410
|
+
lexer;
|
|
411
|
+
constructor(t) {
|
|
412
|
+
this.options = t || e.defaults;
|
|
413
|
+
}
|
|
414
|
+
space(e) {
|
|
415
|
+
const t = this.rules.block.newline.exec(e);
|
|
416
|
+
if (t && t[0].length > 0) return { type: 'space', raw: t[0] };
|
|
417
|
+
}
|
|
418
|
+
code(e) {
|
|
419
|
+
const t = this.rules.block.code.exec(e);
|
|
420
|
+
if (t) {
|
|
421
|
+
const e = t[0].replace(this.rules.other.codeRemoveIndent, '');
|
|
422
|
+
return {
|
|
423
|
+
type: 'code',
|
|
424
|
+
raw: t[0],
|
|
425
|
+
codeBlockStyle: 'indented',
|
|
426
|
+
text: this.options.pedantic ? e : J(e, '\n')
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
fences(e) {
|
|
431
|
+
const t = this.rules.block.fences.exec(e);
|
|
432
|
+
if (t) {
|
|
433
|
+
const e = t[0],
|
|
434
|
+
n = (function (e, t, n) {
|
|
435
|
+
const s = e.match(n.other.indentCodeCompensation);
|
|
436
|
+
if (null === s) return t;
|
|
437
|
+
const r = s[1];
|
|
438
|
+
return t
|
|
439
|
+
.split('\n')
|
|
440
|
+
.map((e) => {
|
|
441
|
+
const t = e.match(n.other.beginningSpace);
|
|
442
|
+
if (null === t) return e;
|
|
443
|
+
const [s] = t;
|
|
444
|
+
return s.length >= r.length ? e.slice(r.length) : e;
|
|
445
|
+
})
|
|
446
|
+
.join('\n');
|
|
447
|
+
})(e, t[3] || '', this.rules);
|
|
448
|
+
return {
|
|
449
|
+
type: 'code',
|
|
450
|
+
raw: e,
|
|
451
|
+
lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, '$1') : t[2],
|
|
452
|
+
text: n
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
heading(e) {
|
|
457
|
+
const t = this.rules.block.heading.exec(e);
|
|
458
|
+
if (t) {
|
|
459
|
+
let e = t[2].trim();
|
|
460
|
+
if (this.rules.other.endingHash.test(e)) {
|
|
461
|
+
const t = J(e, '#');
|
|
462
|
+
this.options.pedantic
|
|
463
|
+
? (e = t.trim())
|
|
464
|
+
: (t && !this.rules.other.endingSpaceChar.test(t)) || (e = t.trim());
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
type: 'heading',
|
|
468
|
+
raw: t[0],
|
|
469
|
+
depth: t[1].length,
|
|
470
|
+
text: e,
|
|
471
|
+
tokens: this.lexer.inline(e)
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
hr(e) {
|
|
476
|
+
const t = this.rules.block.hr.exec(e);
|
|
477
|
+
if (t) return { type: 'hr', raw: J(t[0], '\n') };
|
|
478
|
+
}
|
|
479
|
+
blockquote(e) {
|
|
480
|
+
const t = this.rules.block.blockquote.exec(e);
|
|
481
|
+
if (t) {
|
|
482
|
+
let e = J(t[0], '\n').split('\n'),
|
|
483
|
+
n = '',
|
|
484
|
+
s = '';
|
|
485
|
+
const r = [];
|
|
486
|
+
for (; e.length > 0; ) {
|
|
487
|
+
let t = !1;
|
|
488
|
+
const i = [];
|
|
489
|
+
let l;
|
|
490
|
+
for (l = 0; l < e.length; l++)
|
|
491
|
+
if (this.rules.other.blockquoteStart.test(e[l])) (i.push(e[l]), (t = !0));
|
|
492
|
+
else {
|
|
493
|
+
if (t) break;
|
|
494
|
+
i.push(e[l]);
|
|
495
|
+
}
|
|
496
|
+
e = e.slice(l);
|
|
497
|
+
const o = i.join('\n'),
|
|
498
|
+
a = o
|
|
499
|
+
.replace(this.rules.other.blockquoteSetextReplace, '\n $1')
|
|
500
|
+
.replace(this.rules.other.blockquoteSetextReplace2, '');
|
|
501
|
+
((n = n ? `${n}\n${o}` : o), (s = s ? `${s}\n${a}` : a));
|
|
502
|
+
const c = this.lexer.state.top;
|
|
503
|
+
if (
|
|
504
|
+
((this.lexer.state.top = !0),
|
|
505
|
+
this.lexer.blockTokens(a, r, !0),
|
|
506
|
+
(this.lexer.state.top = c),
|
|
507
|
+
0 === e.length)
|
|
508
|
+
)
|
|
509
|
+
break;
|
|
510
|
+
const h = r.at(-1);
|
|
511
|
+
if ('code' === h?.type) break;
|
|
512
|
+
if ('blockquote' === h?.type) {
|
|
513
|
+
const t = h,
|
|
514
|
+
i = t.raw + '\n' + e.join('\n'),
|
|
515
|
+
l = this.blockquote(i);
|
|
516
|
+
((r[r.length - 1] = l),
|
|
517
|
+
(n = n.substring(0, n.length - t.raw.length) + l.raw),
|
|
518
|
+
(s = s.substring(0, s.length - t.text.length) + l.text));
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
if ('list' !== h?.type);
|
|
522
|
+
else {
|
|
523
|
+
const t = h,
|
|
524
|
+
i = t.raw + '\n' + e.join('\n'),
|
|
525
|
+
l = this.list(i);
|
|
526
|
+
((r[r.length - 1] = l),
|
|
527
|
+
(n = n.substring(0, n.length - h.raw.length) + l.raw),
|
|
528
|
+
(s = s.substring(0, s.length - t.raw.length) + l.raw),
|
|
529
|
+
(e = i.substring(r.at(-1).raw.length).split('\n')));
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return { type: 'blockquote', raw: n, tokens: r, text: s };
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
list(e) {
|
|
536
|
+
let t = this.rules.block.list.exec(e);
|
|
537
|
+
if (t) {
|
|
538
|
+
let n = t[1].trim();
|
|
539
|
+
const s = n.length > 1,
|
|
540
|
+
r = {
|
|
541
|
+
type: 'list',
|
|
542
|
+
raw: '',
|
|
543
|
+
ordered: s,
|
|
544
|
+
start: s ? +n.slice(0, -1) : '',
|
|
545
|
+
loose: !1,
|
|
546
|
+
items: []
|
|
547
|
+
};
|
|
548
|
+
((n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`),
|
|
549
|
+
this.options.pedantic && (n = s ? n : '[*+-]'));
|
|
550
|
+
const i = this.rules.other.listItemRegex(n);
|
|
551
|
+
let l = !1;
|
|
552
|
+
for (; e; ) {
|
|
553
|
+
let n = !1,
|
|
554
|
+
s = '',
|
|
555
|
+
o = '';
|
|
556
|
+
if (!(t = i.exec(e))) break;
|
|
557
|
+
if (this.rules.block.hr.test(e)) break;
|
|
558
|
+
((s = t[0]), (e = e.substring(s.length)));
|
|
559
|
+
let a = t[2]
|
|
560
|
+
.split('\n', 1)[0]
|
|
561
|
+
.replace(this.rules.other.listReplaceTabs, (e) => ' '.repeat(3 * e.length)),
|
|
562
|
+
c = e.split('\n', 1)[0],
|
|
563
|
+
h = !a.trim(),
|
|
564
|
+
p = 0;
|
|
565
|
+
if (
|
|
566
|
+
(this.options.pedantic
|
|
567
|
+
? ((p = 2), (o = a.trimStart()))
|
|
568
|
+
: h
|
|
569
|
+
? (p = t[1].length + 1)
|
|
570
|
+
: ((p = t[2].search(this.rules.other.nonSpaceChar)),
|
|
571
|
+
(p = p > 4 ? 1 : p),
|
|
572
|
+
(o = a.slice(p)),
|
|
573
|
+
(p += t[1].length)),
|
|
574
|
+
h &&
|
|
575
|
+
this.rules.other.blankLine.test(c) &&
|
|
576
|
+
((s += c + '\n'), (e = e.substring(c.length + 1)), (n = !0)),
|
|
577
|
+
!n)
|
|
578
|
+
) {
|
|
579
|
+
const t = this.rules.other.nextBulletRegex(p),
|
|
580
|
+
n = this.rules.other.hrRegex(p),
|
|
581
|
+
r = this.rules.other.fencesBeginRegex(p),
|
|
582
|
+
i = this.rules.other.headingBeginRegex(p),
|
|
583
|
+
l = this.rules.other.htmlBeginRegex(p);
|
|
584
|
+
for (; e; ) {
|
|
585
|
+
const u = e.split('\n', 1)[0];
|
|
586
|
+
let g;
|
|
587
|
+
if (
|
|
588
|
+
((c = u),
|
|
589
|
+
this.options.pedantic
|
|
590
|
+
? ((c = c.replace(this.rules.other.listReplaceNesting, ' ')), (g = c))
|
|
591
|
+
: (g = c.replace(this.rules.other.tabCharGlobal, ' ')),
|
|
592
|
+
r.test(c))
|
|
593
|
+
)
|
|
594
|
+
break;
|
|
595
|
+
if (i.test(c)) break;
|
|
596
|
+
if (l.test(c)) break;
|
|
597
|
+
if (t.test(c)) break;
|
|
598
|
+
if (n.test(c)) break;
|
|
599
|
+
if (g.search(this.rules.other.nonSpaceChar) >= p || !c.trim()) o += '\n' + g.slice(p);
|
|
600
|
+
else {
|
|
601
|
+
if (h) break;
|
|
602
|
+
if (
|
|
603
|
+
a
|
|
604
|
+
.replace(this.rules.other.tabCharGlobal, ' ')
|
|
605
|
+
.search(this.rules.other.nonSpaceChar) >= 4
|
|
606
|
+
)
|
|
607
|
+
break;
|
|
608
|
+
if (r.test(a)) break;
|
|
609
|
+
if (i.test(a)) break;
|
|
610
|
+
if (n.test(a)) break;
|
|
611
|
+
o += '\n' + c;
|
|
612
|
+
}
|
|
613
|
+
(h || c.trim() || (h = !0),
|
|
614
|
+
(s += u + '\n'),
|
|
615
|
+
(e = e.substring(u.length + 1)),
|
|
616
|
+
(a = g.slice(p)));
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
r.loose || (l ? (r.loose = !0) : this.rules.other.doubleBlankLine.test(s) && (l = !0));
|
|
620
|
+
let u,
|
|
621
|
+
g = null;
|
|
622
|
+
(this.options.gfm &&
|
|
623
|
+
((g = this.rules.other.listIsTask.exec(o)),
|
|
624
|
+
g && ((u = '[ ] ' !== g[0]), (o = o.replace(this.rules.other.listReplaceTask, '')))),
|
|
625
|
+
r.items.push({
|
|
626
|
+
type: 'list_item',
|
|
627
|
+
raw: s,
|
|
628
|
+
task: !!g,
|
|
629
|
+
checked: u,
|
|
630
|
+
loose: !1,
|
|
631
|
+
text: o,
|
|
632
|
+
tokens: []
|
|
633
|
+
}),
|
|
634
|
+
(r.raw += s));
|
|
635
|
+
}
|
|
636
|
+
const o = r.items.at(-1);
|
|
637
|
+
if (!o) return;
|
|
638
|
+
((o.raw = o.raw.trimEnd()), (o.text = o.text.trimEnd()), (r.raw = r.raw.trimEnd()));
|
|
639
|
+
for (let e = 0; e < r.items.length; e++)
|
|
640
|
+
if (
|
|
641
|
+
((this.lexer.state.top = !1),
|
|
642
|
+
(r.items[e].tokens = this.lexer.blockTokens(r.items[e].text, [])),
|
|
643
|
+
!r.loose)
|
|
644
|
+
) {
|
|
645
|
+
const t = r.items[e].tokens.filter((e) => 'space' === e.type),
|
|
646
|
+
n = t.length > 0 && t.some((e) => this.rules.other.anyLine.test(e.raw));
|
|
647
|
+
r.loose = n;
|
|
648
|
+
}
|
|
649
|
+
if (r.loose) for (let e = 0; e < r.items.length; e++) r.items[e].loose = !0;
|
|
650
|
+
return r;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
html(e) {
|
|
654
|
+
const t = this.rules.block.html.exec(e);
|
|
655
|
+
if (t) {
|
|
656
|
+
return {
|
|
657
|
+
type: 'html',
|
|
658
|
+
block: !0,
|
|
659
|
+
raw: t[0],
|
|
660
|
+
pre: 'pre' === t[1] || 'script' === t[1] || 'style' === t[1],
|
|
661
|
+
text: t[0]
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
def(e) {
|
|
666
|
+
const t = this.rules.block.def.exec(e);
|
|
667
|
+
if (t) {
|
|
668
|
+
const e = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, ' '),
|
|
669
|
+
n = t[2]
|
|
670
|
+
? t[2]
|
|
671
|
+
.replace(this.rules.other.hrefBrackets, '$1')
|
|
672
|
+
.replace(this.rules.inline.anyPunctuation, '$1')
|
|
673
|
+
: '',
|
|
674
|
+
s = t[3]
|
|
675
|
+
? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, '$1')
|
|
676
|
+
: t[3];
|
|
677
|
+
return { type: 'def', tag: e, raw: t[0], href: n, title: s };
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
table(e) {
|
|
681
|
+
const t = this.rules.block.table.exec(e);
|
|
682
|
+
if (!t) return;
|
|
683
|
+
if (!this.rules.other.tableDelimiter.test(t[2])) return;
|
|
684
|
+
const n = U(t[1]),
|
|
685
|
+
s = t[2].replace(this.rules.other.tableAlignChars, '').split('|'),
|
|
686
|
+
r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, '').split('\n') : [],
|
|
687
|
+
i = { type: 'table', raw: t[0], header: [], align: [], rows: [] };
|
|
688
|
+
if (n.length === s.length) {
|
|
689
|
+
for (const e of s)
|
|
690
|
+
this.rules.other.tableAlignRight.test(e)
|
|
691
|
+
? i.align.push('right')
|
|
692
|
+
: this.rules.other.tableAlignCenter.test(e)
|
|
693
|
+
? i.align.push('center')
|
|
694
|
+
: this.rules.other.tableAlignLeft.test(e)
|
|
695
|
+
? i.align.push('left')
|
|
696
|
+
: i.align.push(null);
|
|
697
|
+
for (let e = 0; e < n.length; e++)
|
|
698
|
+
i.header.push({
|
|
699
|
+
text: n[e],
|
|
700
|
+
tokens: this.lexer.inline(n[e]),
|
|
701
|
+
header: !0,
|
|
702
|
+
align: i.align[e]
|
|
703
|
+
});
|
|
704
|
+
for (const e of r)
|
|
705
|
+
i.rows.push(
|
|
706
|
+
U(e, i.header.length).map((e, t) => ({
|
|
707
|
+
text: e,
|
|
708
|
+
tokens: this.lexer.inline(e),
|
|
709
|
+
header: !1,
|
|
710
|
+
align: i.align[t]
|
|
711
|
+
}))
|
|
712
|
+
);
|
|
713
|
+
return i;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
lheading(e) {
|
|
717
|
+
const t = this.rules.block.lheading.exec(e);
|
|
718
|
+
if (t)
|
|
719
|
+
return {
|
|
720
|
+
type: 'heading',
|
|
721
|
+
raw: t[0],
|
|
722
|
+
depth: '=' === t[2].charAt(0) ? 1 : 2,
|
|
723
|
+
text: t[1],
|
|
724
|
+
tokens: this.lexer.inline(t[1])
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
paragraph(e) {
|
|
728
|
+
const t = this.rules.block.paragraph.exec(e);
|
|
729
|
+
if (t) {
|
|
730
|
+
const e = '\n' === t[1].charAt(t[1].length - 1) ? t[1].slice(0, -1) : t[1];
|
|
731
|
+
return { type: 'paragraph', raw: t[0], text: e, tokens: this.lexer.inline(e) };
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
text(e) {
|
|
735
|
+
const t = this.rules.block.text.exec(e);
|
|
736
|
+
if (t) return { type: 'text', raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
|
|
737
|
+
}
|
|
738
|
+
escape(e) {
|
|
739
|
+
const t = this.rules.inline.escape.exec(e);
|
|
740
|
+
if (t) return { type: 'escape', raw: t[0], text: t[1] };
|
|
741
|
+
}
|
|
742
|
+
tag(e) {
|
|
743
|
+
const t = this.rules.inline.tag.exec(e);
|
|
744
|
+
if (t)
|
|
745
|
+
return (
|
|
746
|
+
!this.lexer.state.inLink && this.rules.other.startATag.test(t[0])
|
|
747
|
+
? (this.lexer.state.inLink = !0)
|
|
748
|
+
: this.lexer.state.inLink &&
|
|
749
|
+
this.rules.other.endATag.test(t[0]) &&
|
|
750
|
+
(this.lexer.state.inLink = !1),
|
|
751
|
+
!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0])
|
|
752
|
+
? (this.lexer.state.inRawBlock = !0)
|
|
753
|
+
: this.lexer.state.inRawBlock &&
|
|
754
|
+
this.rules.other.endPreScriptTag.test(t[0]) &&
|
|
755
|
+
(this.lexer.state.inRawBlock = !1),
|
|
756
|
+
{
|
|
757
|
+
type: 'html',
|
|
758
|
+
raw: t[0],
|
|
759
|
+
inLink: this.lexer.state.inLink,
|
|
760
|
+
inRawBlock: this.lexer.state.inRawBlock,
|
|
761
|
+
block: !1,
|
|
762
|
+
text: t[0]
|
|
763
|
+
}
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
link(e) {
|
|
767
|
+
const t = this.rules.inline.link.exec(e);
|
|
768
|
+
if (t) {
|
|
769
|
+
const e = t[2].trim();
|
|
770
|
+
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(e)) {
|
|
771
|
+
if (!this.rules.other.endAngleBracket.test(e)) return;
|
|
772
|
+
const t = J(e.slice(0, -1), '\\');
|
|
773
|
+
if ((e.length - t.length) % 2 == 0) return;
|
|
774
|
+
} else {
|
|
775
|
+
const e = (function (e, t) {
|
|
776
|
+
if (-1 === e.indexOf(t[1])) return -1;
|
|
777
|
+
let n = 0;
|
|
778
|
+
for (let s = 0; s < e.length; s++)
|
|
779
|
+
if ('\\' === e[s]) s++;
|
|
780
|
+
else if (e[s] === t[0]) n++;
|
|
781
|
+
else if (e[s] === t[1] && (n--, n < 0)) return s;
|
|
782
|
+
return -1;
|
|
783
|
+
})(t[2], '()');
|
|
784
|
+
if (e > -1) {
|
|
785
|
+
const n = (0 === t[0].indexOf('!') ? 5 : 4) + t[1].length + e;
|
|
786
|
+
((t[2] = t[2].substring(0, e)), (t[0] = t[0].substring(0, n).trim()), (t[3] = ''));
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
let n = t[2],
|
|
790
|
+
s = '';
|
|
791
|
+
if (this.options.pedantic) {
|
|
792
|
+
const e = this.rules.other.pedanticHrefTitle.exec(n);
|
|
793
|
+
e && ((n = e[1]), (s = e[3]));
|
|
794
|
+
} else s = t[3] ? t[3].slice(1, -1) : '';
|
|
795
|
+
return (
|
|
796
|
+
(n = n.trim()),
|
|
797
|
+
this.rules.other.startAngleBracket.test(n) &&
|
|
798
|
+
(n =
|
|
799
|
+
this.options.pedantic && !this.rules.other.endAngleBracket.test(e)
|
|
800
|
+
? n.slice(1)
|
|
801
|
+
: n.slice(1, -1)),
|
|
802
|
+
K(
|
|
803
|
+
t,
|
|
804
|
+
{
|
|
805
|
+
href: n ? n.replace(this.rules.inline.anyPunctuation, '$1') : n,
|
|
806
|
+
title: s ? s.replace(this.rules.inline.anyPunctuation, '$1') : s
|
|
807
|
+
},
|
|
808
|
+
t[0],
|
|
809
|
+
this.lexer,
|
|
810
|
+
this.rules
|
|
811
|
+
)
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
reflink(e, t) {
|
|
816
|
+
let n;
|
|
817
|
+
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
818
|
+
const e =
|
|
819
|
+
t[(n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, ' ').toLowerCase()];
|
|
820
|
+
if (!e) {
|
|
821
|
+
const e = n[0].charAt(0);
|
|
822
|
+
return { type: 'text', raw: e, text: e };
|
|
823
|
+
}
|
|
824
|
+
return K(n, e, n[0], this.lexer, this.rules);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
emStrong(e, t, n = '') {
|
|
828
|
+
let s = this.rules.inline.emStrongLDelim.exec(e);
|
|
829
|
+
if (!s) return;
|
|
830
|
+
if (s[3] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
831
|
+
if (!(s[1] || s[2] || '') || !n || this.rules.inline.punctuation.exec(n)) {
|
|
832
|
+
const n = [...s[0]].length - 1;
|
|
833
|
+
let r,
|
|
834
|
+
i,
|
|
835
|
+
l = n,
|
|
836
|
+
o = 0;
|
|
837
|
+
const a =
|
|
838
|
+
'*' === s[0][0]
|
|
839
|
+
? this.rules.inline.emStrongRDelimAst
|
|
840
|
+
: this.rules.inline.emStrongRDelimUnd;
|
|
841
|
+
for (a.lastIndex = 0, t = t.slice(-1 * e.length + n); null != (s = a.exec(t)); ) {
|
|
842
|
+
if (((r = s[1] || s[2] || s[3] || s[4] || s[5] || s[6]), !r)) continue;
|
|
843
|
+
if (((i = [...r].length), s[3] || s[4])) {
|
|
844
|
+
l += i;
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
if ((s[5] || s[6]) && n % 3 && !((n + i) % 3)) {
|
|
848
|
+
o += i;
|
|
849
|
+
continue;
|
|
850
|
+
}
|
|
851
|
+
if (((l -= i), l > 0)) continue;
|
|
852
|
+
i = Math.min(i, i + l + o);
|
|
853
|
+
const t = [...s[0]][0].length,
|
|
854
|
+
a = e.slice(0, n + s.index + t + i);
|
|
855
|
+
if (Math.min(n, i) % 2) {
|
|
856
|
+
const e = a.slice(1, -1);
|
|
857
|
+
return { type: 'em', raw: a, text: e, tokens: this.lexer.inlineTokens(e) };
|
|
858
|
+
}
|
|
859
|
+
const c = a.slice(2, -2);
|
|
860
|
+
return { type: 'strong', raw: a, text: c, tokens: this.lexer.inlineTokens(c) };
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
codespan(e) {
|
|
865
|
+
const t = this.rules.inline.code.exec(e);
|
|
866
|
+
if (t) {
|
|
867
|
+
let e = t[2].replace(this.rules.other.newLineCharGlobal, ' ');
|
|
868
|
+
const n = this.rules.other.nonSpaceChar.test(e),
|
|
869
|
+
s =
|
|
870
|
+
this.rules.other.startingSpaceChar.test(e) && this.rules.other.endingSpaceChar.test(e);
|
|
871
|
+
return (
|
|
872
|
+
n && s && (e = e.substring(1, e.length - 1)),
|
|
873
|
+
{ type: 'codespan', raw: t[0], text: e }
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
br(e) {
|
|
878
|
+
const t = this.rules.inline.br.exec(e);
|
|
879
|
+
if (t) return { type: 'br', raw: t[0] };
|
|
880
|
+
}
|
|
881
|
+
del(e) {
|
|
882
|
+
const t = this.rules.inline.del.exec(e);
|
|
883
|
+
if (t) return { type: 'del', raw: t[0], text: t[2], tokens: this.lexer.inlineTokens(t[2]) };
|
|
884
|
+
}
|
|
885
|
+
autolink(e) {
|
|
886
|
+
const t = this.rules.inline.autolink.exec(e);
|
|
887
|
+
if (t) {
|
|
888
|
+
let e, n;
|
|
889
|
+
return (
|
|
890
|
+
'@' === t[2] ? ((e = t[1]), (n = 'mailto:' + e)) : ((e = t[1]), (n = e)),
|
|
891
|
+
{ type: 'link', raw: t[0], text: e, href: n, tokens: [{ type: 'text', raw: e, text: e }] }
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
url(e) {
|
|
896
|
+
let t;
|
|
897
|
+
if ((t = this.rules.inline.url.exec(e))) {
|
|
898
|
+
let e, n;
|
|
899
|
+
if ('@' === t[2]) ((e = t[0]), (n = 'mailto:' + e));
|
|
900
|
+
else {
|
|
901
|
+
let s;
|
|
902
|
+
do {
|
|
903
|
+
((s = t[0]), (t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? ''));
|
|
904
|
+
} while (s !== t[0]);
|
|
905
|
+
((e = t[0]), (n = 'www.' === t[1] ? 'http://' + t[0] : t[0]));
|
|
906
|
+
}
|
|
907
|
+
return {
|
|
908
|
+
type: 'link',
|
|
909
|
+
raw: t[0],
|
|
910
|
+
text: e,
|
|
911
|
+
href: n,
|
|
912
|
+
tokens: [{ type: 'text', raw: e, text: e }]
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
inlineText(e) {
|
|
917
|
+
const t = this.rules.inline.text.exec(e);
|
|
918
|
+
if (t) {
|
|
919
|
+
const e = this.lexer.state.inRawBlock;
|
|
920
|
+
return { type: 'text', raw: t[0], text: t[0], escaped: e };
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
class W {
|
|
925
|
+
tokens;
|
|
926
|
+
options;
|
|
927
|
+
state;
|
|
928
|
+
tokenizer;
|
|
929
|
+
inlineQueue;
|
|
930
|
+
constructor(t) {
|
|
931
|
+
((this.tokens = []),
|
|
932
|
+
(this.tokens.links = Object.create(null)),
|
|
933
|
+
(this.options = t || e.defaults),
|
|
934
|
+
(this.options.tokenizer = this.options.tokenizer || new V()),
|
|
935
|
+
(this.tokenizer = this.options.tokenizer),
|
|
936
|
+
(this.tokenizer.options = this.options),
|
|
937
|
+
(this.tokenizer.lexer = this),
|
|
938
|
+
(this.inlineQueue = []),
|
|
939
|
+
(this.state = { inLink: !1, inRawBlock: !1, top: !0 }));
|
|
940
|
+
const n = { other: i, block: j.normal, inline: N.normal };
|
|
941
|
+
(this.options.pedantic
|
|
942
|
+
? ((n.block = j.pedantic), (n.inline = N.pedantic))
|
|
943
|
+
: this.options.gfm &&
|
|
944
|
+
((n.block = j.gfm), this.options.breaks ? (n.inline = N.breaks) : (n.inline = N.gfm)),
|
|
945
|
+
(this.tokenizer.rules = n));
|
|
946
|
+
}
|
|
947
|
+
static get rules() {
|
|
948
|
+
return { block: j, inline: N };
|
|
949
|
+
}
|
|
950
|
+
static lex(e, t) {
|
|
951
|
+
return new W(t).lex(e);
|
|
952
|
+
}
|
|
953
|
+
static lexInline(e, t) {
|
|
954
|
+
return new W(t).inlineTokens(e);
|
|
955
|
+
}
|
|
956
|
+
lex(e) {
|
|
957
|
+
((e = e.replace(i.carriageReturn, '\n')), this.blockTokens(e, this.tokens));
|
|
958
|
+
for (let e = 0; e < this.inlineQueue.length; e++) {
|
|
959
|
+
const t = this.inlineQueue[e];
|
|
960
|
+
this.inlineTokens(t.src, t.tokens);
|
|
961
|
+
}
|
|
962
|
+
return ((this.inlineQueue = []), this.tokens);
|
|
963
|
+
}
|
|
964
|
+
blockTokens(e, t = [], n = !1) {
|
|
965
|
+
for (
|
|
966
|
+
this.options.pedantic && (e = e.replace(i.tabCharGlobal, ' ').replace(i.spaceLine, ''));
|
|
967
|
+
e;
|
|
968
|
+
) {
|
|
969
|
+
let s;
|
|
970
|
+
if (
|
|
971
|
+
this.options.extensions?.block?.some(
|
|
972
|
+
(n) =>
|
|
973
|
+
!!(s = n.call({ lexer: this }, e, t)) &&
|
|
974
|
+
((e = e.substring(s.raw.length)), t.push(s), !0)
|
|
975
|
+
)
|
|
976
|
+
)
|
|
977
|
+
continue;
|
|
978
|
+
if ((s = this.tokenizer.space(e))) {
|
|
979
|
+
e = e.substring(s.raw.length);
|
|
980
|
+
const n = t.at(-1);
|
|
981
|
+
1 === s.raw.length && void 0 !== n ? (n.raw += '\n') : t.push(s);
|
|
982
|
+
continue;
|
|
983
|
+
}
|
|
984
|
+
if ((s = this.tokenizer.code(e))) {
|
|
985
|
+
e = e.substring(s.raw.length);
|
|
986
|
+
const n = t.at(-1);
|
|
987
|
+
'paragraph' === n?.type || 'text' === n?.type
|
|
988
|
+
? ((n.raw += '\n' + s.raw),
|
|
989
|
+
(n.text += '\n' + s.text),
|
|
990
|
+
(this.inlineQueue.at(-1).src = n.text))
|
|
991
|
+
: t.push(s);
|
|
992
|
+
continue;
|
|
993
|
+
}
|
|
994
|
+
if ((s = this.tokenizer.fences(e))) {
|
|
995
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
996
|
+
continue;
|
|
997
|
+
}
|
|
998
|
+
if ((s = this.tokenizer.heading(e))) {
|
|
999
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1000
|
+
continue;
|
|
1001
|
+
}
|
|
1002
|
+
if ((s = this.tokenizer.hr(e))) {
|
|
1003
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1004
|
+
continue;
|
|
1005
|
+
}
|
|
1006
|
+
if ((s = this.tokenizer.blockquote(e))) {
|
|
1007
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1008
|
+
continue;
|
|
1009
|
+
}
|
|
1010
|
+
if ((s = this.tokenizer.list(e))) {
|
|
1011
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1012
|
+
continue;
|
|
1013
|
+
}
|
|
1014
|
+
if ((s = this.tokenizer.html(e))) {
|
|
1015
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1016
|
+
continue;
|
|
1017
|
+
}
|
|
1018
|
+
if ((s = this.tokenizer.def(e))) {
|
|
1019
|
+
e = e.substring(s.raw.length);
|
|
1020
|
+
const n = t.at(-1);
|
|
1021
|
+
'paragraph' === n?.type || 'text' === n?.type
|
|
1022
|
+
? ((n.raw += '\n' + s.raw),
|
|
1023
|
+
(n.text += '\n' + s.raw),
|
|
1024
|
+
(this.inlineQueue.at(-1).src = n.text))
|
|
1025
|
+
: this.tokens.links[s.tag] ||
|
|
1026
|
+
(this.tokens.links[s.tag] = { href: s.href, title: s.title });
|
|
1027
|
+
continue;
|
|
1028
|
+
}
|
|
1029
|
+
if ((s = this.tokenizer.table(e))) {
|
|
1030
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1031
|
+
continue;
|
|
1032
|
+
}
|
|
1033
|
+
if ((s = this.tokenizer.lheading(e))) {
|
|
1034
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1035
|
+
continue;
|
|
1036
|
+
}
|
|
1037
|
+
let r = e;
|
|
1038
|
+
if (this.options.extensions?.startBlock) {
|
|
1039
|
+
let t = 1 / 0;
|
|
1040
|
+
const n = e.slice(1);
|
|
1041
|
+
let s;
|
|
1042
|
+
(this.options.extensions.startBlock.forEach((e) => {
|
|
1043
|
+
((s = e.call({ lexer: this }, n)),
|
|
1044
|
+
'number' == typeof s && s >= 0 && (t = Math.min(t, s)));
|
|
1045
|
+
}),
|
|
1046
|
+
t < 1 / 0 && t >= 0 && (r = e.substring(0, t + 1)));
|
|
1047
|
+
}
|
|
1048
|
+
if (this.state.top && (s = this.tokenizer.paragraph(r))) {
|
|
1049
|
+
const i = t.at(-1);
|
|
1050
|
+
(n && 'paragraph' === i?.type
|
|
1051
|
+
? ((i.raw += '\n' + s.raw),
|
|
1052
|
+
(i.text += '\n' + s.text),
|
|
1053
|
+
this.inlineQueue.pop(),
|
|
1054
|
+
(this.inlineQueue.at(-1).src = i.text))
|
|
1055
|
+
: t.push(s),
|
|
1056
|
+
(n = r.length !== e.length),
|
|
1057
|
+
(e = e.substring(s.raw.length)));
|
|
1058
|
+
} else if ((s = this.tokenizer.text(e))) {
|
|
1059
|
+
e = e.substring(s.raw.length);
|
|
1060
|
+
const n = t.at(-1);
|
|
1061
|
+
'text' === n?.type
|
|
1062
|
+
? ((n.raw += '\n' + s.raw),
|
|
1063
|
+
(n.text += '\n' + s.text),
|
|
1064
|
+
this.inlineQueue.pop(),
|
|
1065
|
+
(this.inlineQueue.at(-1).src = n.text))
|
|
1066
|
+
: t.push(s);
|
|
1067
|
+
} else if (e) {
|
|
1068
|
+
const t = 'Infinite loop on byte: ' + e.charCodeAt(0);
|
|
1069
|
+
if (this.options.silent) {
|
|
1070
|
+
console.error(t);
|
|
1071
|
+
break;
|
|
1072
|
+
}
|
|
1073
|
+
throw new Error(t);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
return ((this.state.top = !0), t);
|
|
1077
|
+
}
|
|
1078
|
+
inline(e, t = []) {
|
|
1079
|
+
return (this.inlineQueue.push({ src: e, tokens: t }), t);
|
|
1080
|
+
}
|
|
1081
|
+
inlineTokens(e, t = []) {
|
|
1082
|
+
let n = e,
|
|
1083
|
+
s = null;
|
|
1084
|
+
if (this.tokens.links) {
|
|
1085
|
+
const e = Object.keys(this.tokens.links);
|
|
1086
|
+
if (e.length > 0)
|
|
1087
|
+
for (; null != (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)); )
|
|
1088
|
+
e.includes(s[0].slice(s[0].lastIndexOf('[') + 1, -1)) &&
|
|
1089
|
+
(n =
|
|
1090
|
+
n.slice(0, s.index) +
|
|
1091
|
+
'[' +
|
|
1092
|
+
'a'.repeat(s[0].length - 2) +
|
|
1093
|
+
']' +
|
|
1094
|
+
n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
1095
|
+
}
|
|
1096
|
+
for (; null != (s = this.tokenizer.rules.inline.blockSkip.exec(n)); )
|
|
1097
|
+
n =
|
|
1098
|
+
n.slice(0, s.index) +
|
|
1099
|
+
'[' +
|
|
1100
|
+
'a'.repeat(s[0].length - 2) +
|
|
1101
|
+
']' +
|
|
1102
|
+
n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
1103
|
+
for (; null != (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)); )
|
|
1104
|
+
n =
|
|
1105
|
+
n.slice(0, s.index) +
|
|
1106
|
+
'++' +
|
|
1107
|
+
n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
1108
|
+
let r = !1,
|
|
1109
|
+
i = '';
|
|
1110
|
+
for (; e; ) {
|
|
1111
|
+
let s;
|
|
1112
|
+
if (
|
|
1113
|
+
(r || (i = ''),
|
|
1114
|
+
(r = !1),
|
|
1115
|
+
this.options.extensions?.inline?.some(
|
|
1116
|
+
(n) =>
|
|
1117
|
+
!!(s = n.call({ lexer: this }, e, t)) &&
|
|
1118
|
+
((e = e.substring(s.raw.length)), t.push(s), !0)
|
|
1119
|
+
))
|
|
1120
|
+
)
|
|
1121
|
+
continue;
|
|
1122
|
+
if ((s = this.tokenizer.escape(e))) {
|
|
1123
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1124
|
+
continue;
|
|
1125
|
+
}
|
|
1126
|
+
if ((s = this.tokenizer.tag(e))) {
|
|
1127
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1128
|
+
continue;
|
|
1129
|
+
}
|
|
1130
|
+
if ((s = this.tokenizer.link(e))) {
|
|
1131
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
if ((s = this.tokenizer.reflink(e, this.tokens.links))) {
|
|
1135
|
+
e = e.substring(s.raw.length);
|
|
1136
|
+
const n = t.at(-1);
|
|
1137
|
+
'text' === s.type && 'text' === n?.type
|
|
1138
|
+
? ((n.raw += s.raw), (n.text += s.text))
|
|
1139
|
+
: t.push(s);
|
|
1140
|
+
continue;
|
|
1141
|
+
}
|
|
1142
|
+
if ((s = this.tokenizer.emStrong(e, n, i))) {
|
|
1143
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1144
|
+
continue;
|
|
1145
|
+
}
|
|
1146
|
+
if ((s = this.tokenizer.codespan(e))) {
|
|
1147
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1148
|
+
continue;
|
|
1149
|
+
}
|
|
1150
|
+
if ((s = this.tokenizer.br(e))) {
|
|
1151
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1152
|
+
continue;
|
|
1153
|
+
}
|
|
1154
|
+
if ((s = this.tokenizer.del(e))) {
|
|
1155
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
1158
|
+
if ((s = this.tokenizer.autolink(e))) {
|
|
1159
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1160
|
+
continue;
|
|
1161
|
+
}
|
|
1162
|
+
if (!this.state.inLink && (s = this.tokenizer.url(e))) {
|
|
1163
|
+
((e = e.substring(s.raw.length)), t.push(s));
|
|
1164
|
+
continue;
|
|
1165
|
+
}
|
|
1166
|
+
let l = e;
|
|
1167
|
+
if (this.options.extensions?.startInline) {
|
|
1168
|
+
let t = 1 / 0;
|
|
1169
|
+
const n = e.slice(1);
|
|
1170
|
+
let s;
|
|
1171
|
+
(this.options.extensions.startInline.forEach((e) => {
|
|
1172
|
+
((s = e.call({ lexer: this }, n)),
|
|
1173
|
+
'number' == typeof s && s >= 0 && (t = Math.min(t, s)));
|
|
1174
|
+
}),
|
|
1175
|
+
t < 1 / 0 && t >= 0 && (l = e.substring(0, t + 1)));
|
|
1176
|
+
}
|
|
1177
|
+
if ((s = this.tokenizer.inlineText(l))) {
|
|
1178
|
+
((e = e.substring(s.raw.length)),
|
|
1179
|
+
'_' !== s.raw.slice(-1) && (i = s.raw.slice(-1)),
|
|
1180
|
+
(r = !0));
|
|
1181
|
+
const n = t.at(-1);
|
|
1182
|
+
'text' === n?.type ? ((n.raw += s.raw), (n.text += s.text)) : t.push(s);
|
|
1183
|
+
} else if (e) {
|
|
1184
|
+
const t = 'Infinite loop on byte: ' + e.charCodeAt(0);
|
|
1185
|
+
if (this.options.silent) {
|
|
1186
|
+
console.error(t);
|
|
1187
|
+
break;
|
|
1188
|
+
}
|
|
1189
|
+
throw new Error(t);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
return t;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
class Y {
|
|
1196
|
+
options;
|
|
1197
|
+
parser;
|
|
1198
|
+
constructor(t) {
|
|
1199
|
+
this.options = t || e.defaults;
|
|
1200
|
+
}
|
|
1201
|
+
space(e) {
|
|
1202
|
+
return '';
|
|
1203
|
+
}
|
|
1204
|
+
code({ text: e, lang: t, escaped: n }) {
|
|
1205
|
+
const s = (t || '').match(i.notSpaceStart)?.[0],
|
|
1206
|
+
r = e.replace(i.endingNewline, '') + '\n';
|
|
1207
|
+
return s
|
|
1208
|
+
? '<pre><code class="language-' + X(s) + '">' + (n ? r : X(r, !0)) + '</code></pre>\n'
|
|
1209
|
+
: '<pre><code>' + (n ? r : X(r, !0)) + '</code></pre>\n';
|
|
1210
|
+
}
|
|
1211
|
+
blockquote({ tokens: e }) {
|
|
1212
|
+
return `<blockquote>\n${this.parser.parse(e)}</blockquote>\n`;
|
|
1213
|
+
}
|
|
1214
|
+
html({ text: e }) {
|
|
1215
|
+
return e;
|
|
1216
|
+
}
|
|
1217
|
+
heading({ tokens: e, depth: t }) {
|
|
1218
|
+
return `<h${t}>${this.parser.parseInline(e)}</h${t}>\n`;
|
|
1219
|
+
}
|
|
1220
|
+
hr(e) {
|
|
1221
|
+
return '<hr>\n';
|
|
1222
|
+
}
|
|
1223
|
+
list(e) {
|
|
1224
|
+
const t = e.ordered,
|
|
1225
|
+
n = e.start;
|
|
1226
|
+
let s = '';
|
|
1227
|
+
for (let t = 0; t < e.items.length; t++) {
|
|
1228
|
+
const n = e.items[t];
|
|
1229
|
+
s += this.listitem(n);
|
|
1230
|
+
}
|
|
1231
|
+
const r = t ? 'ol' : 'ul';
|
|
1232
|
+
return '<' + r + (t && 1 !== n ? ' start="' + n + '"' : '') + '>\n' + s + '</' + r + '>\n';
|
|
1233
|
+
}
|
|
1234
|
+
listitem(e) {
|
|
1235
|
+
let t = '';
|
|
1236
|
+
if (e.task) {
|
|
1237
|
+
const n = this.checkbox({ checked: !!e.checked });
|
|
1238
|
+
e.loose
|
|
1239
|
+
? 'paragraph' === e.tokens[0]?.type
|
|
1240
|
+
? ((e.tokens[0].text = n + ' ' + e.tokens[0].text),
|
|
1241
|
+
e.tokens[0].tokens &&
|
|
1242
|
+
e.tokens[0].tokens.length > 0 &&
|
|
1243
|
+
'text' === e.tokens[0].tokens[0].type &&
|
|
1244
|
+
((e.tokens[0].tokens[0].text = n + ' ' + X(e.tokens[0].tokens[0].text)),
|
|
1245
|
+
(e.tokens[0].tokens[0].escaped = !0)))
|
|
1246
|
+
: e.tokens.unshift({ type: 'text', raw: n + ' ', text: n + ' ', escaped: !0 })
|
|
1247
|
+
: (t += n + ' ');
|
|
1248
|
+
}
|
|
1249
|
+
return ((t += this.parser.parse(e.tokens, !!e.loose)), `<li>${t}</li>\n`);
|
|
1250
|
+
}
|
|
1251
|
+
checkbox({ checked: e }) {
|
|
1252
|
+
return '<input ' + (e ? 'checked="" ' : '') + 'disabled="" type="checkbox">';
|
|
1253
|
+
}
|
|
1254
|
+
paragraph({ tokens: e }) {
|
|
1255
|
+
return `<p>${this.parser.parseInline(e)}</p>\n`;
|
|
1256
|
+
}
|
|
1257
|
+
table(e) {
|
|
1258
|
+
let t = '',
|
|
1259
|
+
n = '';
|
|
1260
|
+
for (let t = 0; t < e.header.length; t++) n += this.tablecell(e.header[t]);
|
|
1261
|
+
t += this.tablerow({ text: n });
|
|
1262
|
+
let s = '';
|
|
1263
|
+
for (let t = 0; t < e.rows.length; t++) {
|
|
1264
|
+
const r = e.rows[t];
|
|
1265
|
+
n = '';
|
|
1266
|
+
for (let e = 0; e < r.length; e++) n += this.tablecell(r[e]);
|
|
1267
|
+
s += this.tablerow({ text: n });
|
|
1268
|
+
}
|
|
1269
|
+
return (
|
|
1270
|
+
s && (s = `<tbody>${s}</tbody>`),
|
|
1271
|
+
'<table>\n<thead>\n' + t + '</thead>\n' + s + '</table>\n'
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1274
|
+
tablerow({ text: e }) {
|
|
1275
|
+
return `<tr>\n${e}</tr>\n`;
|
|
1276
|
+
}
|
|
1277
|
+
tablecell(e) {
|
|
1278
|
+
const t = this.parser.parseInline(e.tokens),
|
|
1279
|
+
n = e.header ? 'th' : 'td';
|
|
1280
|
+
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>\n`;
|
|
1281
|
+
}
|
|
1282
|
+
strong({ tokens: e }) {
|
|
1283
|
+
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
1284
|
+
}
|
|
1285
|
+
em({ tokens: e }) {
|
|
1286
|
+
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
1287
|
+
}
|
|
1288
|
+
codespan({ text: e }) {
|
|
1289
|
+
return `<code>${X(e, !0)}</code>`;
|
|
1290
|
+
}
|
|
1291
|
+
br(e) {
|
|
1292
|
+
return '<br>';
|
|
1293
|
+
}
|
|
1294
|
+
del({ tokens: e }) {
|
|
1295
|
+
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
1296
|
+
}
|
|
1297
|
+
link({ href: e, title: t, tokens: n }) {
|
|
1298
|
+
const s = this.parser.parseInline(n),
|
|
1299
|
+
r = F(e);
|
|
1300
|
+
if (null === r) return s;
|
|
1301
|
+
let i = '<a href="' + (e = r) + '"';
|
|
1302
|
+
return (t && (i += ' title="' + X(t) + '"'), (i += '>' + s + '</a>'), i);
|
|
1303
|
+
}
|
|
1304
|
+
image({ href: e, title: t, text: n }) {
|
|
1305
|
+
const s = F(e);
|
|
1306
|
+
if (null === s) return X(n);
|
|
1307
|
+
let r = `<img src="${(e = s)}" alt="${n}"`;
|
|
1308
|
+
return (t && (r += ` title="${X(t)}"`), (r += '>'), r);
|
|
1309
|
+
}
|
|
1310
|
+
text(e) {
|
|
1311
|
+
return 'tokens' in e && e.tokens
|
|
1312
|
+
? this.parser.parseInline(e.tokens)
|
|
1313
|
+
: 'escaped' in e && e.escaped
|
|
1314
|
+
? e.text
|
|
1315
|
+
: X(e.text);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
class ee {
|
|
1319
|
+
strong({ text: e }) {
|
|
1320
|
+
return e;
|
|
1321
|
+
}
|
|
1322
|
+
em({ text: e }) {
|
|
1323
|
+
return e;
|
|
1324
|
+
}
|
|
1325
|
+
codespan({ text: e }) {
|
|
1326
|
+
return e;
|
|
1327
|
+
}
|
|
1328
|
+
del({ text: e }) {
|
|
1329
|
+
return e;
|
|
1330
|
+
}
|
|
1331
|
+
html({ text: e }) {
|
|
1332
|
+
return e;
|
|
1333
|
+
}
|
|
1334
|
+
text({ text: e }) {
|
|
1335
|
+
return e;
|
|
1336
|
+
}
|
|
1337
|
+
link({ text: e }) {
|
|
1338
|
+
return '' + e;
|
|
1339
|
+
}
|
|
1340
|
+
image({ text: e }) {
|
|
1341
|
+
return '' + e;
|
|
1342
|
+
}
|
|
1343
|
+
br() {
|
|
1344
|
+
return '';
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
class te {
|
|
1348
|
+
options;
|
|
1349
|
+
renderer;
|
|
1350
|
+
textRenderer;
|
|
1351
|
+
constructor(t) {
|
|
1352
|
+
((this.options = t || e.defaults),
|
|
1353
|
+
(this.options.renderer = this.options.renderer || new Y()),
|
|
1354
|
+
(this.renderer = this.options.renderer),
|
|
1355
|
+
(this.renderer.options = this.options),
|
|
1356
|
+
(this.renderer.parser = this),
|
|
1357
|
+
(this.textRenderer = new ee()));
|
|
1358
|
+
}
|
|
1359
|
+
static parse(e, t) {
|
|
1360
|
+
return new te(t).parse(e);
|
|
1361
|
+
}
|
|
1362
|
+
static parseInline(e, t) {
|
|
1363
|
+
return new te(t).parseInline(e);
|
|
1364
|
+
}
|
|
1365
|
+
parse(e, t = !0) {
|
|
1366
|
+
let n = '';
|
|
1367
|
+
for (let s = 0; s < e.length; s++) {
|
|
1368
|
+
const r = e[s];
|
|
1369
|
+
if (this.options.extensions?.renderers?.[r.type]) {
|
|
1370
|
+
const e = r,
|
|
1371
|
+
t = this.options.extensions.renderers[e.type].call({ parser: this }, e);
|
|
1372
|
+
if (
|
|
1373
|
+
!1 !== t ||
|
|
1374
|
+
![
|
|
1375
|
+
'space',
|
|
1376
|
+
'hr',
|
|
1377
|
+
'heading',
|
|
1378
|
+
'code',
|
|
1379
|
+
'table',
|
|
1380
|
+
'blockquote',
|
|
1381
|
+
'list',
|
|
1382
|
+
'html',
|
|
1383
|
+
'paragraph',
|
|
1384
|
+
'text'
|
|
1385
|
+
].includes(e.type)
|
|
1386
|
+
) {
|
|
1387
|
+
n += t || '';
|
|
1388
|
+
continue;
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
const i = r;
|
|
1392
|
+
switch (i.type) {
|
|
1393
|
+
case 'space':
|
|
1394
|
+
n += this.renderer.space(i);
|
|
1395
|
+
continue;
|
|
1396
|
+
case 'hr':
|
|
1397
|
+
n += this.renderer.hr(i);
|
|
1398
|
+
continue;
|
|
1399
|
+
case 'heading':
|
|
1400
|
+
n += this.renderer.heading(i);
|
|
1401
|
+
continue;
|
|
1402
|
+
case 'code':
|
|
1403
|
+
n += this.renderer.code(i);
|
|
1404
|
+
continue;
|
|
1405
|
+
case 'table':
|
|
1406
|
+
n += this.renderer.table(i);
|
|
1407
|
+
continue;
|
|
1408
|
+
case 'blockquote':
|
|
1409
|
+
n += this.renderer.blockquote(i);
|
|
1410
|
+
continue;
|
|
1411
|
+
case 'list':
|
|
1412
|
+
n += this.renderer.list(i);
|
|
1413
|
+
continue;
|
|
1414
|
+
case 'html':
|
|
1415
|
+
n += this.renderer.html(i);
|
|
1416
|
+
continue;
|
|
1417
|
+
case 'paragraph':
|
|
1418
|
+
n += this.renderer.paragraph(i);
|
|
1419
|
+
continue;
|
|
1420
|
+
case 'text': {
|
|
1421
|
+
let r = i,
|
|
1422
|
+
l = this.renderer.text(r);
|
|
1423
|
+
for (; s + 1 < e.length && 'text' === e[s + 1].type; )
|
|
1424
|
+
((r = e[++s]), (l += '\n' + this.renderer.text(r)));
|
|
1425
|
+
n += t
|
|
1426
|
+
? this.renderer.paragraph({
|
|
1427
|
+
type: 'paragraph',
|
|
1428
|
+
raw: l,
|
|
1429
|
+
text: l,
|
|
1430
|
+
tokens: [{ type: 'text', raw: l, text: l, escaped: !0 }]
|
|
1431
|
+
})
|
|
1432
|
+
: l;
|
|
1433
|
+
continue;
|
|
1434
|
+
}
|
|
1435
|
+
default: {
|
|
1436
|
+
const e = 'Token with "' + i.type + '" type was not found.';
|
|
1437
|
+
if (this.options.silent) return (console.error(e), '');
|
|
1438
|
+
throw new Error(e);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
return n;
|
|
1443
|
+
}
|
|
1444
|
+
parseInline(e, t = this.renderer) {
|
|
1445
|
+
let n = '';
|
|
1446
|
+
for (let s = 0; s < e.length; s++) {
|
|
1447
|
+
const r = e[s];
|
|
1448
|
+
if (this.options.extensions?.renderers?.[r.type]) {
|
|
1449
|
+
const e = this.options.extensions.renderers[r.type].call({ parser: this }, r);
|
|
1450
|
+
if (
|
|
1451
|
+
!1 !== e ||
|
|
1452
|
+
![
|
|
1453
|
+
'escape',
|
|
1454
|
+
'html',
|
|
1455
|
+
'link',
|
|
1456
|
+
'image',
|
|
1457
|
+
'strong',
|
|
1458
|
+
'em',
|
|
1459
|
+
'codespan',
|
|
1460
|
+
'br',
|
|
1461
|
+
'del',
|
|
1462
|
+
'text'
|
|
1463
|
+
].includes(r.type)
|
|
1464
|
+
) {
|
|
1465
|
+
n += e || '';
|
|
1466
|
+
continue;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
const i = r;
|
|
1470
|
+
switch (i.type) {
|
|
1471
|
+
case 'escape':
|
|
1472
|
+
case 'text':
|
|
1473
|
+
n += t.text(i);
|
|
1474
|
+
break;
|
|
1475
|
+
case 'html':
|
|
1476
|
+
n += t.html(i);
|
|
1477
|
+
break;
|
|
1478
|
+
case 'link':
|
|
1479
|
+
n += t.link(i);
|
|
1480
|
+
break;
|
|
1481
|
+
case 'image':
|
|
1482
|
+
n += t.image(i);
|
|
1483
|
+
break;
|
|
1484
|
+
case 'strong':
|
|
1485
|
+
n += t.strong(i);
|
|
1486
|
+
break;
|
|
1487
|
+
case 'em':
|
|
1488
|
+
n += t.em(i);
|
|
1489
|
+
break;
|
|
1490
|
+
case 'codespan':
|
|
1491
|
+
n += t.codespan(i);
|
|
1492
|
+
break;
|
|
1493
|
+
case 'br':
|
|
1494
|
+
n += t.br(i);
|
|
1495
|
+
break;
|
|
1496
|
+
case 'del':
|
|
1497
|
+
n += t.del(i);
|
|
1498
|
+
break;
|
|
1499
|
+
default: {
|
|
1500
|
+
const e = 'Token with "' + i.type + '" type was not found.';
|
|
1501
|
+
if (this.options.silent) return (console.error(e), '');
|
|
1502
|
+
throw new Error(e);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
return n;
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
class ne {
|
|
1510
|
+
options;
|
|
1511
|
+
block;
|
|
1512
|
+
constructor(t) {
|
|
1513
|
+
this.options = t || e.defaults;
|
|
1514
|
+
}
|
|
1515
|
+
static passThroughHooks = new Set(['preprocess', 'postprocess', 'processAllTokens']);
|
|
1516
|
+
preprocess(e) {
|
|
1517
|
+
return e;
|
|
1518
|
+
}
|
|
1519
|
+
postprocess(e) {
|
|
1520
|
+
return e;
|
|
1521
|
+
}
|
|
1522
|
+
processAllTokens(e) {
|
|
1523
|
+
return e;
|
|
1524
|
+
}
|
|
1525
|
+
provideLexer() {
|
|
1526
|
+
return this.block ? W.lex : W.lexInline;
|
|
1527
|
+
}
|
|
1528
|
+
provideParser() {
|
|
1529
|
+
return this.block ? te.parse : te.parseInline;
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
class se {
|
|
1533
|
+
defaults = {
|
|
1534
|
+
async: !1,
|
|
1535
|
+
breaks: !1,
|
|
1536
|
+
extensions: null,
|
|
1537
|
+
gfm: !0,
|
|
1538
|
+
hooks: null,
|
|
1539
|
+
pedantic: !1,
|
|
1540
|
+
renderer: null,
|
|
1541
|
+
silent: !1,
|
|
1542
|
+
tokenizer: null,
|
|
1543
|
+
walkTokens: null
|
|
1544
|
+
};
|
|
1545
|
+
options = this.setOptions;
|
|
1546
|
+
parse = this.parseMarkdown(!0);
|
|
1547
|
+
parseInline = this.parseMarkdown(!1);
|
|
1548
|
+
Parser = te;
|
|
1549
|
+
Renderer = Y;
|
|
1550
|
+
TextRenderer = ee;
|
|
1551
|
+
Lexer = W;
|
|
1552
|
+
Tokenizer = V;
|
|
1553
|
+
Hooks = ne;
|
|
1554
|
+
constructor(...e) {
|
|
1555
|
+
this.use(...e);
|
|
1556
|
+
}
|
|
1557
|
+
walkTokens(e, t) {
|
|
1558
|
+
let n = [];
|
|
1559
|
+
for (const s of e)
|
|
1560
|
+
switch (((n = n.concat(t.call(this, s))), s.type)) {
|
|
1561
|
+
case 'table': {
|
|
1562
|
+
const e = s;
|
|
1563
|
+
for (const s of e.header) n = n.concat(this.walkTokens(s.tokens, t));
|
|
1564
|
+
for (const s of e.rows) for (const e of s) n = n.concat(this.walkTokens(e.tokens, t));
|
|
1565
|
+
break;
|
|
1566
|
+
}
|
|
1567
|
+
case 'list': {
|
|
1568
|
+
const e = s;
|
|
1569
|
+
n = n.concat(this.walkTokens(e.items, t));
|
|
1570
|
+
break;
|
|
1571
|
+
}
|
|
1572
|
+
default: {
|
|
1573
|
+
const e = s;
|
|
1574
|
+
this.defaults.extensions?.childTokens?.[e.type]
|
|
1575
|
+
? this.defaults.extensions.childTokens[e.type].forEach((s) => {
|
|
1576
|
+
const r = e[s].flat(1 / 0);
|
|
1577
|
+
n = n.concat(this.walkTokens(r, t));
|
|
1578
|
+
})
|
|
1579
|
+
: e.tokens && (n = n.concat(this.walkTokens(e.tokens, t)));
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
return n;
|
|
1583
|
+
}
|
|
1584
|
+
use(...e) {
|
|
1585
|
+
const t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
1586
|
+
return (
|
|
1587
|
+
e.forEach((e) => {
|
|
1588
|
+
const n = { ...e };
|
|
1589
|
+
if (
|
|
1590
|
+
((n.async = this.defaults.async || n.async || !1),
|
|
1591
|
+
e.extensions &&
|
|
1592
|
+
(e.extensions.forEach((e) => {
|
|
1593
|
+
if (!e.name) throw new Error('extension name required');
|
|
1594
|
+
if ('renderer' in e) {
|
|
1595
|
+
const n = t.renderers[e.name];
|
|
1596
|
+
t.renderers[e.name] = n
|
|
1597
|
+
? function (...t) {
|
|
1598
|
+
let s = e.renderer.apply(this, t);
|
|
1599
|
+
return (!1 === s && (s = n.apply(this, t)), s);
|
|
1600
|
+
}
|
|
1601
|
+
: e.renderer;
|
|
1602
|
+
}
|
|
1603
|
+
if ('tokenizer' in e) {
|
|
1604
|
+
if (!e.level || ('block' !== e.level && 'inline' !== e.level))
|
|
1605
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
1606
|
+
const n = t[e.level];
|
|
1607
|
+
(n ? n.unshift(e.tokenizer) : (t[e.level] = [e.tokenizer]),
|
|
1608
|
+
e.start &&
|
|
1609
|
+
('block' === e.level
|
|
1610
|
+
? t.startBlock
|
|
1611
|
+
? t.startBlock.push(e.start)
|
|
1612
|
+
: (t.startBlock = [e.start])
|
|
1613
|
+
: 'inline' === e.level &&
|
|
1614
|
+
(t.startInline
|
|
1615
|
+
? t.startInline.push(e.start)
|
|
1616
|
+
: (t.startInline = [e.start]))));
|
|
1617
|
+
}
|
|
1618
|
+
'childTokens' in e && e.childTokens && (t.childTokens[e.name] = e.childTokens);
|
|
1619
|
+
}),
|
|
1620
|
+
(n.extensions = t)),
|
|
1621
|
+
e.renderer)
|
|
1622
|
+
) {
|
|
1623
|
+
const t = this.defaults.renderer || new Y(this.defaults);
|
|
1624
|
+
for (const n in e.renderer) {
|
|
1625
|
+
if (!(n in t)) throw new Error(`renderer '${n}' does not exist`);
|
|
1626
|
+
if (['options', 'parser'].includes(n)) continue;
|
|
1627
|
+
const s = n,
|
|
1628
|
+
r = e.renderer[s],
|
|
1629
|
+
i = t[s];
|
|
1630
|
+
t[s] = (...e) => {
|
|
1631
|
+
let n = r.apply(t, e);
|
|
1632
|
+
return (!1 === n && (n = i.apply(t, e)), n || '');
|
|
1633
|
+
};
|
|
1634
|
+
}
|
|
1635
|
+
n.renderer = t;
|
|
1636
|
+
}
|
|
1637
|
+
if (e.tokenizer) {
|
|
1638
|
+
const t = this.defaults.tokenizer || new V(this.defaults);
|
|
1639
|
+
for (const n in e.tokenizer) {
|
|
1640
|
+
if (!(n in t)) throw new Error(`tokenizer '${n}' does not exist`);
|
|
1641
|
+
if (['options', 'rules', 'lexer'].includes(n)) continue;
|
|
1642
|
+
const s = n,
|
|
1643
|
+
r = e.tokenizer[s],
|
|
1644
|
+
i = t[s];
|
|
1645
|
+
t[s] = (...e) => {
|
|
1646
|
+
let n = r.apply(t, e);
|
|
1647
|
+
return (!1 === n && (n = i.apply(t, e)), n);
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
n.tokenizer = t;
|
|
1651
|
+
}
|
|
1652
|
+
if (e.hooks) {
|
|
1653
|
+
const t = this.defaults.hooks || new ne();
|
|
1654
|
+
for (const n in e.hooks) {
|
|
1655
|
+
if (!(n in t)) throw new Error(`hook '${n}' does not exist`);
|
|
1656
|
+
if (['options', 'block'].includes(n)) continue;
|
|
1657
|
+
const s = n,
|
|
1658
|
+
r = e.hooks[s],
|
|
1659
|
+
i = t[s];
|
|
1660
|
+
ne.passThroughHooks.has(n)
|
|
1661
|
+
? (t[s] = (e) => {
|
|
1662
|
+
if (this.defaults.async)
|
|
1663
|
+
return Promise.resolve(r.call(t, e)).then((e) => i.call(t, e));
|
|
1664
|
+
const n = r.call(t, e);
|
|
1665
|
+
return i.call(t, n);
|
|
1666
|
+
})
|
|
1667
|
+
: (t[s] = (...e) => {
|
|
1668
|
+
let n = r.apply(t, e);
|
|
1669
|
+
return (!1 === n && (n = i.apply(t, e)), n);
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
n.hooks = t;
|
|
1673
|
+
}
|
|
1674
|
+
if (e.walkTokens) {
|
|
1675
|
+
const t = this.defaults.walkTokens,
|
|
1676
|
+
s = e.walkTokens;
|
|
1677
|
+
n.walkTokens = function (e) {
|
|
1678
|
+
let n = [];
|
|
1679
|
+
return (n.push(s.call(this, e)), t && (n = n.concat(t.call(this, e))), n);
|
|
1680
|
+
};
|
|
1681
|
+
}
|
|
1682
|
+
this.defaults = { ...this.defaults, ...n };
|
|
1683
|
+
}),
|
|
1684
|
+
this
|
|
1685
|
+
);
|
|
1686
|
+
}
|
|
1687
|
+
setOptions(e) {
|
|
1688
|
+
return ((this.defaults = { ...this.defaults, ...e }), this);
|
|
1689
|
+
}
|
|
1690
|
+
lexer(e, t) {
|
|
1691
|
+
return W.lex(e, t ?? this.defaults);
|
|
1692
|
+
}
|
|
1693
|
+
parser(e, t) {
|
|
1694
|
+
return te.parse(e, t ?? this.defaults);
|
|
1695
|
+
}
|
|
1696
|
+
parseMarkdown(e) {
|
|
1697
|
+
return (t, n) => {
|
|
1698
|
+
const s = { ...n },
|
|
1699
|
+
r = { ...this.defaults, ...s },
|
|
1700
|
+
i = this.onError(!!r.silent, !!r.async);
|
|
1701
|
+
if (!0 === this.defaults.async && !1 === s.async)
|
|
1702
|
+
return i(
|
|
1703
|
+
new Error(
|
|
1704
|
+
'marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.'
|
|
1705
|
+
)
|
|
1706
|
+
);
|
|
1707
|
+
if (null == t) return i(new Error('marked(): input parameter is undefined or null'));
|
|
1708
|
+
if ('string' != typeof t)
|
|
1709
|
+
return i(
|
|
1710
|
+
new Error(
|
|
1711
|
+
'marked(): input parameter is of type ' +
|
|
1712
|
+
Object.prototype.toString.call(t) +
|
|
1713
|
+
', string expected'
|
|
1714
|
+
)
|
|
1715
|
+
);
|
|
1716
|
+
r.hooks && ((r.hooks.options = r), (r.hooks.block = e));
|
|
1717
|
+
const l = r.hooks ? r.hooks.provideLexer() : e ? W.lex : W.lexInline,
|
|
1718
|
+
o = r.hooks ? r.hooks.provideParser() : e ? te.parse : te.parseInline;
|
|
1719
|
+
if (r.async)
|
|
1720
|
+
return Promise.resolve(r.hooks ? r.hooks.preprocess(t) : t)
|
|
1721
|
+
.then((e) => l(e, r))
|
|
1722
|
+
.then((e) => (r.hooks ? r.hooks.processAllTokens(e) : e))
|
|
1723
|
+
.then((e) =>
|
|
1724
|
+
r.walkTokens ? Promise.all(this.walkTokens(e, r.walkTokens)).then(() => e) : e
|
|
1725
|
+
)
|
|
1726
|
+
.then((e) => o(e, r))
|
|
1727
|
+
.then((e) => (r.hooks ? r.hooks.postprocess(e) : e))
|
|
1728
|
+
.catch(i);
|
|
1729
|
+
try {
|
|
1730
|
+
r.hooks && (t = r.hooks.preprocess(t));
|
|
1731
|
+
let e = l(t, r);
|
|
1732
|
+
(r.hooks && (e = r.hooks.processAllTokens(e)),
|
|
1733
|
+
r.walkTokens && this.walkTokens(e, r.walkTokens));
|
|
1734
|
+
let n = o(e, r);
|
|
1735
|
+
return (r.hooks && (n = r.hooks.postprocess(n)), n);
|
|
1736
|
+
} catch (e) {
|
|
1737
|
+
return i(e);
|
|
1738
|
+
}
|
|
1739
|
+
};
|
|
1740
|
+
}
|
|
1741
|
+
onError(e, t) {
|
|
1742
|
+
return (n) => {
|
|
1743
|
+
if (((n.message += '\nPlease report this to https://github.com/markedjs/marked.'), e)) {
|
|
1744
|
+
const e = '<p>An error occurred:</p><pre>' + X(n.message + '', !0) + '</pre>';
|
|
1745
|
+
return t ? Promise.resolve(e) : e;
|
|
1746
|
+
}
|
|
1747
|
+
if (t) return Promise.reject(n);
|
|
1748
|
+
throw n;
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
const re = new se();
|
|
1753
|
+
function ie(e, t) {
|
|
1754
|
+
return re.parse(e, t);
|
|
1755
|
+
}
|
|
1756
|
+
((ie.options = ie.setOptions =
|
|
1757
|
+
function (e) {
|
|
1758
|
+
return (re.setOptions(e), (ie.defaults = re.defaults), n(ie.defaults), ie);
|
|
1759
|
+
}),
|
|
1760
|
+
(ie.getDefaults = t),
|
|
1761
|
+
(ie.defaults = e.defaults),
|
|
1762
|
+
(ie.use = function (...e) {
|
|
1763
|
+
return (re.use(...e), (ie.defaults = re.defaults), n(ie.defaults), ie);
|
|
1764
|
+
}),
|
|
1765
|
+
(ie.walkTokens = function (e, t) {
|
|
1766
|
+
return re.walkTokens(e, t);
|
|
1767
|
+
}),
|
|
1768
|
+
(ie.parseInline = re.parseInline),
|
|
1769
|
+
(ie.Parser = te),
|
|
1770
|
+
(ie.parser = te.parse),
|
|
1771
|
+
(ie.Renderer = Y),
|
|
1772
|
+
(ie.TextRenderer = ee),
|
|
1773
|
+
(ie.Lexer = W),
|
|
1774
|
+
(ie.lexer = W.lex),
|
|
1775
|
+
(ie.Tokenizer = V),
|
|
1776
|
+
(ie.Hooks = ne),
|
|
1777
|
+
(ie.parse = ie));
|
|
1778
|
+
const le = ie.options,
|
|
1779
|
+
oe = ie.setOptions,
|
|
1780
|
+
ae = ie.use,
|
|
1781
|
+
ce = ie.walkTokens,
|
|
1782
|
+
he = ie.parseInline,
|
|
1783
|
+
pe = ie,
|
|
1784
|
+
ue = te.parse,
|
|
1785
|
+
ge = W.lex;
|
|
1786
|
+
((e.Hooks = ne),
|
|
1787
|
+
(e.Lexer = W),
|
|
1788
|
+
(e.Marked = se),
|
|
1789
|
+
(e.Parser = te),
|
|
1790
|
+
(e.Renderer = Y),
|
|
1791
|
+
(e.TextRenderer = ee),
|
|
1792
|
+
(e.Tokenizer = V),
|
|
1793
|
+
(e.getDefaults = t),
|
|
1794
|
+
(e.lexer = ge),
|
|
1795
|
+
(e.marked = ie),
|
|
1796
|
+
(e.options = le),
|
|
1797
|
+
(e.parse = pe),
|
|
1798
|
+
(e.parseInline = he),
|
|
1799
|
+
(e.parser = ue),
|
|
1800
|
+
(e.setOptions = oe),
|
|
1801
|
+
(e.use = ae),
|
|
1802
|
+
(e.walkTokens = ce));
|
|
1803
|
+
});
|