@dst0/p-tui 0.4.41 → 5.0.2
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/dist/autocomplete.d.ts.map +1 -1
- package/dist/autocomplete.js.map +1 -1
- package/dist/components/box.d.ts +3 -1
- package/dist/components/box.d.ts.map +1 -1
- package/dist/components/box.js +19 -10
- package/dist/components/box.js.map +1 -1
- package/dist/components/cancellable-loader.d.ts.map +1 -1
- package/dist/components/cancellable-loader.js.map +1 -1
- package/dist/components/editor/constants.d.ts +9 -0
- package/dist/components/editor/constants.d.ts.map +1 -0
- package/dist/components/editor/constants.js +12 -0
- package/dist/components/editor/constants.js.map +1 -0
- package/dist/components/editor/editor-methods/autocomplete-matching.d.ts +29 -0
- package/dist/components/editor/editor-methods/autocomplete-matching.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/autocomplete-matching.js +104 -0
- package/dist/components/editor/editor-methods/autocomplete-matching.js.map +1 -0
- package/dist/components/editor/editor-methods/autocomplete-request.d.ts +14 -0
- package/dist/components/editor/editor-methods/autocomplete-request.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/autocomplete-request.js +72 -0
- package/dist/components/editor/editor-methods/autocomplete-request.js.map +1 -0
- package/dist/components/editor/editor-methods/backspace-cursor.d.ts +9 -0
- package/dist/components/editor/editor-methods/backspace-cursor.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/backspace-cursor.js +122 -0
- package/dist/components/editor/editor-methods/backspace-cursor.js.map +1 -0
- package/dist/components/editor/editor-methods/configuration.d.ts +17 -0
- package/dist/components/editor/editor-methods/configuration.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/configuration.js +107 -0
- package/dist/components/editor/editor-methods/configuration.js.map +1 -0
- package/dist/components/editor/editor-methods/cursor-movement.d.ts +7 -0
- package/dist/components/editor/editor-methods/cursor-movement.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/cursor-movement.js +112 -0
- package/dist/components/editor/editor-methods/cursor-movement.js.map +1 -0
- package/dist/components/editor/editor-methods/input-handling.d.ts +3 -0
- package/dist/components/editor/editor-methods/input-handling.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/input-handling.js +257 -0
- package/dist/components/editor/editor-methods/input-handling.js.map +1 -0
- package/dist/components/editor/editor-methods/paste-submit.d.ts +7 -0
- package/dist/components/editor/editor-methods/paste-submit.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/paste-submit.js +105 -0
- package/dist/components/editor/editor-methods/paste-submit.js.map +1 -0
- package/dist/components/editor/editor-methods/render.d.ts +3 -0
- package/dist/components/editor/editor-methods/render.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/render.js +114 -0
- package/dist/components/editor/editor-methods/render.js.map +1 -0
- package/dist/components/editor/editor-methods/text-insertion.d.ts +4 -0
- package/dist/components/editor/editor-methods/text-insertion.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/text-insertion.js +91 -0
- package/dist/components/editor/editor-methods/text-insertion.js.map +1 -0
- package/dist/components/editor/editor-methods/text-layout.d.ts +15 -0
- package/dist/components/editor/editor-methods/text-layout.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/text-layout.js +129 -0
- package/dist/components/editor/editor-methods/text-layout.js.map +1 -0
- package/dist/components/editor/editor-methods/vertical-movement.d.ts +8 -0
- package/dist/components/editor/editor-methods/vertical-movement.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/vertical-movement.js +123 -0
- package/dist/components/editor/editor-methods/vertical-movement.js.map +1 -0
- package/dist/components/editor/editor-methods/word-operations.d.ts +19 -0
- package/dist/components/editor/editor-methods/word-operations.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/word-operations.js +122 -0
- package/dist/components/editor/editor-methods/word-operations.js.map +1 -0
- package/dist/components/editor/editor-methods/yank-undo.d.ts +11 -0
- package/dist/components/editor/editor-methods/yank-undo.d.ts.map +1 -0
- package/dist/components/editor/editor-methods/yank-undo.js +132 -0
- package/dist/components/editor/editor-methods/yank-undo.js.map +1 -0
- package/dist/components/editor/editor.d.ts +67 -0
- package/dist/components/editor/editor.d.ts.map +1 -0
- package/dist/components/editor/editor.js +93 -0
- package/dist/components/editor/editor.js.map +1 -0
- package/dist/components/editor/helpers.d.ts +3 -0
- package/dist/components/editor/helpers.d.ts.map +1 -0
- package/dist/components/editor/helpers.js +3 -0
- package/dist/components/editor/helpers.js.map +1 -0
- package/dist/components/editor/index.d.ts +4 -0
- package/dist/components/editor/index.d.ts.map +1 -0
- package/dist/components/editor/index.js +3 -0
- package/dist/components/editor/index.js.map +1 -0
- package/dist/components/editor/paste-marker.d.ts +5 -0
- package/dist/components/editor/paste-marker.d.ts.map +1 -0
- package/dist/components/editor/paste-marker.js +134 -0
- package/dist/components/editor/paste-marker.js.map +1 -0
- package/dist/components/editor/trigger-patterns.d.ts +4 -0
- package/dist/components/editor/trigger-patterns.d.ts.map +1 -0
- package/dist/components/editor/trigger-patterns.js +11 -0
- package/dist/components/editor/trigger-patterns.js.map +1 -0
- package/dist/components/editor/types.d.ts +25 -0
- package/dist/components/editor/types.d.ts.map +1 -0
- package/dist/components/editor/types.js +2 -0
- package/dist/components/editor/types.js.map +1 -0
- package/dist/components/editor.d.ts +1 -253
- package/dist/components/editor.d.ts.map +1 -1
- package/dist/components/editor.js +1 -1915
- package/dist/components/editor.js.map +1 -1
- package/dist/components/image.d.ts.map +1 -1
- package/dist/components/image.js.map +1 -1
- package/dist/components/input/constants.d.ts +2 -0
- package/dist/components/input/constants.d.ts.map +1 -0
- package/dist/components/input/constants.js +3 -0
- package/dist/components/input/constants.js.map +1 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/index.d.ts.map +1 -0
- package/dist/components/input/index.js +2 -0
- package/dist/components/input/index.js.map +1 -0
- package/dist/components/input/input-methods/input-handling.d.ts +3 -0
- package/dist/components/input/input-methods/input-handling.d.ts.map +1 -0
- package/dist/components/input/input-methods/input-handling.js +145 -0
- package/dist/components/input/input-methods/input-handling.js.map +1 -0
- package/dist/components/input/input-methods/render.d.ts +3 -0
- package/dist/components/input/input-methods/render.d.ts.map +1 -0
- package/dist/components/input/input-methods/render.js +62 -0
- package/dist/components/input/input-methods/render.js.map +1 -0
- package/dist/components/input/input-methods/text-editing.d.ts +17 -0
- package/dist/components/input/input-methods/text-editing.d.ts.map +1 -0
- package/dist/components/input/input-methods/text-editing.js +145 -0
- package/dist/components/input/input-methods/text-editing.js.map +1 -0
- package/dist/components/input/input-methods/value-access.d.ts +4 -0
- package/dist/components/input/input-methods/value-access.d.ts.map +1 -0
- package/dist/components/input/input-methods/value-access.js +20 -0
- package/dist/components/input/input-methods/value-access.js.map +1 -0
- package/dist/components/input/input.d.ts +37 -0
- package/dist/components/input/input.d.ts.map +1 -0
- package/dist/components/input/input.js +77 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/input/types.d.ts +5 -0
- package/dist/components/input/types.d.ts.map +1 -0
- package/dist/components/input/types.js +2 -0
- package/dist/components/input/types.js.map +1 -0
- package/dist/components/input.d.ts +1 -36
- package/dist/components/input.d.ts.map +1 -1
- package/dist/components/input.js +1 -377
- package/dist/components/input.js.map +1 -1
- package/dist/components/loader.d.ts.map +1 -1
- package/dist/components/loader.js.map +1 -1
- package/dist/components/markdown/constants.d.ts +4 -0
- package/dist/components/markdown/constants.d.ts.map +1 -0
- package/dist/components/markdown/constants.js +8 -0
- package/dist/components/markdown/constants.js.map +1 -0
- package/dist/components/markdown/index.d.ts +3 -0
- package/dist/components/markdown/index.d.ts.map +1 -0
- package/dist/components/markdown/index.js +2 -0
- package/dist/components/markdown/index.js.map +1 -0
- package/dist/components/markdown/markdown-methods/inline-rendering.d.ts +7 -0
- package/dist/components/markdown/markdown-methods/inline-rendering.d.ts.map +1 -0
- package/dist/components/markdown/markdown-methods/inline-rendering.js +95 -0
- package/dist/components/markdown/markdown-methods/inline-rendering.js.map +1 -0
- package/dist/components/markdown/markdown-methods/list-table-helpers.d.ts +7 -0
- package/dist/components/markdown/markdown-methods/list-table-helpers.d.ts.map +1 -0
- package/dist/components/markdown/markdown-methods/list-table-helpers.js +61 -0
- package/dist/components/markdown/markdown-methods/list-table-helpers.js.map +1 -0
- package/dist/components/markdown/markdown-methods/table-rendering.d.ts +5 -0
- package/dist/components/markdown/markdown-methods/table-rendering.d.ts.map +1 -0
- package/dist/components/markdown/markdown-methods/table-rendering.js +146 -0
- package/dist/components/markdown/markdown-methods/table-rendering.js.map +1 -0
- package/dist/components/markdown/markdown-methods/text-rendering.d.ts +6 -0
- package/dist/components/markdown/markdown-methods/text-rendering.d.ts.map +1 -0
- package/dist/components/markdown/markdown-methods/text-rendering.js +115 -0
- package/dist/components/markdown/markdown-methods/text-rendering.js.map +1 -0
- package/dist/components/markdown/markdown-methods/theming.d.ts +6 -0
- package/dist/components/markdown/markdown-methods/theming.d.ts.map +1 -0
- package/dist/components/markdown/markdown-methods/theming.js +41 -0
- package/dist/components/markdown/markdown-methods/theming.js.map +1 -0
- package/dist/components/markdown/markdown-methods/token-rendering.d.ts +5 -0
- package/dist/components/markdown/markdown-methods/token-rendering.d.ts.map +1 -0
- package/dist/components/markdown/markdown-methods/token-rendering.js +142 -0
- package/dist/components/markdown/markdown-methods/token-rendering.js.map +1 -0
- package/dist/components/markdown/markdown.d.ts +32 -0
- package/dist/components/markdown/markdown.d.ts.map +1 -0
- package/dist/components/markdown/markdown.js +72 -0
- package/dist/components/markdown/markdown.js.map +1 -0
- package/dist/components/markdown/strictstrikethroughtokenizer.d.ts +6 -0
- package/dist/components/markdown/strictstrikethroughtokenizer.d.ts.map +1 -0
- package/dist/components/markdown/strictstrikethroughtokenizer.js +18 -0
- package/dist/components/markdown/strictstrikethroughtokenizer.js.map +1 -0
- package/dist/components/markdown/types.d.ts +42 -0
- package/dist/components/markdown/types.d.ts.map +1 -0
- package/dist/components/markdown/types.js +2 -0
- package/dist/components/markdown/types.js.map +1 -0
- package/dist/components/markdown.d.ts +1 -96
- package/dist/components/markdown.d.ts.map +1 -1
- package/dist/components/markdown.js +1 -653
- package/dist/components/markdown.js.map +1 -1
- package/dist/components/select-list.d.ts.map +1 -1
- package/dist/components/select-list.js +8 -3
- package/dist/components/select-list.js.map +1 -1
- package/dist/components/settings-list.d.ts.map +1 -1
- package/dist/components/settings-list.js +2 -6
- package/dist/components/settings-list.js.map +1 -1
- package/dist/components/spacer.d.ts.map +1 -1
- package/dist/components/spacer.js.map +1 -1
- package/dist/components/text.d.ts.map +1 -1
- package/dist/components/text.js +2 -2
- package/dist/components/text.js.map +1 -1
- package/dist/components/truncated-text.d.ts.map +1 -1
- package/dist/components/truncated-text.js.map +1 -1
- package/dist/editor-component.d.ts.map +1 -1
- package/dist/editor-component.js.map +1 -1
- package/dist/fuzzy.d.ts.map +1 -1
- package/dist/fuzzy.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/keybindings.d.ts.map +1 -1
- package/dist/keybindings.js.map +1 -1
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +145 -14
- package/dist/keys.js.map +1 -1
- package/dist/kill-ring.d.ts.map +1 -1
- package/dist/kill-ring.js.map +1 -1
- package/dist/native-modifiers.d.ts +9 -0
- package/dist/native-modifiers.d.ts.map +1 -1
- package/dist/native-modifiers.js +5 -0
- package/dist/native-modifiers.js.map +1 -1
- package/dist/stdin-buffer.d.ts +3 -0
- package/dist/stdin-buffer.d.ts.map +1 -1
- package/dist/stdin-buffer.js +24 -21
- package/dist/stdin-buffer.js.map +1 -1
- package/dist/terminal/constants.d.ts +9 -0
- package/dist/terminal/constants.d.ts.map +1 -0
- package/dist/terminal/constants.js +10 -0
- package/dist/terminal/constants.js.map +1 -0
- package/dist/terminal/helpers.d.ts +6 -0
- package/dist/terminal/helpers.d.ts.map +1 -0
- package/dist/terminal/helpers.js +23 -0
- package/dist/terminal/helpers.js.map +1 -0
- package/dist/terminal/index.d.ts +4 -0
- package/dist/terminal/index.d.ts.map +1 -0
- package/dist/terminal/index.js +3 -0
- package/dist/terminal/index.js.map +1 -0
- package/dist/terminal/processterminal-methods/cursor-screen.d.ts +11 -0
- package/dist/terminal/processterminal-methods/cursor-screen.d.ts.map +1 -0
- package/dist/terminal/processterminal-methods/cursor-screen.js +50 -0
- package/dist/terminal/processterminal-methods/cursor-screen.js.map +1 -0
- package/dist/terminal/processterminal-methods/keyboard-protocol.d.ts +14 -0
- package/dist/terminal/processterminal-methods/keyboard-protocol.d.ts.map +1 -0
- package/dist/terminal/processterminal-methods/keyboard-protocol.js +147 -0
- package/dist/terminal/processterminal-methods/keyboard-protocol.js.map +1 -0
- package/dist/terminal/processterminal-methods/terminal-io.d.ts +9 -0
- package/dist/terminal/processterminal-methods/terminal-io.d.ts.map +1 -0
- package/dist/terminal/processterminal-methods/terminal-io.js +153 -0
- package/dist/terminal/processterminal-methods/terminal-io.js.map +1 -0
- package/dist/terminal/processterminal.d.ts +49 -0
- package/dist/terminal/processterminal.d.ts.map +1 -0
- package/dist/terminal/processterminal.js +129 -0
- package/dist/terminal/processterminal.js.map +1 -0
- package/dist/terminal/types.d.ts +31 -0
- package/dist/terminal/types.d.ts.map +1 -0
- package/dist/terminal/types.js +2 -0
- package/dist/terminal/types.js.map +1 -0
- package/dist/terminal-colors.d.ts +2 -0
- package/dist/terminal-colors.d.ts.map +1 -1
- package/dist/terminal-colors.js +17 -5
- package/dist/terminal-colors.js.map +1 -1
- package/dist/terminal-image.d.ts.map +1 -1
- package/dist/terminal-image.js.map +1 -1
- package/dist/terminal.d.ts +1 -109
- package/dist/terminal.d.ts.map +1 -1
- package/dist/terminal.js +1 -432
- package/dist/terminal.js.map +1 -1
- package/dist/tui/constants.d.ts +3 -0
- package/dist/tui/constants.d.ts.map +1 -0
- package/dist/tui/constants.js +3 -0
- package/dist/tui/constants.js.map +1 -0
- package/dist/tui/container.d.ts +10 -0
- package/dist/tui/container.d.ts.map +1 -0
- package/dist/tui/container.js +31 -0
- package/dist/tui/container.js.map +1 -0
- package/dist/tui/helpers.d.ts +8 -0
- package/dist/tui/helpers.d.ts.map +1 -0
- package/dist/tui/helpers.js +53 -0
- package/dist/tui/helpers.js.map +1 -0
- package/dist/tui/index.d.ts +6 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +5 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/tui-methods/configuration.d.ts +20 -0
- package/dist/tui/tui-methods/configuration.d.ts.map +1 -0
- package/dist/tui/tui-methods/configuration.js +131 -0
- package/dist/tui/tui-methods/configuration.js.map +1 -0
- package/dist/tui/tui-methods/cursor-background.d.ts +10 -0
- package/dist/tui/tui-methods/cursor-background.d.ts.map +1 -0
- package/dist/tui/tui-methods/cursor-background.js +52 -0
- package/dist/tui/tui-methods/cursor-background.js.map +1 -0
- package/dist/tui/tui-methods/incremental-render.d.ts +17 -0
- package/dist/tui/tui-methods/incremental-render.d.ts.map +1 -0
- package/dist/tui/tui-methods/incremental-render.js +259 -0
- package/dist/tui/tui-methods/incremental-render.js.map +1 -0
- package/dist/tui/tui-methods/input-handling.d.ts +5 -0
- package/dist/tui/tui-methods/input-handling.d.ts.map +1 -0
- package/dist/tui/tui-methods/input-handling.js +111 -0
- package/dist/tui/tui-methods/input-handling.js.map +1 -0
- package/dist/tui/tui-methods/line-compositing.d.ts +7 -0
- package/dist/tui/tui-methods/line-compositing.d.ts.map +1 -0
- package/dist/tui/tui-methods/line-compositing.js +61 -0
- package/dist/tui/tui-methods/line-compositing.js.map +1 -0
- package/dist/tui/tui-methods/overlay-compositing.d.ts +12 -0
- package/dist/tui/tui-methods/overlay-compositing.d.ts.map +1 -0
- package/dist/tui/tui-methods/overlay-compositing.js +123 -0
- package/dist/tui/tui-methods/overlay-compositing.js.map +1 -0
- package/dist/tui/tui-methods/overlay-layout.d.ts +11 -0
- package/dist/tui/tui-methods/overlay-layout.d.ts.map +1 -0
- package/dist/tui/tui-methods/overlay-layout.js +124 -0
- package/dist/tui/tui-methods/overlay-layout.js.map +1 -0
- package/dist/tui/tui-methods/overlay-management.d.ts +11 -0
- package/dist/tui/tui-methods/overlay-management.d.ts.map +1 -0
- package/dist/tui/tui-methods/overlay-management.js +152 -0
- package/dist/tui/tui-methods/overlay-management.js.map +1 -0
- package/dist/tui/tui-methods/render-pipeline.d.ts +3 -0
- package/dist/tui/tui-methods/render-pipeline.d.ts.map +1 -0
- package/dist/tui/tui-methods/render-pipeline.js +176 -0
- package/dist/tui/tui-methods/render-pipeline.js.map +1 -0
- package/dist/tui/tui-methods/render-width-error.d.ts +3 -0
- package/dist/tui/tui-methods/render-width-error.d.ts.map +1 -0
- package/dist/tui/tui-methods/render-width-error.js +28 -0
- package/dist/tui/tui-methods/render-width-error.js.map +1 -0
- package/dist/tui/tui-methods/terminal-control.d.ts +8 -0
- package/dist/tui/tui-methods/terminal-control.d.ts.map +1 -0
- package/dist/tui/tui-methods/terminal-control.js +101 -0
- package/dist/tui/tui-methods/terminal-control.js.map +1 -0
- package/dist/tui/tui.d.ts +59 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +78 -0
- package/dist/tui/tui.js.map +1 -0
- package/dist/tui/types.d.ts +124 -0
- package/dist/tui/types.d.ts.map +1 -0
- package/dist/tui/types.js +2 -0
- package/dist/tui/types.js.map +1 -0
- package/dist/tui.d.ts +1 -254
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +1 -1344
- package/dist/tui.js.map +1 -1
- package/dist/undo-stack.d.ts.map +1 -1
- package/dist/undo-stack.js.map +1 -1
- package/dist/utils/ansi-wrapping.d.ts +5 -0
- package/dist/utils/ansi-wrapping.d.ts.map +1 -0
- package/dist/utils/ansi-wrapping.js +52 -0
- package/dist/utils/ansi-wrapping.js.map +1 -0
- package/dist/utils/ansicodetracker.d.ts +27 -0
- package/dist/utils/ansicodetracker.d.ts.map +1 -0
- package/dist/utils/ansicodetracker.js +222 -0
- package/dist/utils/ansicodetracker.js.map +1 -0
- package/dist/utils/column-slicing.d.ts +12 -0
- package/dist/utils/column-slicing.d.ts.map +1 -0
- package/dist/utils/column-slicing.js +111 -0
- package/dist/utils/column-slicing.js.map +1 -0
- package/dist/utils/column-truncation.d.ts +2 -0
- package/dist/utils/column-truncation.d.ts.map +1 -0
- package/dist/utils/column-truncation.js +129 -0
- package/dist/utils/column-truncation.js.map +1 -0
- package/dist/utils/constants.d.ts +12 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +12 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/install-delegated-methods.d.ts +5 -0
- package/dist/utils/install-delegated-methods.d.ts.map +1 -0
- package/dist/utils/install-delegated-methods.js +27 -0
- package/dist/utils/install-delegated-methods.js.map +1 -0
- package/dist/utils/segmentation.d.ts +10 -0
- package/dist/utils/segmentation.d.ts.map +1 -0
- package/dist/utils/segmentation.js +111 -0
- package/dist/utils/segmentation.js.map +1 -0
- package/dist/utils/terminal-output.d.ts +10 -0
- package/dist/utils/terminal-output.d.ts.map +1 -0
- package/dist/utils/terminal-output.js +122 -0
- package/dist/utils/terminal-output.js.map +1 -0
- package/dist/utils/types.d.ts +7 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/width-truncation.d.ts +6 -0
- package/dist/utils/width-truncation.d.ts.map +1 -0
- package/dist/utils/width-truncation.js +121 -0
- package/dist/utils/width-truncation.js.map +1 -0
- package/dist/utils/word-wrapping.d.ts +4 -0
- package/dist/utils/word-wrapping.d.ts.map +1 -0
- package/dist/utils/word-wrapping.js +139 -0
- package/dist/utils/word-wrapping.js.map +1 -0
- package/dist/utils.d.ts +1 -84
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1059
- package/dist/utils.js.map +1 -1
- package/dist/word-navigation.d.ts.map +1 -1
- package/dist/word-navigation.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Markdown } from "../markdown.ts";
|
|
2
|
+
import type { InlineStyleContext } from "../types.ts";
|
|
3
|
+
export declare function do_getDefaultStylePrefix(self: Markdown): string;
|
|
4
|
+
export declare function do_getStylePrefix(_self: Markdown, styleFn: (text: string) => string): string;
|
|
5
|
+
export declare function do_getDefaultInlineStyleContext(self: Markdown): InlineStyleContext;
|
|
6
|
+
//# sourceMappingURL=theming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theming.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown/markdown-methods/theming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAgC/D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAK5F;AAED,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,QAAQ,GAAG,kBAAkB,CAKlF","sourcesContent":["import type { Markdown } from \"../markdown.ts\";\nimport type { InlineStyleContext } from \"../types.ts\";\n\nexport function do_getDefaultStylePrefix(self: Markdown): string {\n if (!self.defaultTextStyle) {\n return \"\";\n }\n\n if (self.defaultStylePrefix !== undefined) {\n return self.defaultStylePrefix;\n }\n\n const sentinel = \"\\u0000\";\n let styled = sentinel;\n\n if (self.defaultTextStyle.color) {\n styled = self.defaultTextStyle.color(styled);\n }\n\n if (self.defaultTextStyle.bold) {\n styled = self.theme.bold(styled);\n }\n if (self.defaultTextStyle.italic) {\n styled = self.theme.italic(styled);\n }\n if (self.defaultTextStyle.strikethrough) {\n styled = self.theme.strikethrough(styled);\n }\n if (self.defaultTextStyle.underline) {\n styled = self.theme.underline(styled);\n }\n\n const sentinelIndex = styled.indexOf(sentinel);\n self.defaultStylePrefix = sentinelIndex >= 0 ? styled.slice(0, sentinelIndex) : \"\";\n return self.defaultStylePrefix;\n}\n\nexport function do_getStylePrefix(_self: Markdown, styleFn: (text: string) => string): string {\n const sentinel = \"\\u0000\";\n const styled = styleFn(sentinel);\n const sentinelIndex = styled.indexOf(sentinel);\n return sentinelIndex >= 0 ? styled.slice(0, sentinelIndex) : \"\";\n}\n\nexport function do_getDefaultInlineStyleContext(self: Markdown): InlineStyleContext {\n return {\n applyText: (text: string) => self.applyDefaultStyle(text),\n stylePrefix: self.getDefaultStylePrefix(),\n };\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export function do_getDefaultStylePrefix(self) {
|
|
2
|
+
if (!self.defaultTextStyle) {
|
|
3
|
+
return "";
|
|
4
|
+
}
|
|
5
|
+
if (self.defaultStylePrefix !== undefined) {
|
|
6
|
+
return self.defaultStylePrefix;
|
|
7
|
+
}
|
|
8
|
+
const sentinel = "\u0000";
|
|
9
|
+
let styled = sentinel;
|
|
10
|
+
if (self.defaultTextStyle.color) {
|
|
11
|
+
styled = self.defaultTextStyle.color(styled);
|
|
12
|
+
}
|
|
13
|
+
if (self.defaultTextStyle.bold) {
|
|
14
|
+
styled = self.theme.bold(styled);
|
|
15
|
+
}
|
|
16
|
+
if (self.defaultTextStyle.italic) {
|
|
17
|
+
styled = self.theme.italic(styled);
|
|
18
|
+
}
|
|
19
|
+
if (self.defaultTextStyle.strikethrough) {
|
|
20
|
+
styled = self.theme.strikethrough(styled);
|
|
21
|
+
}
|
|
22
|
+
if (self.defaultTextStyle.underline) {
|
|
23
|
+
styled = self.theme.underline(styled);
|
|
24
|
+
}
|
|
25
|
+
const sentinelIndex = styled.indexOf(sentinel);
|
|
26
|
+
self.defaultStylePrefix = sentinelIndex >= 0 ? styled.slice(0, sentinelIndex) : "";
|
|
27
|
+
return self.defaultStylePrefix;
|
|
28
|
+
}
|
|
29
|
+
export function do_getStylePrefix(_self, styleFn) {
|
|
30
|
+
const sentinel = "\u0000";
|
|
31
|
+
const styled = styleFn(sentinel);
|
|
32
|
+
const sentinelIndex = styled.indexOf(sentinel);
|
|
33
|
+
return sentinelIndex >= 0 ? styled.slice(0, sentinelIndex) : "";
|
|
34
|
+
}
|
|
35
|
+
export function do_getDefaultInlineStyleContext(self) {
|
|
36
|
+
return {
|
|
37
|
+
applyText: (text) => self.applyDefaultStyle(text),
|
|
38
|
+
stylePrefix: self.getDefaultStylePrefix(),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=theming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theming.js","sourceRoot":"","sources":["../../../../src/components/markdown/markdown-methods/theming.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,wBAAwB,CAAC,IAAc,EAAU;IAC/D,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC;IAC1B,IAAI,MAAM,GAAG,QAAQ,CAAC;IAEtB,IAAI,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,GAAG,IAAI,CAAC,KA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n\nexport function do_getDefaultStylePrefix(self: Markdown): string {\n if (!self.defaultTextStyle) {\n return \"\";\n }\n\n if (self.defaultStylePrefix !== undefined) {\n return self.defaultStylePrefix;\n }\n\n const sentinel = \"\\u0000\";\n let styled = sentinel;\n\n if (self.defaultTextStyle.color) {\n styled = self.defaultTextStyle.color(styled);\n }\n\n if (self.defaultTextStyle.bold) {\n styled = self.theme.bold(styled);\n }\n if (self.defaultTextStyle.italic) {\n styled = self.theme.italic(styled);\n }\n if (self.defaultTextStyle.strikethrough) {\n styled = self.theme.strikethrough(styled);\n }\n if (self.defaultTextStyle.underline) {\n styled = self.theme.underline(styled);\n }\n\n const sentinelIndex = styled.indexOf(sentinel);\n self.defaultStylePrefix = sentinelIndex >= 0 ? styled.slice(0, sentinelIndex) : \"\";\n return self.defaultStylePrefix;\n}\n\nexport function do_getStylePrefix(_self: Markdown, styleFn: (text: string) => string): string {\n const sentinel = \"\\u0000\";\n const styled = styleFn(sentinel);\n const sentinelIndex = styled.indexOf(sentinel);\n return sentinelIndex >= 0 ? styled.slice(0, sentinelIndex) : \"\";\n}\n\nexport function do_getDefaultInlineStyleContext(self: Markdown): InlineStyleContext {\n return {\n applyText: (text: string) => self.applyDefaultStyle(text),\n stylePrefix: self.getDefaultStylePrefix(),\n };\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Token } from "marked";
|
|
2
|
+
import type { Markdown } from "../markdown.ts";
|
|
3
|
+
import type { InlineStyleContext } from "../types.ts";
|
|
4
|
+
export declare function do_renderToken(self: Markdown, token: Token, width: number, nextTokenType?: string, styleContext?: InlineStyleContext): string[];
|
|
5
|
+
//# sourceMappingURL=token-rendering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-rendering.d.ts","sourceRoot":"","sources":["../../../../src/components/markdown/markdown-methods/token-rendering.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAU,MAAM,QAAQ,CAAC;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,kBAAkB,GAChC,MAAM,EAAE,CA8JV","sourcesContent":["import type { Token, Tokens } from \"marked\";\nimport { wrapTextWithAnsi } from \"../../../utils.ts\";\nimport type { Markdown } from \"../markdown.ts\";\nimport type { InlineStyleContext } from \"../types.ts\";\n\nexport function do_renderToken(\n self: Markdown,\n token: Token,\n width: number,\n nextTokenType?: string,\n styleContext?: InlineStyleContext,\n): string[] {\n const lines: string[] = [];\n\n switch (token.type) {\n case \"heading\": {\n const headingLevel = token.depth;\n const headingPrefix = `${\"#\".repeat(headingLevel)} `;\n\n // Build a heading-specific style context so inline tokens (codespan, bold, etc.)\n // restore heading styling after their own ANSI resets instead of falling back to\n // the default text style.\n let headingStyleFn: (text: string) => string;\n if (headingLevel === 1) {\n headingStyleFn = (text: string) => self.theme.heading(self.theme.bold(self.theme.underline(text)));\n } else {\n headingStyleFn = (text: string) => self.theme.heading(self.theme.bold(text));\n }\n\n const headingStyleContext: InlineStyleContext = {\n applyText: headingStyleFn,\n stylePrefix: self.getStylePrefix(headingStyleFn),\n };\n\n const headingText = self.renderInlineTokens(token.tokens || [], headingStyleContext);\n const styledHeading = headingLevel >= 3 ? headingStyleFn(headingPrefix) + headingText : headingText;\n lines.push(styledHeading);\n if (nextTokenType && nextTokenType !== \"space\") {\n lines.push(\"\"); // Add spacing after headings (unless space token follows)\n }\n break;\n }\n\n case \"paragraph\": {\n const paragraphText = self.renderInlineTokens(token.tokens || [], styleContext);\n lines.push(paragraphText);\n // Don't add spacing if next token is space or list\n if (nextTokenType && nextTokenType !== \"list\" && nextTokenType !== \"space\") {\n lines.push(\"\");\n }\n break;\n }\n\n case \"text\":\n lines.push(self.renderInlineTokens([token], styleContext));\n break;\n\n case \"code\": {\n const indent = self.theme.codeBlockIndent ?? \" \";\n lines.push(self.theme.codeBlockBorder(`\\`\\`\\`${token.lang || \"\"}`));\n if (self.theme.highlightCode) {\n const highlightedLines = self.theme.highlightCode(token.text, token.lang);\n for (const hlLine of highlightedLines) {\n lines.push(`${indent}${hlLine}`);\n }\n } else {\n // Split code by newlines and style each line\n const codeLines = token.text.split(\"\\n\");\n for (const codeLine of codeLines) {\n lines.push(`${indent}${self.theme.codeBlock(codeLine)}`);\n }\n }\n lines.push(self.theme.codeBlockBorder(\"```\"));\n if (nextTokenType && nextTokenType !== \"space\") {\n lines.push(\"\"); // Add spacing after code blocks (unless space token follows)\n }\n break;\n }\n\n case \"list\": {\n const listLines = self.renderList(token as Tokens.List, 0, width, styleContext);\n lines.push(...listLines);\n // Don't add spacing after lists if a space token follows\n // (the space token will handle it)\n break;\n }\n\n case \"table\": {\n const tableLines = self.renderTable(token as Tokens.Table, width, nextTokenType, styleContext);\n lines.push(...tableLines);\n break;\n }\n\n case \"blockquote\": {\n const quoteStyle = (text: string) => self.theme.quote(self.theme.italic(text));\n const quoteStylePrefix = self.getStylePrefix(quoteStyle);\n const applyQuoteStyle = (line: string): string => {\n if (!quoteStylePrefix) {\n return quoteStyle(line);\n }\n const lineWithReappliedStyle = line.replace(/\\x1b\\[0m/g, `\\x1b[0m${quoteStylePrefix}`);\n return quoteStyle(lineWithReappliedStyle);\n };\n\n // Calculate available width for quote content (subtract border \"│ \" = 2 chars)\n const quoteContentWidth = Math.max(1, width - 2);\n\n // Blockquotes contain block-level tokens (paragraph, list, code, etc.), so render\n // children with renderToken() instead of renderInlineTokens().\n // Default message style should not apply inside blockquotes.\n const quoteInlineStyleContext: InlineStyleContext = {\n applyText: (text: string) => text,\n stylePrefix: quoteStylePrefix,\n };\n const quoteTokens = token.tokens || [];\n const renderedQuoteLines: string[] = [];\n for (let i = 0; i < quoteTokens.length; i++) {\n const quoteToken = quoteTokens[i];\n const nextQuoteToken = quoteTokens[i + 1];\n renderedQuoteLines.push(\n ...self.renderToken(quoteToken, quoteContentWidth, nextQuoteToken?.type, quoteInlineStyleContext),\n );\n }\n\n // Avoid rendering an extra empty quote line before the outer blockquote spacing.\n while (renderedQuoteLines.length > 0 && renderedQuoteLines[renderedQuoteLines.length - 1] === \"\") {\n renderedQuoteLines.pop();\n }\n\n for (const quoteLine of renderedQuoteLines) {\n const styledLine = applyQuoteStyle(quoteLine);\n const wrappedLines = wrapTextWithAnsi(styledLine, quoteContentWidth);\n for (const wrappedLine of wrappedLines) {\n lines.push(self.theme.quoteBorder(\"│ \") + wrappedLine);\n }\n }\n if (nextTokenType && nextTokenType !== \"space\") {\n lines.push(\"\"); // Add spacing after blockquotes (unless space token follows)\n }\n break;\n }\n\n case \"hr\":\n lines.push(self.theme.hr(\"─\".repeat(Math.min(width, 80))));\n if (nextTokenType && nextTokenType !== \"space\") {\n lines.push(\"\"); // Add spacing after horizontal rules (unless space token follows)\n }\n break;\n\n case \"html\":\n // Render HTML as plain text (escaped for terminal)\n if (\"raw\" in token && typeof token.raw === \"string\") {\n lines.push(self.applyDefaultStyle(token.raw.trim()));\n }\n break;\n\n case \"space\":\n // Space tokens represent blank lines in markdown\n lines.push(\"\");\n break;\n\n default:\n // Handle any other token types as plain text\n if (\"text\" in token && typeof token.text === \"string\") {\n lines.push(token.text);\n }\n }\n\n return lines;\n}\n"]}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { wrapTextWithAnsi } from "../../../utils.js";
|
|
2
|
+
export function do_renderToken(self, token, width, nextTokenType, styleContext) {
|
|
3
|
+
const lines = [];
|
|
4
|
+
switch (token.type) {
|
|
5
|
+
case "heading": {
|
|
6
|
+
const headingLevel = token.depth;
|
|
7
|
+
const headingPrefix = `${"#".repeat(headingLevel)} `;
|
|
8
|
+
// Build a heading-specific style context so inline tokens (codespan, bold, etc.)
|
|
9
|
+
// restore heading styling after their own ANSI resets instead of falling back to
|
|
10
|
+
// the default text style.
|
|
11
|
+
let headingStyleFn;
|
|
12
|
+
if (headingLevel === 1) {
|
|
13
|
+
headingStyleFn = (text) => self.theme.heading(self.theme.bold(self.theme.underline(text)));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
headingStyleFn = (text) => self.theme.heading(self.theme.bold(text));
|
|
17
|
+
}
|
|
18
|
+
const headingStyleContext = {
|
|
19
|
+
applyText: headingStyleFn,
|
|
20
|
+
stylePrefix: self.getStylePrefix(headingStyleFn),
|
|
21
|
+
};
|
|
22
|
+
const headingText = self.renderInlineTokens(token.tokens || [], headingStyleContext);
|
|
23
|
+
const styledHeading = headingLevel >= 3 ? headingStyleFn(headingPrefix) + headingText : headingText;
|
|
24
|
+
lines.push(styledHeading);
|
|
25
|
+
if (nextTokenType && nextTokenType !== "space") {
|
|
26
|
+
lines.push(""); // Add spacing after headings (unless space token follows)
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case "paragraph": {
|
|
31
|
+
const paragraphText = self.renderInlineTokens(token.tokens || [], styleContext);
|
|
32
|
+
lines.push(paragraphText);
|
|
33
|
+
// Don't add spacing if next token is space or list
|
|
34
|
+
if (nextTokenType && nextTokenType !== "list" && nextTokenType !== "space") {
|
|
35
|
+
lines.push("");
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case "text":
|
|
40
|
+
lines.push(self.renderInlineTokens([token], styleContext));
|
|
41
|
+
break;
|
|
42
|
+
case "code": {
|
|
43
|
+
const indent = self.theme.codeBlockIndent ?? " ";
|
|
44
|
+
lines.push(self.theme.codeBlockBorder(`\`\`\`${token.lang || ""}`));
|
|
45
|
+
if (self.theme.highlightCode) {
|
|
46
|
+
const highlightedLines = self.theme.highlightCode(token.text, token.lang);
|
|
47
|
+
for (const hlLine of highlightedLines) {
|
|
48
|
+
lines.push(`${indent}${hlLine}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// Split code by newlines and style each line
|
|
53
|
+
const codeLines = token.text.split("\n");
|
|
54
|
+
for (const codeLine of codeLines) {
|
|
55
|
+
lines.push(`${indent}${self.theme.codeBlock(codeLine)}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
lines.push(self.theme.codeBlockBorder("```"));
|
|
59
|
+
if (nextTokenType && nextTokenType !== "space") {
|
|
60
|
+
lines.push(""); // Add spacing after code blocks (unless space token follows)
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case "list": {
|
|
65
|
+
const listLines = self.renderList(token, 0, width, styleContext);
|
|
66
|
+
lines.push(...listLines);
|
|
67
|
+
// Don't add spacing after lists if a space token follows
|
|
68
|
+
// (the space token will handle it)
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case "table": {
|
|
72
|
+
const tableLines = self.renderTable(token, width, nextTokenType, styleContext);
|
|
73
|
+
lines.push(...tableLines);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case "blockquote": {
|
|
77
|
+
const quoteStyle = (text) => self.theme.quote(self.theme.italic(text));
|
|
78
|
+
const quoteStylePrefix = self.getStylePrefix(quoteStyle);
|
|
79
|
+
const applyQuoteStyle = (line) => {
|
|
80
|
+
if (!quoteStylePrefix) {
|
|
81
|
+
return quoteStyle(line);
|
|
82
|
+
}
|
|
83
|
+
const lineWithReappliedStyle = line.replace(/\x1b\[0m/g, `\x1b[0m${quoteStylePrefix}`);
|
|
84
|
+
return quoteStyle(lineWithReappliedStyle);
|
|
85
|
+
};
|
|
86
|
+
// Calculate available width for quote content (subtract border "│ " = 2 chars)
|
|
87
|
+
const quoteContentWidth = Math.max(1, width - 2);
|
|
88
|
+
// Blockquotes contain block-level tokens (paragraph, list, code, etc.), so render
|
|
89
|
+
// children with renderToken() instead of renderInlineTokens().
|
|
90
|
+
// Default message style should not apply inside blockquotes.
|
|
91
|
+
const quoteInlineStyleContext = {
|
|
92
|
+
applyText: (text) => text,
|
|
93
|
+
stylePrefix: quoteStylePrefix,
|
|
94
|
+
};
|
|
95
|
+
const quoteTokens = token.tokens || [];
|
|
96
|
+
const renderedQuoteLines = [];
|
|
97
|
+
for (let i = 0; i < quoteTokens.length; i++) {
|
|
98
|
+
const quoteToken = quoteTokens[i];
|
|
99
|
+
const nextQuoteToken = quoteTokens[i + 1];
|
|
100
|
+
renderedQuoteLines.push(...self.renderToken(quoteToken, quoteContentWidth, nextQuoteToken?.type, quoteInlineStyleContext));
|
|
101
|
+
}
|
|
102
|
+
// Avoid rendering an extra empty quote line before the outer blockquote spacing.
|
|
103
|
+
while (renderedQuoteLines.length > 0 && renderedQuoteLines[renderedQuoteLines.length - 1] === "") {
|
|
104
|
+
renderedQuoteLines.pop();
|
|
105
|
+
}
|
|
106
|
+
for (const quoteLine of renderedQuoteLines) {
|
|
107
|
+
const styledLine = applyQuoteStyle(quoteLine);
|
|
108
|
+
const wrappedLines = wrapTextWithAnsi(styledLine, quoteContentWidth);
|
|
109
|
+
for (const wrappedLine of wrappedLines) {
|
|
110
|
+
lines.push(self.theme.quoteBorder("│ ") + wrappedLine);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (nextTokenType && nextTokenType !== "space") {
|
|
114
|
+
lines.push(""); // Add spacing after blockquotes (unless space token follows)
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case "hr":
|
|
119
|
+
lines.push(self.theme.hr("─".repeat(Math.min(width, 80))));
|
|
120
|
+
if (nextTokenType && nextTokenType !== "space") {
|
|
121
|
+
lines.push(""); // Add spacing after horizontal rules (unless space token follows)
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
case "html":
|
|
125
|
+
// Render HTML as plain text (escaped for terminal)
|
|
126
|
+
if ("raw" in token && typeof token.raw === "string") {
|
|
127
|
+
lines.push(self.applyDefaultStyle(token.raw.trim()));
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case "space":
|
|
131
|
+
// Space tokens represent blank lines in markdown
|
|
132
|
+
lines.push("");
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
// Handle any other token types as plain text
|
|
136
|
+
if ("text" in token && typeof token.text === "string") {
|
|
137
|
+
lines.push(token.text);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return lines;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=token-rendering.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-rendering.js","sourceRoot":"","sources":["../../../../src/components/markdown/markdown-methods/token-rendering.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAIrD,MAAM,UAAU,cAAc,CAC5B,IAAc,EACd,KAAY,EACZ,KAAa,EACb,aAAsB,EACtB,YAAiC,EACvB;IACV,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,SAAS,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC;YACjC,MAAM,aAAa,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC;YAErD,iFAAiF;YACjF,iFAAiF;YACjF,0BAA0B;YAC1B,IAAI,cAAwC,CAAC;YAC7C,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;gBACvB,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACrG,CAAC;iBAAM,CAAC;gBACN,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAA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AAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,kEAAkE;YACpF,CAAC;YACD,MAAM;QAER,KAAK,MAAM;YACT,mDAAmD;YACnD,IAAI,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBACpD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YACvD,CAAC;YACD,MAAM;QAER,KAAK,OAAO;YACV,iDAAiD;YACjD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,MAAM;QAER;YACE,6CAA6C;YAC7C,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AAAA,CACd","sourcesContent":["import type { Token, Tokens } from \"marked\";\nimport { wrapTextWithAnsi } from \"../../../utils.ts\";\nimport type { Markdown } from \"../markdown.ts\";\nimport type { InlineStyleContext } from \"../types.ts\";\n\nexport function do_renderToken(\n self: Markdown,\n token: Token,\n width: number,\n nextTokenType?: string,\n styleContext?: InlineStyleContext,\n): string[] {\n const lines: string[] = [];\n\n switch (token.type) {\n case \"heading\": {\n const headingLevel = token.depth;\n const headingPrefix = `${\"#\".repeat(headingLevel)} `;\n\n // Build a heading-specific style context so inline tokens (codespan, bold, etc.)\n // restore heading styling after their own ANSI resets instead of falling back to\n // the default text style.\n let headingStyleFn: (text: string) => string;\n if (headingLevel === 1) {\n headingStyleFn = (text: string) => self.theme.heading(self.theme.bold(self.theme.underline(text)));\n } else {\n headingStyleFn = (text: string) => self.theme.heading(self.theme.bold(text));\n }\n\n const headingStyleContext: InlineStyleContext = {\n applyText: headingStyleFn,\n stylePrefix: self.getStylePrefix(headingStyleFn),\n };\n\n const headingText = self.renderInlineTokens(token.tokens || [], headingStyleContext);\n const styledHeading = headingLevel >= 3 ? headingStyleFn(headingPrefix) + headingText : headingText;\n lines.push(styledHeading);\n if (nextTokenType && nextTokenType !== \"space\") {\n lines.push(\"\"); // Add spacing after headings (unless space token follows)\n }\n break;\n }\n\n case \"paragraph\": {\n const paragraphText = self.renderInlineTokens(token.tokens || [], styleContext);\n lines.push(paragraphText);\n // Don't add spacing if next token is space or list\n if (nextTokenType && nextTokenType !== \"list\" && nextTokenType !== \"space\") {\n lines.push(\"\");\n }\n break;\n }\n\n case \"text\":\n lines.push(self.renderInlineTokens([token], styleContext));\n break;\n\n case \"code\": {\n const indent = self.theme.codeBlockIndent ?? \" \";\n lines.push(self.theme.codeBlockBorder(`\\`\\`\\`${token.lang || \"\"}`));\n if (self.theme.highlightCode) {\n const highlightedLines = self.theme.highlightCode(token.text, token.lang);\n for (const hlLine of highlightedLines) {\n lines.push(`${indent}${hlLine}`);\n }\n } else {\n // Split code by newlines and style each line\n const codeLines = token.text.split(\"\\n\");\n for (const codeLine of codeLines) {\n lines.push(`${indent}${self.theme.codeBlock(codeLine)}`);\n }\n }\n lines.push(self.theme.codeBlockBorder(\"```\"));\n if (nextTokenType && nextTokenType !== \"space\") {\n lines.push(\"\"); // Add spacing after code blocks (unless space token follows)\n }\n break;\n }\n\n case \"list\": {\n const listLines = self.renderList(token as Tokens.List, 0, width, styleContext);\n lines.push(...listLines);\n // Don't add spacing after lists if a space token follows\n // (the space token will handle it)\n break;\n }\n\n case \"table\": {\n const tableLines = self.renderTable(token as Tokens.Table, width, nextTokenType, styleContext);\n lines.push(...tableLines);\n break;\n }\n\n case \"blockquote\": {\n const quoteStyle = (text: string) => self.theme.quote(self.theme.italic(text));\n const quoteStylePrefix = self.getStylePrefix(quoteStyle);\n const applyQuoteStyle = (line: string): string => {\n if (!quoteStylePrefix) {\n return quoteStyle(line);\n }\n const lineWithReappliedStyle = line.replace(/\\x1b\\[0m/g, `\\x1b[0m${quoteStylePrefix}`);\n return quoteStyle(lineWithReappliedStyle);\n };\n\n // Calculate available width for quote content (subtract border \"│ \" = 2 chars)\n const quoteContentWidth = Math.max(1, width - 2);\n\n // Blockquotes contain block-level tokens (paragraph, list, code, etc.), so render\n // children with renderToken() instead of renderInlineTokens().\n // Default message style should not apply inside blockquotes.\n const quoteInlineStyleContext: InlineStyleContext = {\n applyText: (text: string) => text,\n stylePrefix: quoteStylePrefix,\n };\n const quoteTokens = token.tokens || [];\n const renderedQuoteLines: string[] = [];\n for (let i = 0; i < quoteTokens.length; i++) {\n const quoteToken = quoteTokens[i];\n const nextQuoteToken = quoteTokens[i + 1];\n renderedQuoteLines.push(\n ...self.renderToken(quoteToken, quoteContentWidth, nextQuoteToken?.type, quoteInlineStyleContext),\n );\n }\n\n // Avoid rendering an extra empty quote line before the outer blockquote spacing.\n while (renderedQuoteLines.length > 0 && renderedQuoteLines[renderedQuoteLines.length - 1] === \"\") {\n renderedQuoteLines.pop();\n }\n\n for (const quoteLine of renderedQuoteLines) {\n const styledLine = applyQuoteStyle(quoteLine);\n const wrappedLines = wrapTextWithAnsi(styledLine, quoteContentWidth);\n for (const wrappedLine of wrappedLines) {\n lines.push(self.theme.quoteBorder(\"│ \") + wrappedLine);\n }\n }\n if (nextTokenType && nextTokenType !== \"space\") {\n lines.push(\"\"); // Add spacing after blockquotes (unless space token follows)\n }\n break;\n }\n\n case \"hr\":\n lines.push(self.theme.hr(\"─\".repeat(Math.min(width, 80))));\n if (nextTokenType && nextTokenType !== \"space\") {\n lines.push(\"\"); // Add spacing after horizontal rules (unless space token follows)\n }\n break;\n\n case \"html\":\n // Render HTML as plain text (escaped for terminal)\n if (\"raw\" in token && typeof token.raw === \"string\") {\n lines.push(self.applyDefaultStyle(token.raw.trim()));\n }\n break;\n\n case \"space\":\n // Space tokens represent blank lines in markdown\n lines.push(\"\");\n break;\n\n default:\n // Handle any other token types as plain text\n if (\"text\" in token && typeof token.text === \"string\") {\n lines.push(token.text);\n }\n }\n\n return lines;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Token, Tokens } from "marked";
|
|
2
|
+
import type { Component } from "../../tui.ts";
|
|
3
|
+
import type { DefaultTextStyle, InlineStyleContext, MarkdownOptions, MarkdownTheme } from "./types.ts";
|
|
4
|
+
export declare class Markdown implements Component {
|
|
5
|
+
text: string;
|
|
6
|
+
paddingX: number;
|
|
7
|
+
paddingY: number;
|
|
8
|
+
defaultTextStyle?: DefaultTextStyle;
|
|
9
|
+
theme: MarkdownTheme;
|
|
10
|
+
options: MarkdownOptions;
|
|
11
|
+
defaultStylePrefix?: string;
|
|
12
|
+
cachedText?: string;
|
|
13
|
+
cachedWidth?: number;
|
|
14
|
+
cachedLines?: string[];
|
|
15
|
+
constructor(text: string, paddingX: number, paddingY: number, theme: MarkdownTheme, defaultTextStyle?: DefaultTextStyle, options?: MarkdownOptions);
|
|
16
|
+
setText(text: string): void;
|
|
17
|
+
invalidate(): void;
|
|
18
|
+
render(width: number): string[];
|
|
19
|
+
applyDefaultStyle(text: string): string;
|
|
20
|
+
getDefaultStylePrefix(): string;
|
|
21
|
+
getStylePrefix(styleFn: (text: string) => string): string;
|
|
22
|
+
getDefaultInlineStyleContext(): InlineStyleContext;
|
|
23
|
+
renderToken(token: Token, width: number, nextTokenType?: string, styleContext?: InlineStyleContext): string[];
|
|
24
|
+
renderInlineTokens(tokens: Token[], styleContext?: InlineStyleContext): string;
|
|
25
|
+
getOrderedListMarker(item: Tokens.ListItem): string | undefined;
|
|
26
|
+
getUnorderedListMarker(item: Tokens.ListItem): string | undefined;
|
|
27
|
+
renderList(token: Tokens.List, depth: number, width: number, styleContext?: InlineStyleContext): string[];
|
|
28
|
+
getLongestWordWidth(text: string, maxWidth?: number): number;
|
|
29
|
+
wrapCellText(text: string, maxWidth: number): string[];
|
|
30
|
+
renderTable(token: Tokens.Table, availableWidth: number, nextTokenType?: string, styleContext?: InlineStyleContext): string[];
|
|
31
|
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AM,GAAG,MAAM,CAExD;IAED,4BAA4B,IAAI,kBAAkB,CAEjD;IAED,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAE5G;IAED,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,YAAY,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAE7E;IAED,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,GAAG,SAAS,CAE9D;IAED,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,GAAG,SAAS,CAEhE;IAED,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAExG;IAED,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D;IAED,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAErD;IAED,WAAW,CACT,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,cAAc,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,kBAAkB,GAChC,MAAM,EAAE,CAEV;CACF","sourcesContent":["import type { Token, Tokens } from \"marked\";\nimport type { Component } from \"../../tui.ts\";\nimport {\n do_getOrderedListMarker,\n do_getUnorderedListMarker,\n do_renderInlineTokens,\n} from \"./markdown-methods/inline-rendering.ts\";\nimport { do_getLongestWordWidth, do_renderList, do_wrapCellText } from \"./markdown-methods/list-table-helpers.ts\";\nimport { do_renderTable } from \"./markdown-methods/table-rendering.ts\";\nimport { do_applyDefaultStyle, do_invalidate, do_render, do_setText } from \"./markdown-methods/text-rendering.ts\";\nimport {\n do_getDefaultInlineStyleContext,\n do_getDefaultStylePrefix,\n do_getStylePrefix,\n} from \"./markdown-methods/theming.ts\";\nimport { do_renderToken } from \"./markdown-methods/token-rendering.ts\";\nimport type { DefaultTextStyle, InlineStyleContext, MarkdownOptions, MarkdownTheme } from \"./types.ts\";\n\nexport class Markdown implements Component {\n public text: string;\n\n public paddingX: number;\n\n public paddingY: number;\n\n public defaultTextStyle?: DefaultTextStyle;\n\n public theme: MarkdownTheme;\n\n public options: MarkdownOptions;\n\n public defaultStylePrefix?: string;\n\n public cachedText?: string;\n\n public cachedWidth?: number;\n\n public cachedLines?: string[];\n\n constructor(\n text: string,\n paddingX: number,\n paddingY: number,\n theme: MarkdownTheme,\n defaultTextStyle?: DefaultTextStyle,\n options?: MarkdownOptions,\n ) {\n this.text = text;\n this.paddingX = paddingX;\n this.paddingY = paddingY;\n this.theme = theme;\n this.defaultTextStyle = defaultTextStyle;\n this.options = options ? { ...options } : {};\n }\n\n setText(text: string): void {\n do_setText(this, text);\n }\n\n invalidate(): void {\n do_invalidate(this);\n }\n\n render(width: number): string[] {\n return do_render(this, width);\n }\n\n applyDefaultStyle(text: string): string {\n return do_applyDefaultStyle(this, text);\n }\n\n getDefaultStylePrefix(): string {\n return do_getDefaultStylePrefix(this);\n }\n\n getStylePrefix(styleFn: (text: string) => string): string {\n return do_getStylePrefix(this, styleFn);\n }\n\n getDefaultInlineStyleContext(): InlineStyleContext {\n return do_getDefaultInlineStyleContext(this);\n }\n\n renderToken(token: Token, width: number, nextTokenType?: string, styleContext?: InlineStyleContext): string[] {\n return do_renderToken(this, token, width, nextTokenType, styleContext);\n }\n\n renderInlineTokens(tokens: Token[], styleContext?: InlineStyleContext): string {\n return do_renderInlineTokens(this, tokens, styleContext);\n }\n\n getOrderedListMarker(item: Tokens.ListItem): string | undefined {\n return do_getOrderedListMarker(this, item);\n }\n\n getUnorderedListMarker(item: Tokens.ListItem): string | undefined {\n return do_getUnorderedListMarker(this, item);\n }\n\n renderList(token: Tokens.List, depth: number, width: number, styleContext?: InlineStyleContext): string[] {\n return do_renderList(this, token, depth, width, styleContext);\n }\n\n getLongestWordWidth(text: string, maxWidth?: number): number {\n return do_getLongestWordWidth(this, text, maxWidth);\n }\n\n wrapCellText(text: string, maxWidth: number): string[] {\n return do_wrapCellText(this, text, maxWidth);\n }\n\n renderTable(\n token: Tokens.Table,\n availableWidth: number,\n nextTokenType?: string,\n styleContext?: InlineStyleContext,\n ): string[] {\n return do_renderTable(this, token, availableWidth, nextTokenType, styleContext);\n }\n}\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { do_getOrderedListMarker, do_getUnorderedListMarker, do_renderInlineTokens, } from "./markdown-methods/inline-rendering.js";
|
|
2
|
+
import { do_getLongestWordWidth, do_renderList, do_wrapCellText } from "./markdown-methods/list-table-helpers.js";
|
|
3
|
+
import { do_renderTable } from "./markdown-methods/table-rendering.js";
|
|
4
|
+
import { do_applyDefaultStyle, do_invalidate, do_render, do_setText } from "./markdown-methods/text-rendering.js";
|
|
5
|
+
import { do_getDefaultInlineStyleContext, do_getDefaultStylePrefix, do_getStylePrefix, } from "./markdown-methods/theming.js";
|
|
6
|
+
import { do_renderToken } from "./markdown-methods/token-rendering.js";
|
|
7
|
+
export class Markdown {
|
|
8
|
+
text;
|
|
9
|
+
paddingX;
|
|
10
|
+
paddingY;
|
|
11
|
+
defaultTextStyle;
|
|
12
|
+
theme;
|
|
13
|
+
options;
|
|
14
|
+
defaultStylePrefix;
|
|
15
|
+
cachedText;
|
|
16
|
+
cachedWidth;
|
|
17
|
+
cachedLines;
|
|
18
|
+
constructor(text, paddingX, paddingY, theme, defaultTextStyle, options) {
|
|
19
|
+
this.text = text;
|
|
20
|
+
this.paddingX = paddingX;
|
|
21
|
+
this.paddingY = paddingY;
|
|
22
|
+
this.theme = theme;
|
|
23
|
+
this.defaultTextStyle = defaultTextStyle;
|
|
24
|
+
this.options = options ? { ...options } : {};
|
|
25
|
+
}
|
|
26
|
+
setText(text) {
|
|
27
|
+
do_setText(this, text);
|
|
28
|
+
}
|
|
29
|
+
invalidate() {
|
|
30
|
+
do_invalidate(this);
|
|
31
|
+
}
|
|
32
|
+
render(width) {
|
|
33
|
+
return do_render(this, width);
|
|
34
|
+
}
|
|
35
|
+
applyDefaultStyle(text) {
|
|
36
|
+
return do_applyDefaultStyle(this, text);
|
|
37
|
+
}
|
|
38
|
+
getDefaultStylePrefix() {
|
|
39
|
+
return do_getDefaultStylePrefix(this);
|
|
40
|
+
}
|
|
41
|
+
getStylePrefix(styleFn) {
|
|
42
|
+
return do_getStylePrefix(this, styleFn);
|
|
43
|
+
}
|
|
44
|
+
getDefaultInlineStyleContext() {
|
|
45
|
+
return do_getDefaultInlineStyleContext(this);
|
|
46
|
+
}
|
|
47
|
+
renderToken(token, width, nextTokenType, styleContext) {
|
|
48
|
+
return do_renderToken(this, token, width, nextTokenType, styleContext);
|
|
49
|
+
}
|
|
50
|
+
renderInlineTokens(tokens, styleContext) {
|
|
51
|
+
return do_renderInlineTokens(this, tokens, styleContext);
|
|
52
|
+
}
|
|
53
|
+
getOrderedListMarker(item) {
|
|
54
|
+
return do_getOrderedListMarker(this, item);
|
|
55
|
+
}
|
|
56
|
+
getUnorderedListMarker(item) {
|
|
57
|
+
return do_getUnorderedListMarker(this, item);
|
|
58
|
+
}
|
|
59
|
+
renderList(token, depth, width, styleContext) {
|
|
60
|
+
return do_renderList(this, token, depth, width, styleContext);
|
|
61
|
+
}
|
|
62
|
+
getLongestWordWidth(text, maxWidth) {
|
|
63
|
+
return do_getLongestWordWidth(this, text, maxWidth);
|
|
64
|
+
}
|
|
65
|
+
wrapCellText(text, maxWidth) {
|
|
66
|
+
return do_wrapCellText(this, text, maxWidth);
|
|
67
|
+
}
|
|
68
|
+
renderTable(token, availableWidth, nextTokenType, styleContext) {
|
|
69
|
+
return do_renderTable(this, token, availableWidth, nextTokenType, styleContext);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../../src/components/markdown/markdown.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAClH,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClH,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAGvE,MAAM,OAAO,QAAQ;IACZ,IAAI,CAAS;IAEb,QAAQ,CAAS;IAEjB,QAAQ,CAAS;IAEjB,gBAAgB,CAAoB;IAEpC,KAAK,CAAgB;IAErB,OAAO,CAAkB;IAEzB,kBAAkB,CAAU;IAE5B,UAAU,CAAU;IAEpB,WAAW,CAAU;IAErB,WAAW,CAAY;IAE9B,YACE,IAAY,EACZ,QAAgB,EAChB,QAAgB,EAChB,KAAoB,EACpB,gBAAmC,EACnC,OAAyB,EACzB;QACA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAAA,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AAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IAAA,CAC/D;IAED,mBAAmB,CAAC,IAAY,EAAE,QAAiB,EAAU;QAC3D,OAAO,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAAA,CACrD;IAED,YAAY,CAAC,IAAY,EAAE,QAAgB,EAAY;QACrD,OAAO,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAAA,CAC9C;IAED,WAAW,CACT,KAAmB,EACnB,cAAsB,EACtB,aAAsB,EACtB,YAAiC,EACvB;QACV,OAAO,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;IAAA,CACjF;CACF","sourcesContent":["import type { Token, Tokens } from \"marked\";\nimport type { Component } from \"../../tui.ts\";\nimport {\n do_getOrderedListMarker,\n do_getUnorderedListMarker,\n do_renderInlineTokens,\n} from \"./markdown-methods/inline-rendering.ts\";\nimport { do_getLongestWordWidth, do_renderList, do_wrapCellText } from \"./markdown-methods/list-table-helpers.ts\";\nimport { do_renderTable } from \"./markdown-methods/table-rendering.ts\";\nimport { do_applyDefaultStyle, do_invalidate, do_render, do_setText } from \"./markdown-methods/text-rendering.ts\";\nimport {\n do_getDefaultInlineStyleContext,\n do_getDefaultStylePrefix,\n do_getStylePrefix,\n} from \"./markdown-methods/theming.ts\";\nimport { do_renderToken } from \"./markdown-methods/token-rendering.ts\";\nimport type { DefaultTextStyle, InlineStyleContext, MarkdownOptions, MarkdownTheme } from \"./types.ts\";\n\nexport class Markdown implements Component {\n public text: string;\n\n public paddingX: number;\n\n public paddingY: number;\n\n public defaultTextStyle?: DefaultTextStyle;\n\n public theme: MarkdownTheme;\n\n public options: MarkdownOptions;\n\n public defaultStylePrefix?: string;\n\n public cachedText?: string;\n\n public cachedWidth?: number;\n\n public cachedLines?: string[];\n\n constructor(\n text: string,\n paddingX: number,\n paddingY: number,\n theme: MarkdownTheme,\n defaultTextStyle?: DefaultTextStyle,\n options?: MarkdownOptions,\n ) {\n this.text = text;\n this.paddingX = paddingX;\n this.paddingY = paddingY;\n this.theme = theme;\n this.defaultTextStyle = defaultTextStyle;\n this.options = options ? { ...options } : {};\n }\n\n setText(text: string): void {\n do_setText(this, text);\n }\n\n invalidate(): void {\n do_invalidate(this);\n }\n\n render(width: number): string[] {\n return do_render(this, width);\n }\n\n applyDefaultStyle(text: string): string {\n return do_applyDefaultStyle(this, text);\n }\n\n getDefaultStylePrefix(): string {\n return do_getDefaultStylePrefix(this);\n }\n\n getStylePrefix(styleFn: (text: string) => string): string {\n return do_getStylePrefix(this, styleFn);\n }\n\n getDefaultInlineStyleContext(): InlineStyleContext {\n return do_getDefaultInlineStyleContext(this);\n }\n\n renderToken(token: Token, width: number, nextTokenType?: string, styleContext?: InlineStyleContext): string[] {\n return do_renderToken(this, token, width, nextTokenType, styleContext);\n }\n\n renderInlineTokens(tokens: Token[], styleContext?: InlineStyleContext): string {\n return do_renderInlineTokens(this, tokens, styleContext);\n }\n\n getOrderedListMarker(item: Tokens.ListItem): string | undefined {\n return do_getOrderedListMarker(this, item);\n }\n\n getUnorderedListMarker(item: Tokens.ListItem): string | undefined {\n return do_getUnorderedListMarker(this, item);\n }\n\n renderList(token: Tokens.List, depth: number, width: number, styleContext?: InlineStyleContext): string[] {\n return do_renderList(this, token, depth, width, styleContext);\n }\n\n getLongestWordWidth(text: string, maxWidth?: number): number {\n return do_getLongestWordWidth(this, text, maxWidth);\n }\n\n wrapCellText(text: string, maxWidth: number): string[] {\n return do_wrapCellText(this, text, maxWidth);\n }\n\n renderTable(\n token: Tokens.Table,\n availableWidth: number,\n nextTokenType?: string,\n styleContext?: InlineStyleContext,\n ): string[] {\n return do_renderTable(this, token, availableWidth, nextTokenType, styleContext);\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Tokenizer, type Tokens } from "marked";
|
|
2
|
+
export declare const STRICT_STRIKETHROUGH_REGEX: RegExp;
|
|
3
|
+
export declare class StrictStrikethroughTokenizer extends Tokenizer {
|
|
4
|
+
del(src: string): Tokens.Del | undefined;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=strictstrikethroughtokenizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strictstrikethroughtokenizer.d.ts","sourceRoot":"","sources":["../../../src/components/markdown/strictstrikethroughtokenizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,eAAO,MAAM,0BAA0B,QAAiE,CAAC;AAEzG,qBAAa,4BAA6B,SAAQ,SAAS;IAChD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,SAAS,CAahD;CACF","sourcesContent":["import { Tokenizer, type Tokens } from \"marked\";\n\nexport const STRICT_STRIKETHROUGH_REGEX = /^(~~)(?=[^\\s~])((?:\\\\.|[^\\\\])*?(?:\\\\.|[^\\s~\\\\]))\\1(?=[^~]|$)/;\n\nexport class StrictStrikethroughTokenizer extends Tokenizer {\n override del(src: string): Tokens.Del | undefined {\n const match = STRICT_STRIKETHROUGH_REGEX.exec(src);\n if (!match) {\n return undefined;\n }\n\n const text = match[2];\n return {\n type: \"del\",\n raw: match[0],\n text,\n tokens: this.lexer.inlineTokens(text),\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Tokenizer } from "marked";
|
|
2
|
+
export const STRICT_STRIKETHROUGH_REGEX = /^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/;
|
|
3
|
+
export class StrictStrikethroughTokenizer extends Tokenizer {
|
|
4
|
+
del(src) {
|
|
5
|
+
const match = STRICT_STRIKETHROUGH_REGEX.exec(src);
|
|
6
|
+
if (!match) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const text = match[2];
|
|
10
|
+
return {
|
|
11
|
+
type: "del",
|
|
12
|
+
raw: match[0],
|
|
13
|
+
text,
|
|
14
|
+
tokens: this.lexer.inlineTokens(text),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=strictstrikethroughtokenizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strictstrikethroughtokenizer.js","sourceRoot":"","sources":["../../../src/components/markdown/strictstrikethroughtokenizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,QAAQ,CAAC;AAEhD,MAAM,CAAC,MAAM,0BAA0B,GAAG,8DAA8D,CAAC;AAEzG,MAAM,OAAO,4BAA6B,SAAQ,SAAS;IAChD,GAAG,CAAC,GAAW,EAA0B;QAChD,MAAM,KAAK,GAAG,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,OAAO;YACL,IAAI,EAAE,KAAK;YACX,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YACb,IAAI;YACJ,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC;SACtC,CAAC;IAAA,CACH;CACF","sourcesContent":["import { Tokenizer, type Tokens } from \"marked\";\n\nexport const STRICT_STRIKETHROUGH_REGEX = /^(~~)(?=[^\\s~])((?:\\\\.|[^\\\\])*?(?:\\\\.|[^\\s~\\\\]))\\1(?=[^~]|$)/;\n\nexport class StrictStrikethroughTokenizer extends Tokenizer {\n override del(src: string): Tokens.Del | undefined {\n const match = STRICT_STRIKETHROUGH_REGEX.exec(src);\n if (!match) {\n return undefined;\n }\n\n const text = match[2];\n return {\n type: \"del\",\n raw: match[0],\n text,\n tokens: this.lexer.inlineTokens(text),\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface DefaultTextStyle {
|
|
2
|
+
/** Foreground color function */
|
|
3
|
+
color?: (text: string) => string;
|
|
4
|
+
/** Background color function */
|
|
5
|
+
bgColor?: (text: string) => string;
|
|
6
|
+
/** Bold text */
|
|
7
|
+
bold?: boolean;
|
|
8
|
+
/** Italic text */
|
|
9
|
+
italic?: boolean;
|
|
10
|
+
/** Strikethrough text */
|
|
11
|
+
strikethrough?: boolean;
|
|
12
|
+
/** Underline text */
|
|
13
|
+
underline?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface MarkdownTheme {
|
|
16
|
+
heading: (text: string) => string;
|
|
17
|
+
link: (text: string) => string;
|
|
18
|
+
linkUrl: (text: string) => string;
|
|
19
|
+
code: (text: string) => string;
|
|
20
|
+
codeBlock: (text: string) => string;
|
|
21
|
+
codeBlockBorder: (text: string) => string;
|
|
22
|
+
quote: (text: string) => string;
|
|
23
|
+
quoteBorder: (text: string) => string;
|
|
24
|
+
hr: (text: string) => string;
|
|
25
|
+
listBullet: (text: string) => string;
|
|
26
|
+
bold: (text: string) => string;
|
|
27
|
+
italic: (text: string) => string;
|
|
28
|
+
strikethrough: (text: string) => string;
|
|
29
|
+
underline: (text: string) => string;
|
|
30
|
+
highlightCode?: (code: string, lang?: string) => string[];
|
|
31
|
+
/** Prefix applied to each rendered code block line (default: " ") */
|
|
32
|
+
codeBlockIndent?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface MarkdownOptions {
|
|
35
|
+
/** Preserve source list markers instead of normalizing them. */
|
|
36
|
+
preserveOrderedListMarkers?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface InlineStyleContext {
|
|
39
|
+
applyText: (text: string) => string;
|
|
40
|
+
stylePrefix: string;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","source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AM,KAAK,MAAM,CAAC;IACxC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IAC1D,sEAAsE;IACtE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;CACrB","sourcesContent":["export interface DefaultTextStyle {\n /** Foreground color function */\n color?: (text: string) => string;\n /** Background color function */\n bgColor?: (text: string) => string;\n /** Bold text */\n bold?: boolean;\n /** Italic text */\n italic?: boolean;\n /** Strikethrough text */\n strikethrough?: boolean;\n /** Underline text */\n underline?: boolean;\n}\n\nexport interface MarkdownTheme {\n heading: (text: string) => string;\n link: (text: string) => string;\n linkUrl: (text: string) => string;\n code: (text: string) => string;\n codeBlock: (text: string) => string;\n codeBlockBorder: (text: string) => string;\n quote: (text: string) => string;\n quoteBorder: (text: string) => string;\n hr: (text: string) => string;\n listBullet: (text: string) => string;\n bold: (text: string) => string;\n italic: (text: string) => string;\n strikethrough: (text: string) => string;\n underline: (text: string) => string;\n highlightCode?: (code: string, lang?: string) => string[];\n /** Prefix applied to each rendered code block line (default: \" \") */\n codeBlockIndent?: string;\n}\n\nexport interface MarkdownOptions {\n /** Preserve source list markers instead of normalizing them. */\n preserveOrderedListMarkers?: boolean;\n}\n\nexport interface InlineStyleContext {\n applyText: (text: string) => string;\n stylePrefix: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/markdown/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface DefaultTextStyle {\n /** Foreground color function */\n color?: (text: string) => string;\n /** Background color function */\n bgColor?: (text: string) => string;\n /** Bold text */\n bold?: boolean;\n /** Italic text */\n italic?: boolean;\n /** Strikethrough text */\n strikethrough?: boolean;\n /** Underline text */\n underline?: boolean;\n}\n\nexport interface MarkdownTheme {\n heading: (text: string) => string;\n link: (text: string) => string;\n linkUrl: (text: string) => string;\n code: (text: string) => string;\n codeBlock: (text: string) => string;\n codeBlockBorder: (text: string) => string;\n quote: (text: string) => string;\n quoteBorder: (text: string) => string;\n hr: (text: string) => string;\n listBullet: (text: string) => string;\n bold: (text: string) => string;\n italic: (text: string) => string;\n strikethrough: (text: string) => string;\n underline: (text: string) => string;\n highlightCode?: (code: string, lang?: string) => string[];\n /** Prefix applied to each rendered code block line (default: \" \") */\n codeBlockIndent?: string;\n}\n\nexport interface MarkdownOptions {\n /** Preserve source list markers instead of normalizing them. */\n preserveOrderedListMarkers?: boolean;\n}\n\nexport interface InlineStyleContext {\n applyText: (text: string) => string;\n stylePrefix: string;\n}\n"]}
|
|
@@ -1,97 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Default text styling for markdown content.
|
|
4
|
-
* Applied to all text unless overridden by markdown formatting.
|
|
5
|
-
*/
|
|
6
|
-
export interface DefaultTextStyle {
|
|
7
|
-
/** Foreground color function */
|
|
8
|
-
color?: (text: string) => string;
|
|
9
|
-
/** Background color function */
|
|
10
|
-
bgColor?: (text: string) => string;
|
|
11
|
-
/** Bold text */
|
|
12
|
-
bold?: boolean;
|
|
13
|
-
/** Italic text */
|
|
14
|
-
italic?: boolean;
|
|
15
|
-
/** Strikethrough text */
|
|
16
|
-
strikethrough?: boolean;
|
|
17
|
-
/** Underline text */
|
|
18
|
-
underline?: boolean;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Theme functions for markdown elements.
|
|
22
|
-
* Each function takes text and returns styled text with ANSI codes.
|
|
23
|
-
*/
|
|
24
|
-
export interface MarkdownTheme {
|
|
25
|
-
heading: (text: string) => string;
|
|
26
|
-
link: (text: string) => string;
|
|
27
|
-
linkUrl: (text: string) => string;
|
|
28
|
-
code: (text: string) => string;
|
|
29
|
-
codeBlock: (text: string) => string;
|
|
30
|
-
codeBlockBorder: (text: string) => string;
|
|
31
|
-
quote: (text: string) => string;
|
|
32
|
-
quoteBorder: (text: string) => string;
|
|
33
|
-
hr: (text: string) => string;
|
|
34
|
-
listBullet: (text: string) => string;
|
|
35
|
-
bold: (text: string) => string;
|
|
36
|
-
italic: (text: string) => string;
|
|
37
|
-
strikethrough: (text: string) => string;
|
|
38
|
-
underline: (text: string) => string;
|
|
39
|
-
highlightCode?: (code: string, lang?: string) => string[];
|
|
40
|
-
/** Prefix applied to each rendered code block line (default: " ") */
|
|
41
|
-
codeBlockIndent?: string;
|
|
42
|
-
}
|
|
43
|
-
export interface MarkdownOptions {
|
|
44
|
-
/** Preserve source list markers instead of normalizing them. */
|
|
45
|
-
preserveOrderedListMarkers?: boolean;
|
|
46
|
-
}
|
|
47
|
-
export declare class Markdown implements Component {
|
|
48
|
-
private text;
|
|
49
|
-
private paddingX;
|
|
50
|
-
private paddingY;
|
|
51
|
-
private defaultTextStyle?;
|
|
52
|
-
private theme;
|
|
53
|
-
private options;
|
|
54
|
-
private defaultStylePrefix?;
|
|
55
|
-
private cachedText?;
|
|
56
|
-
private cachedWidth?;
|
|
57
|
-
private cachedLines?;
|
|
58
|
-
constructor(text: string, paddingX: number, paddingY: number, theme: MarkdownTheme, defaultTextStyle?: DefaultTextStyle, options?: MarkdownOptions);
|
|
59
|
-
setText(text: string): void;
|
|
60
|
-
invalidate(): void;
|
|
61
|
-
render(width: number): string[];
|
|
62
|
-
/**
|
|
63
|
-
* Apply default text style to a string.
|
|
64
|
-
* This is the base styling applied to all text content.
|
|
65
|
-
* NOTE: Background color is NOT applied here - it's applied at the padding stage
|
|
66
|
-
* to ensure it extends to the full line width.
|
|
67
|
-
*/
|
|
68
|
-
private applyDefaultStyle;
|
|
69
|
-
private getDefaultStylePrefix;
|
|
70
|
-
private getStylePrefix;
|
|
71
|
-
private getDefaultInlineStyleContext;
|
|
72
|
-
private renderToken;
|
|
73
|
-
private renderInlineTokens;
|
|
74
|
-
private getOrderedListMarker;
|
|
75
|
-
private getUnorderedListMarker;
|
|
76
|
-
/**
|
|
77
|
-
* Render a list with proper nesting support
|
|
78
|
-
*/
|
|
79
|
-
private renderList;
|
|
80
|
-
/**
|
|
81
|
-
* Get the visible width of the longest word in a string.
|
|
82
|
-
*/
|
|
83
|
-
private getLongestWordWidth;
|
|
84
|
-
/**
|
|
85
|
-
* Wrap a table cell to fit into a column.
|
|
86
|
-
*
|
|
87
|
-
* Delegates to wrapTextWithAnsi() so ANSI codes + long tokens are handled
|
|
88
|
-
* consistently with the rest of the renderer.
|
|
89
|
-
*/
|
|
90
|
-
private wrapCellText;
|
|
91
|
-
/**
|
|
92
|
-
* Render a table with width-aware cell wrapping.
|
|
93
|
-
* Cells that don't fit are wrapped to multiple lines.
|
|
94
|
-
*/
|
|
95
|
-
private renderTable;
|
|
96
|
-
}
|
|
1
|
+
export * from "./markdown/index.ts";
|
|
97
2
|
//# sourceMappingURL=markdown.d.ts.map
|