@nicomatt69/streamtty 0.0.1
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/LICENSE +21 -0
- package/README.md +471 -0
- package/dist/ai-sdk-adapter.d.ts +113 -0
- package/dist/ai-sdk-adapter.d.ts.map +1 -0
- package/dist/ai-sdk-adapter.js +304 -0
- package/dist/ai-sdk-adapter.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +188 -0
- package/dist/cli.js.map +1 -0
- package/dist/errors.d.ts +131 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +346 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +185 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +350 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +323 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/streaming-parser.d.ts +81 -0
- package/dist/parser/streaming-parser.d.ts.map +1 -0
- package/dist/parser/streaming-parser.js +522 -0
- package/dist/parser/streaming-parser.js.map +1 -0
- package/dist/performance.d.ts +139 -0
- package/dist/performance.d.ts.map +1 -0
- package/dist/performance.js +401 -0
- package/dist/performance.js.map +1 -0
- package/dist/plugins/index.d.ts +6 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +22 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/plugin-system-inline.d.ts +116 -0
- package/dist/plugins/plugin-system-inline.d.ts.map +1 -0
- package/dist/plugins/plugin-system-inline.js +289 -0
- package/dist/plugins/plugin-system-inline.js.map +1 -0
- package/dist/plugins/plugin-system.d.ts +65 -0
- package/dist/plugins/plugin-system.d.ts.map +1 -0
- package/dist/plugins/plugin-system.js +202 -0
- package/dist/plugins/plugin-system.js.map +1 -0
- package/dist/plugins/rehype/harden.d.ts +15 -0
- package/dist/plugins/rehype/harden.d.ts.map +1 -0
- package/dist/plugins/rehype/harden.js +71 -0
- package/dist/plugins/rehype/harden.js.map +1 -0
- package/dist/plugins/rehype/index.d.ts +5 -0
- package/dist/plugins/rehype/index.d.ts.map +1 -0
- package/dist/plugins/rehype/index.js +21 -0
- package/dist/plugins/rehype/index.js.map +1 -0
- package/dist/plugins/remark/index.d.ts +6 -0
- package/dist/plugins/remark/index.d.ts.map +1 -0
- package/dist/plugins/remark/index.js +22 -0
- package/dist/plugins/remark/index.js.map +1 -0
- package/dist/plugins/remark/math.d.ts +7 -0
- package/dist/plugins/remark/math.d.ts.map +1 -0
- package/dist/plugins/remark/math.js +22 -0
- package/dist/plugins/remark/math.js.map +1 -0
- package/dist/plugins/remark/mermaid.d.ts +7 -0
- package/dist/plugins/remark/mermaid.d.ts.map +1 -0
- package/dist/plugins/remark/mermaid.js +19 -0
- package/dist/plugins/remark/mermaid.js.map +1 -0
- package/dist/plugins/types.d.ts +72 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +3 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/renderer/blessed-renderer.d.ts +92 -0
- package/dist/renderer/blessed-renderer.d.ts.map +1 -0
- package/dist/renderer/blessed-renderer.js +610 -0
- package/dist/renderer/blessed-renderer.js.map +1 -0
- package/dist/renderers/index.d.ts +7 -0
- package/dist/renderers/index.d.ts.map +1 -0
- package/dist/renderers/index.js +21 -0
- package/dist/renderers/index.js.map +1 -0
- package/dist/renderers/math-renderer.d.ts +49 -0
- package/dist/renderers/math-renderer.d.ts.map +1 -0
- package/dist/renderers/math-renderer.js +193 -0
- package/dist/renderers/math-renderer.js.map +1 -0
- package/dist/renderers/mermaid-ascii.d.ts +14 -0
- package/dist/renderers/mermaid-ascii.d.ts.map +1 -0
- package/dist/renderers/mermaid-ascii.js +260 -0
- package/dist/renderers/mermaid-ascii.js.map +1 -0
- package/dist/renderers/mermaid-renderer.d.ts +79 -0
- package/dist/renderers/mermaid-renderer.d.ts.map +1 -0
- package/dist/renderers/mermaid-renderer.js +298 -0
- package/dist/renderers/mermaid-renderer.js.map +1 -0
- package/dist/renderers/shiki-ansi.d.ts +48 -0
- package/dist/renderers/shiki-ansi.d.ts.map +1 -0
- package/dist/renderers/shiki-ansi.js +206 -0
- package/dist/renderers/shiki-ansi.js.map +1 -0
- package/dist/renderers/table-ascii.d.ts +30 -0
- package/dist/renderers/table-ascii.d.ts.map +1 -0
- package/dist/renderers/table-ascii.js +243 -0
- package/dist/renderers/table-ascii.js.map +1 -0
- package/dist/renderers/table-renderer.d.ts +49 -0
- package/dist/renderers/table-renderer.d.ts.map +1 -0
- package/dist/renderers/table-renderer.js +224 -0
- package/dist/renderers/table-renderer.js.map +1 -0
- package/dist/renderers/unicode-math.d.ts +29 -0
- package/dist/renderers/unicode-math.d.ts.map +1 -0
- package/dist/renderers/unicode-math.js +181 -0
- package/dist/renderers/unicode-math.js.map +1 -0
- package/dist/security/ansi-sanitizer.d.ts +71 -0
- package/dist/security/ansi-sanitizer.d.ts.map +1 -0
- package/dist/security/ansi-sanitizer.js +275 -0
- package/dist/security/ansi-sanitizer.js.map +1 -0
- package/dist/security/chunk-processor.d.ts +81 -0
- package/dist/security/chunk-processor.d.ts.map +1 -0
- package/dist/security/chunk-processor.js +297 -0
- package/dist/security/chunk-processor.js.map +1 -0
- package/dist/security/index.d.ts +6 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +22 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/input-validator.d.ts +55 -0
- package/dist/security/input-validator.d.ts.map +1 -0
- package/dist/security/input-validator.js +201 -0
- package/dist/security/input-validator.js.map +1 -0
- package/dist/stream-protocol.d.ts +61 -0
- package/dist/stream-protocol.d.ts.map +1 -0
- package/dist/stream-protocol.js +214 -0
- package/dist/stream-protocol.js.map +1 -0
- package/dist/streamdown-compat.d.ts +74 -0
- package/dist/streamdown-compat.d.ts.map +1 -0
- package/dist/streamdown-compat.js +241 -0
- package/dist/streamdown-compat.js.map +1 -0
- package/dist/streaming/stream-stats.d.ts +97 -0
- package/dist/streaming/stream-stats.d.ts.map +1 -0
- package/dist/streaming/stream-stats.js +217 -0
- package/dist/streaming/stream-stats.js.map +1 -0
- package/dist/streaming-integration.d.ts +71 -0
- package/dist/streaming-integration.d.ts.map +1 -0
- package/dist/streaming-integration.js +194 -0
- package/dist/streaming-integration.js.map +1 -0
- package/dist/themes/index.d.ts +59 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/index.js +122 -0
- package/dist/themes/index.js.map +1 -0
- package/dist/types/index.d.ts +222 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/plugin-types.d.ts +5 -0
- package/dist/types/plugin-types.d.ts.map +1 -0
- package/dist/types/plugin-types.js +6 -0
- package/dist/types/plugin-types.js.map +1 -0
- package/dist/types/stream-events.d.ts +71 -0
- package/dist/types/stream-events.d.ts.map +1 -0
- package/dist/types/stream-events.js +10 -0
- package/dist/types/stream-events.js.map +1 -0
- package/dist/utils/blessed-syntax-highlighter.d.ts +124 -0
- package/dist/utils/blessed-syntax-highlighter.d.ts.map +1 -0
- package/dist/utils/blessed-syntax-highlighter.js +440 -0
- package/dist/utils/blessed-syntax-highlighter.js.map +1 -0
- package/dist/utils/enhanced-table-renderer.d.ts +77 -0
- package/dist/utils/enhanced-table-renderer.d.ts.map +1 -0
- package/dist/utils/enhanced-table-renderer.js +376 -0
- package/dist/utils/enhanced-table-renderer.js.map +1 -0
- package/dist/utils/formatting.d.ts +100 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/formatting.js +220 -0
- package/dist/utils/formatting.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/math-unicode-renderer.d.ts +38 -0
- package/dist/utils/math-unicode-renderer.d.ts.map +1 -0
- package/dist/utils/math-unicode-renderer.js +380 -0
- package/dist/utils/math-unicode-renderer.js.map +1 -0
- package/dist/utils/mermaid-ascii-renderer.d.ts +20 -0
- package/dist/utils/mermaid-ascii-renderer.d.ts.map +1 -0
- package/dist/utils/mermaid-ascii-renderer.js +325 -0
- package/dist/utils/mermaid-ascii-renderer.js.map +1 -0
- package/dist/utils/mermaid-ascii.d.ts +53 -0
- package/dist/utils/mermaid-ascii.d.ts.map +1 -0
- package/dist/utils/mermaid-ascii.js +181 -0
- package/dist/utils/mermaid-ascii.js.map +1 -0
- package/dist/utils/shiki-ansi-renderer.d.ts +29 -0
- package/dist/utils/shiki-ansi-renderer.d.ts.map +1 -0
- package/dist/utils/shiki-ansi-renderer.js +354 -0
- package/dist/utils/shiki-ansi-renderer.js.map +1 -0
- package/dist/utils/syntax-highlighter.d.ts +87 -0
- package/dist/utils/syntax-highlighter.d.ts.map +1 -0
- package/dist/utils/syntax-highlighter.js +265 -0
- package/dist/utils/syntax-highlighter.js.map +1 -0
- package/dist/utils/table-formatter-inline.d.ts +37 -0
- package/dist/utils/table-formatter-inline.d.ts.map +1 -0
- package/dist/utils/table-formatter-inline.js +337 -0
- package/dist/utils/table-formatter-inline.js.map +1 -0
- package/dist/utils/table.d.ts +35 -0
- package/dist/utils/table.d.ts.map +1 -0
- package/dist/utils/table.js +197 -0
- package/dist/utils/table.js.map +1 -0
- package/dist/widgets/stream-indicator.d.ts +130 -0
- package/dist/widgets/stream-indicator.d.ts.map +1 -0
- package/dist/widgets/stream-indicator.js +276 -0
- package/dist/widgets/stream-indicator.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LaTeX to Unicode Math Renderer
|
|
4
|
+
* Converts LaTeX math expressions to beautiful Unicode representations
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.renderMathToUnicode = renderMathToUnicode;
|
|
8
|
+
exports.renderMathBlock = renderMathBlock;
|
|
9
|
+
exports.containsMath = containsMath;
|
|
10
|
+
exports.extractMath = extractMath;
|
|
11
|
+
exports.replaceMathInText = replaceMathInText;
|
|
12
|
+
exports.formatMathExpression = formatMathExpression;
|
|
13
|
+
// Comprehensive Unicode math symbol mappings
|
|
14
|
+
const UNICODE_MAP = {
|
|
15
|
+
// Superscripts
|
|
16
|
+
'\\^0': '⁰',
|
|
17
|
+
'\\^1': '¹',
|
|
18
|
+
'\\^2': '²',
|
|
19
|
+
'\\^3': '³',
|
|
20
|
+
'\\^4': '⁴',
|
|
21
|
+
'\\^5': '⁵',
|
|
22
|
+
'\\^6': '⁶',
|
|
23
|
+
'\\^7': '⁷',
|
|
24
|
+
'\\^8': '⁸',
|
|
25
|
+
'\\^9': '⁹',
|
|
26
|
+
'\\^+': '⁺',
|
|
27
|
+
'\\^-': '⁻',
|
|
28
|
+
'\\^=': '⁼',
|
|
29
|
+
'\\^(': '⁽',
|
|
30
|
+
'\\^)': '⁾',
|
|
31
|
+
// Subscripts
|
|
32
|
+
'_0': '₀',
|
|
33
|
+
'_1': '₁',
|
|
34
|
+
'_2': '₂',
|
|
35
|
+
'_3': '₃',
|
|
36
|
+
'_4': '₄',
|
|
37
|
+
'_5': '₅',
|
|
38
|
+
'_6': '₆',
|
|
39
|
+
'_7': '₇',
|
|
40
|
+
'_8': '₈',
|
|
41
|
+
'_9': '₉',
|
|
42
|
+
'_+': '₊',
|
|
43
|
+
'_-': '₋',
|
|
44
|
+
'_=': '₌',
|
|
45
|
+
'_(': '₍',
|
|
46
|
+
'_)': '₎',
|
|
47
|
+
// Greek letters (lowercase)
|
|
48
|
+
'alpha': 'α',
|
|
49
|
+
'beta': 'β',
|
|
50
|
+
'gamma': 'γ',
|
|
51
|
+
'delta': 'δ',
|
|
52
|
+
'epsilon': 'ε',
|
|
53
|
+
'zeta': 'ζ',
|
|
54
|
+
'eta': 'η',
|
|
55
|
+
'theta': 'θ',
|
|
56
|
+
'iota': 'ι',
|
|
57
|
+
'kappa': 'κ',
|
|
58
|
+
'lambda': 'λ',
|
|
59
|
+
'mu': 'μ',
|
|
60
|
+
'nu': 'ν',
|
|
61
|
+
'xi': 'ξ',
|
|
62
|
+
'omicron': 'ο',
|
|
63
|
+
'pi': 'π',
|
|
64
|
+
'rho': 'ρ',
|
|
65
|
+
'sigma': 'σ',
|
|
66
|
+
'tau': 'τ',
|
|
67
|
+
'upsilon': 'υ',
|
|
68
|
+
'phi': 'φ',
|
|
69
|
+
'chi': 'χ',
|
|
70
|
+
'psi': 'ψ',
|
|
71
|
+
'omega': 'ω',
|
|
72
|
+
// Greek letters (uppercase)
|
|
73
|
+
'Alpha': 'Α',
|
|
74
|
+
'Beta': 'Β',
|
|
75
|
+
'Gamma': 'Γ',
|
|
76
|
+
'Delta': 'Δ',
|
|
77
|
+
'Epsilon': 'Ε',
|
|
78
|
+
'Zeta': 'Ζ',
|
|
79
|
+
'Eta': 'Η',
|
|
80
|
+
'Theta': 'Θ',
|
|
81
|
+
'Iota': 'Ι',
|
|
82
|
+
'Kappa': 'Κ',
|
|
83
|
+
'Lambda': 'Λ',
|
|
84
|
+
'Mu': 'Μ',
|
|
85
|
+
'Nu': 'Ν',
|
|
86
|
+
'Xi': 'Ξ',
|
|
87
|
+
'Omicron': 'Ο',
|
|
88
|
+
'Pi': 'Π',
|
|
89
|
+
'Rho': 'Ρ',
|
|
90
|
+
'Sigma': 'Σ',
|
|
91
|
+
'Tau': 'Τ',
|
|
92
|
+
'Upsilon': 'Υ',
|
|
93
|
+
'Phi': 'Φ',
|
|
94
|
+
'Chi': 'Χ',
|
|
95
|
+
'Psi': 'Ψ',
|
|
96
|
+
'Omega': 'Ω',
|
|
97
|
+
// Math operators
|
|
98
|
+
'sqrt': '√',
|
|
99
|
+
'cbrt': '∛',
|
|
100
|
+
'fourthroot': '∜',
|
|
101
|
+
'integral': '∫',
|
|
102
|
+
'sum': '∑',
|
|
103
|
+
'prod': '∏',
|
|
104
|
+
'coprod': '∐',
|
|
105
|
+
'infty': '∞',
|
|
106
|
+
'partial': '∂',
|
|
107
|
+
'nabla': '∇',
|
|
108
|
+
'approx': '≈',
|
|
109
|
+
'ne': '≠',
|
|
110
|
+
'leq': '≤',
|
|
111
|
+
'geq': '≥',
|
|
112
|
+
'll': '≪',
|
|
113
|
+
'gg': '≫',
|
|
114
|
+
'prec': '≺',
|
|
115
|
+
'succ': '≻',
|
|
116
|
+
'in': '∈',
|
|
117
|
+
'notin': '∉',
|
|
118
|
+
'subset': '⊂',
|
|
119
|
+
'supset': '⊃',
|
|
120
|
+
'subseteq': '⊆',
|
|
121
|
+
'supseteq': '⊇',
|
|
122
|
+
'cup': '∪',
|
|
123
|
+
'cap': '∩',
|
|
124
|
+
'setminus': '∖',
|
|
125
|
+
'cdot': '·',
|
|
126
|
+
'times': '×',
|
|
127
|
+
'div': '÷',
|
|
128
|
+
'pm': '±',
|
|
129
|
+
'mp': '∓',
|
|
130
|
+
'ast': '∗',
|
|
131
|
+
'circ': '∘',
|
|
132
|
+
'bullet': '•',
|
|
133
|
+
'dagger': '†',
|
|
134
|
+
'ddagger': '‡',
|
|
135
|
+
'angle': '∠',
|
|
136
|
+
'parallel': '∥',
|
|
137
|
+
'perp': '⊥',
|
|
138
|
+
'checkmark': '✓',
|
|
139
|
+
'xmark': '✗',
|
|
140
|
+
// Relations
|
|
141
|
+
'equiv': '≡',
|
|
142
|
+
'sim': '∼',
|
|
143
|
+
'simeq': '≃',
|
|
144
|
+
'cong': '≅',
|
|
145
|
+
'asymp': '≍',
|
|
146
|
+
'propto': '∝',
|
|
147
|
+
'models': '⊨',
|
|
148
|
+
'vdash': '⊢',
|
|
149
|
+
'dashv': '⊣',
|
|
150
|
+
// Logical operators
|
|
151
|
+
'forall': '∀',
|
|
152
|
+
'exists': '∃',
|
|
153
|
+
'neg': '¬',
|
|
154
|
+
'land': '∧',
|
|
155
|
+
'lor': '∨',
|
|
156
|
+
'implies': '⟹',
|
|
157
|
+
'iff': '⟺',
|
|
158
|
+
'bot': '⊥',
|
|
159
|
+
'top': '⊤',
|
|
160
|
+
// Arrows
|
|
161
|
+
'to': '→',
|
|
162
|
+
'rightarrow': '→',
|
|
163
|
+
'leftarrow': '←',
|
|
164
|
+
'leftrightarrow': '↔',
|
|
165
|
+
'Rightarrow': '⇒',
|
|
166
|
+
'Leftarrow': '⇐',
|
|
167
|
+
'Leftrightarrow': '⇔',
|
|
168
|
+
'mapsto': '↦',
|
|
169
|
+
'longmapsto': '⟼',
|
|
170
|
+
'uparrow': '↑',
|
|
171
|
+
'downarrow': '↓',
|
|
172
|
+
'updownarrow': '↕',
|
|
173
|
+
'Uparrow': '⇑',
|
|
174
|
+
'Downarrow': '⇓',
|
|
175
|
+
'Updownarrow': '⇕',
|
|
176
|
+
'nearrow': '↗',
|
|
177
|
+
'searrow': '↘',
|
|
178
|
+
'swarrow': '↙',
|
|
179
|
+
'nwarrow': '↖',
|
|
180
|
+
// Mathematical operators
|
|
181
|
+
'frac': '⁄', // Used in fractions
|
|
182
|
+
'lfloor': '⌊',
|
|
183
|
+
'rfloor': '⌋',
|
|
184
|
+
'lceil': '⌈',
|
|
185
|
+
'rceil': '⌉',
|
|
186
|
+
// Miscellaneous
|
|
187
|
+
'varphi': 'φ',
|
|
188
|
+
'vartheta': 'ϑ',
|
|
189
|
+
'ell': 'ℓ',
|
|
190
|
+
'Re': 'ℜ',
|
|
191
|
+
'Im': 'ℑ',
|
|
192
|
+
'wp': '℘',
|
|
193
|
+
'wr': '≀',
|
|
194
|
+
'heartsuit': '♡',
|
|
195
|
+
'diamondsuit': '♢',
|
|
196
|
+
'clubsuit': '♣',
|
|
197
|
+
'spadesuit': '♠',
|
|
198
|
+
'flatsuit': '♭',
|
|
199
|
+
'naturalsuit': '♮',
|
|
200
|
+
'sharpsuit': '♯',
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Render LaTeX expression to Unicode inline format
|
|
204
|
+
*/
|
|
205
|
+
function renderMathToUnicode(latex) {
|
|
206
|
+
if (!latex || latex.length === 0) {
|
|
207
|
+
return latex;
|
|
208
|
+
}
|
|
209
|
+
let result = latex;
|
|
210
|
+
// Replace LaTeX commands with Unicode equivalents
|
|
211
|
+
for (const [latex_code, unicode] of Object.entries(UNICODE_MAP)) {
|
|
212
|
+
// Handle both \cmd and cmd format
|
|
213
|
+
const patterns = [
|
|
214
|
+
new RegExp(`\\\\${latex_code}\\b`, 'g'),
|
|
215
|
+
new RegExp(`\\b${latex_code}\\b`, 'g'),
|
|
216
|
+
];
|
|
217
|
+
for (const pattern of patterns) {
|
|
218
|
+
result = result.replace(pattern, unicode);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
// Handle special cases
|
|
222
|
+
// Exponents: x^2 → x²
|
|
223
|
+
result = result.replace(/\^(\d)/g, (_, digit) => {
|
|
224
|
+
const superscripts = ['⁰', '¹', '²', '³', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹'];
|
|
225
|
+
return superscripts[parseInt(digit)] || _;
|
|
226
|
+
});
|
|
227
|
+
// Subscripts: x_i → xᵢ
|
|
228
|
+
result = result.replace(/_(\d)/g, (_, digit) => {
|
|
229
|
+
const subscripts = ['₀', '₁', '₂', '₃', '₄', '₅', '₆', '₇', '₈', '₉'];
|
|
230
|
+
return subscripts[parseInt(digit)] || _;
|
|
231
|
+
});
|
|
232
|
+
// Handle sqrt with braces: \sqrt{x} → √x
|
|
233
|
+
result = result.replace(/√\{([^}]+)\}/g, '√($1)');
|
|
234
|
+
// Handle fractions (simple inline): x/y stays as x/y (can't do real fractions inline)
|
|
235
|
+
// But we can indicate it better with slash
|
|
236
|
+
result = result.replace(/\\frac\{([^}]+)\}\{([^}]+)\}/g, '($1)/($2)');
|
|
237
|
+
// Handle parentheses variants
|
|
238
|
+
result = result.replace(/\\left\(/g, '(');
|
|
239
|
+
result = result.replace(/\\right\)/g, ')');
|
|
240
|
+
result = result.replace(/\\left\[/g, '[');
|
|
241
|
+
result = result.replace(/\\right\]/g, ']');
|
|
242
|
+
result = result.replace(/\\left\{/g, '{');
|
|
243
|
+
result = result.replace(/\\right\}/g, '}');
|
|
244
|
+
// Remove remaining LaTeX command syntax
|
|
245
|
+
result = result.replace(/\\[a-zA-Z]+/g, '');
|
|
246
|
+
// Clean up whitespace
|
|
247
|
+
result = result.replace(/\s+/g, ' ').trim();
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Render math in block format with box
|
|
252
|
+
*/
|
|
253
|
+
function renderMathBlock(latex, options) {
|
|
254
|
+
const width = options?.width || 60;
|
|
255
|
+
const style = options?.boxStyle || 'rounded';
|
|
256
|
+
const unicode = renderMathToUnicode(latex);
|
|
257
|
+
// Wrap in a box for display
|
|
258
|
+
const lines = wrapText(unicode, width - 4);
|
|
259
|
+
const topBorder = style === 'rounded'
|
|
260
|
+
? '┌' + '─'.repeat(width - 2) + '┐'
|
|
261
|
+
: '┏' + '━'.repeat(width - 2) + '┓';
|
|
262
|
+
const bottomBorder = style === 'rounded'
|
|
263
|
+
? '└' + '─'.repeat(width - 2) + '┘'
|
|
264
|
+
: '┗' + '━'.repeat(width - 2) + '┛';
|
|
265
|
+
const vertBorder = style === 'rounded' ? '│' : '┃';
|
|
266
|
+
let result = topBorder + '\n';
|
|
267
|
+
for (const line of lines) {
|
|
268
|
+
const padded = line.padEnd(width - 4);
|
|
269
|
+
result += vertBorder + ' ' + padded + ' ' + vertBorder + '\n';
|
|
270
|
+
}
|
|
271
|
+
result += bottomBorder;
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Wrap text to fit within width
|
|
276
|
+
*/
|
|
277
|
+
function wrapText(text, width) {
|
|
278
|
+
if (text.length <= width) {
|
|
279
|
+
return [text];
|
|
280
|
+
}
|
|
281
|
+
const lines = [];
|
|
282
|
+
const words = text.split(' ');
|
|
283
|
+
let currentLine = '';
|
|
284
|
+
for (const word of words) {
|
|
285
|
+
if ((currentLine + ' ' + word).length <= width) {
|
|
286
|
+
currentLine += (currentLine ? ' ' : '') + word;
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
if (currentLine)
|
|
290
|
+
lines.push(currentLine);
|
|
291
|
+
currentLine = word;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (currentLine)
|
|
295
|
+
lines.push(currentLine);
|
|
296
|
+
return lines;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Detect if text contains LaTeX math
|
|
300
|
+
*/
|
|
301
|
+
function containsMath(text) {
|
|
302
|
+
// Check for inline math: $...$
|
|
303
|
+
// Check for display math: $$...$$
|
|
304
|
+
// Check for LaTeX commands: \...
|
|
305
|
+
return /\$.*?\$|\\\w+|_\{|_\d|\^\{|\^\d/.test(text);
|
|
306
|
+
}
|
|
307
|
+
function extractMath(text) {
|
|
308
|
+
const matches = [];
|
|
309
|
+
const blockRanges = [];
|
|
310
|
+
// Find display math: $$...$$ (non-greedy to handle multiple blocks)
|
|
311
|
+
// Use negative lookahead/lookbehind to avoid matching triple $$$
|
|
312
|
+
const blockRegex = /\$\$((?:(?!\$\$).)+)\$\$/gs;
|
|
313
|
+
let blockMatch;
|
|
314
|
+
while ((blockMatch = blockRegex.exec(text)) !== null) {
|
|
315
|
+
const start = blockMatch.index;
|
|
316
|
+
const end = blockMatch.index + blockMatch[0].length;
|
|
317
|
+
blockRanges.push({ start, end });
|
|
318
|
+
matches.push({
|
|
319
|
+
type: 'block',
|
|
320
|
+
content: blockMatch[1],
|
|
321
|
+
start,
|
|
322
|
+
end,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
// Find inline math: $...$ (non-greedy, avoiding blocks)
|
|
326
|
+
// Use negative lookahead to ensure we don't match $$
|
|
327
|
+
const inlineRegex = /\$(?!\$)((?:(?!\$).)+)\$(?!\$)/gs;
|
|
328
|
+
let inlineMatch;
|
|
329
|
+
while ((inlineMatch = inlineRegex.exec(text)) !== null) {
|
|
330
|
+
const matchStart = inlineMatch.index;
|
|
331
|
+
const matchEnd = matchStart + inlineMatch[0].length;
|
|
332
|
+
// Skip if this overlaps with any block match (more efficient than .some())
|
|
333
|
+
const overlapsBlock = blockRanges.some(range => matchStart >= range.start && matchStart < range.end);
|
|
334
|
+
if (!overlapsBlock) {
|
|
335
|
+
matches.push({
|
|
336
|
+
type: 'inline',
|
|
337
|
+
content: inlineMatch[1],
|
|
338
|
+
start: matchStart,
|
|
339
|
+
end: matchEnd,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
// Sort by position
|
|
344
|
+
matches.sort((a, b) => a.start - b.start);
|
|
345
|
+
return matches;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Replace math in text with rendered Unicode
|
|
349
|
+
*/
|
|
350
|
+
function replaceMathInText(text) {
|
|
351
|
+
const matches = extractMath(text);
|
|
352
|
+
if (matches.length === 0) {
|
|
353
|
+
return text;
|
|
354
|
+
}
|
|
355
|
+
let result = '';
|
|
356
|
+
let lastEnd = 0;
|
|
357
|
+
for (const match of matches) {
|
|
358
|
+
// Add text before match
|
|
359
|
+
result += text.slice(lastEnd, match.start);
|
|
360
|
+
// Add rendered math (without $ delimiters)
|
|
361
|
+
result += renderMathToUnicode(match.content);
|
|
362
|
+
lastEnd = match.end;
|
|
363
|
+
}
|
|
364
|
+
// Add remaining text
|
|
365
|
+
result += text.slice(lastEnd);
|
|
366
|
+
return result;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Format math expression with pretty printing
|
|
370
|
+
*/
|
|
371
|
+
function formatMathExpression(latex) {
|
|
372
|
+
// Handle common patterns for prettier output
|
|
373
|
+
let formatted = latex;
|
|
374
|
+
// e.g., "x^2 + y^2 = z^2" → "x² + y² = z²"
|
|
375
|
+
formatted = formatted.replace(/(\w)\^(\d+)/g, '$1' + '²'.repeat(Number('$2')));
|
|
376
|
+
// Render to Unicode
|
|
377
|
+
formatted = renderMathToUnicode(formatted);
|
|
378
|
+
return formatted;
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=math-unicode-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math-unicode-renderer.js","sourceRoot":"","sources":["../../src/utils/math-unicode-renderer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA4MH,kDAwDC;AAKD,0CAgCC;AA+BD,oCAKC;AAYD,kCA+CC;AAKD,8CAwBC;AAKD,oDAWC;AAnbD,6CAA6C;AAC7C,MAAM,WAAW,GAAG;IAClB,eAAe;IACf,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IAEX,aAAa;IACb,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IAET,4BAA4B;IAC5B,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,GAAG;IACd,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,G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AG,CAAC;IACtB,CAAC;IAED,qBAAqB;IACrB,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAE9B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,KAAa;IAChD,6CAA6C;IAC7C,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,2CAA2C;IAC3C,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE/E,oBAAoB;IACpB,SAAS,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAE3C,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid to ASCII Art Renderer
|
|
3
|
+
* Converts Mermaid diagram syntax to beautiful ASCII art
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Main rendering function
|
|
7
|
+
*/
|
|
8
|
+
export declare function renderMermaidToASCII(mermaidCode: string, options?: {
|
|
9
|
+
maxWidth?: number;
|
|
10
|
+
boxStyle?: 'simple' | 'rounded';
|
|
11
|
+
}): string;
|
|
12
|
+
/**
|
|
13
|
+
* Detect if code is Mermaid syntax
|
|
14
|
+
*/
|
|
15
|
+
export declare function isMermaidCode(code: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Format mermaid code for better readability
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatMermaidCode(code: string): string;
|
|
20
|
+
//# sourceMappingURL=mermaid-ascii-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid-ascii-renderer.d.ts","sourceRoot":"","sources":["../../src/utils/mermaid-ascii-renderer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmUH;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,GAC/D,MAAM,CAuBR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAoBnD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAStD"}
|