python-color-math 0.2.1__py3-none-any.whl → 0.2.2__py3-none-any.whl
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.
- color_math/__init__.py +1 -1
- color_math/main.py +1 -1
- color_math/mcp_server.py +109 -70
- {python_color_math-0.2.1.dist-info → python_color_math-0.2.2.dist-info}/METADATA +2 -2
- {python_color_math-0.2.1.dist-info → python_color_math-0.2.2.dist-info}/RECORD +9 -9
- {python_color_math-0.2.1.dist-info → python_color_math-0.2.2.dist-info}/WHEEL +0 -0
- {python_color_math-0.2.1.dist-info → python_color_math-0.2.2.dist-info}/entry_points.txt +0 -0
- {python_color_math-0.2.1.dist-info → python_color_math-0.2.2.dist-info}/licenses/LICENSE +0 -0
- {python_color_math-0.2.1.dist-info → python_color_math-0.2.2.dist-info}/top_level.txt +0 -0
color_math/__init__.py
CHANGED
color_math/main.py
CHANGED
|
@@ -32,7 +32,7 @@ from .parsers.math_parser import describe_math_blocks
|
|
|
32
32
|
from .self_test import run_self_test
|
|
33
33
|
from .tutorial import run_tutorial
|
|
34
34
|
|
|
35
|
-
VERSION = "0.2.
|
|
35
|
+
VERSION = "0.2.2"
|
|
36
36
|
SUPPORTED_EXTENSIONS = {".md", ".markdown", ".qmd", ".ipynb", ".tex", ".latex"}
|
|
37
37
|
DEFAULT_EXCLUDES = {
|
|
38
38
|
".git",
|
color_math/mcp_server.py
CHANGED
|
@@ -149,22 +149,30 @@ def create_mcp_server() -> MCPServer:
|
|
|
149
149
|
normalize_braces=normalize_braces,
|
|
150
150
|
)
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
try:
|
|
153
|
+
clean_expr = expression.strip()
|
|
154
|
+
had_delimiters = clean_expr.startswith("$$") and clean_expr.endswith("$$")
|
|
155
|
+
block_text = clean_expr if had_delimiters else f"$${clean_expr}$$"
|
|
155
156
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
colored = convert_math_block(block_text, pal, opts)
|
|
158
|
+
if not had_delimiters and colored.startswith("$$") and colored.endswith("$$"):
|
|
159
|
+
colored_output = colored[2:-2]
|
|
160
|
+
else:
|
|
161
|
+
colored_output = colored
|
|
161
162
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
return {
|
|
164
|
+
"original": expression,
|
|
165
|
+
"colorized": colored_output,
|
|
166
|
+
"changed": colored_output != expression,
|
|
167
|
+
"theme": theme,
|
|
168
|
+
}
|
|
169
|
+
except Exception as err:
|
|
170
|
+
return {
|
|
171
|
+
"original": expression,
|
|
172
|
+
"error": str(err),
|
|
173
|
+
"changed": False,
|
|
174
|
+
"theme": theme,
|
|
175
|
+
}
|
|
168
176
|
|
|
169
177
|
@server.tool(
|
|
170
178
|
name="colorize_text",
|
|
@@ -199,16 +207,25 @@ def create_mcp_server() -> MCPServer:
|
|
|
199
207
|
normalize_braces=normalize_braces,
|
|
200
208
|
)
|
|
201
209
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
try:
|
|
211
|
+
fmt = format_name if format_name in FORMATS else "markdown"
|
|
212
|
+
result = transform_document(text, fmt, undo=False, palette=pal, options=opts)
|
|
213
|
+
return {
|
|
214
|
+
"format": fmt,
|
|
215
|
+
"theme": theme,
|
|
216
|
+
"original_length": len(text),
|
|
217
|
+
"colorized_length": len(result),
|
|
218
|
+
"changed": result != text,
|
|
219
|
+
"result": result,
|
|
220
|
+
}
|
|
221
|
+
except Exception as err:
|
|
222
|
+
return {
|
|
223
|
+
"format": format_name,
|
|
224
|
+
"theme": theme,
|
|
225
|
+
"error": str(err),
|
|
226
|
+
"changed": False,
|
|
227
|
+
"result": text,
|
|
228
|
+
}
|
|
212
229
|
|
|
213
230
|
@server.tool(
|
|
214
231
|
name="uncolor_text",
|
|
@@ -221,15 +238,23 @@ def create_mcp_server() -> MCPServer:
|
|
|
221
238
|
text: str,
|
|
222
239
|
format_name: str = "markdown",
|
|
223
240
|
) -> dict[str, Any]:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
241
|
+
try:
|
|
242
|
+
fmt = format_name if format_name in FORMATS else "markdown"
|
|
243
|
+
result = transform_document(text, fmt, undo=True)
|
|
244
|
+
return {
|
|
245
|
+
"format": fmt,
|
|
246
|
+
"original_length": len(text),
|
|
247
|
+
"cleaned_length": len(result),
|
|
248
|
+
"changed": result != text,
|
|
249
|
+
"result": result,
|
|
250
|
+
}
|
|
251
|
+
except Exception as err:
|
|
252
|
+
return {
|
|
253
|
+
"format": format_name,
|
|
254
|
+
"error": str(err),
|
|
255
|
+
"changed": False,
|
|
256
|
+
"result": text,
|
|
257
|
+
}
|
|
233
258
|
|
|
234
259
|
@server.tool(
|
|
235
260
|
name="process_file",
|
|
@@ -271,47 +296,56 @@ def create_mcp_server() -> MCPServer:
|
|
|
271
296
|
normalize_braces=normalize_braces,
|
|
272
297
|
)
|
|
273
298
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
299
|
+
try:
|
|
300
|
+
fmt = detect_format(path)
|
|
301
|
+
original_text, raw_bytes = read_utf8(path)
|
|
302
|
+
transformed = transform_document(
|
|
303
|
+
original_text, fmt, undo=undo, palette=pal, options=opts
|
|
304
|
+
)
|
|
279
305
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
306
|
+
changed = transformed != original_text
|
|
307
|
+
diff_output = ""
|
|
308
|
+
if changed:
|
|
309
|
+
diff_lines = list(
|
|
310
|
+
difflib.unified_diff(
|
|
311
|
+
original_text.splitlines(keepends=True),
|
|
312
|
+
transformed.splitlines(keepends=True),
|
|
313
|
+
fromfile=str(path),
|
|
314
|
+
tofile=str(path),
|
|
315
|
+
)
|
|
289
316
|
)
|
|
290
|
-
|
|
291
|
-
diff_output = "".join(diff_lines[:100]) # limit diff length
|
|
317
|
+
diff_output = "".join(diff_lines[:100]) # limit diff length
|
|
292
318
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
319
|
+
written = False
|
|
320
|
+
if changed and in_place:
|
|
321
|
+
new_bytes = encode_utf8(transformed, raw_bytes)
|
|
322
|
+
written = replace_bytes(path, new_bytes, raw_bytes)
|
|
297
323
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
324
|
+
return {
|
|
325
|
+
"file_path": str(path),
|
|
326
|
+
"format": fmt,
|
|
327
|
+
"action": "undo" if undo else "colorize",
|
|
328
|
+
"changed": changed,
|
|
329
|
+
"written_to_disk": written,
|
|
330
|
+
"diff": diff_output if changed else None,
|
|
331
|
+
"message": (
|
|
332
|
+
f"File successfully updated on disk: {path.name}"
|
|
333
|
+
if written
|
|
334
|
+
else (
|
|
335
|
+
f"Dry run complete: changes detected in {path.name}"
|
|
336
|
+
if changed
|
|
337
|
+
else f"No changes needed: {path.name} is already up to date."
|
|
338
|
+
)
|
|
339
|
+
),
|
|
340
|
+
}
|
|
341
|
+
except Exception as err:
|
|
342
|
+
return {
|
|
343
|
+
"file_path": str(path),
|
|
344
|
+
"error": str(err),
|
|
345
|
+
"changed": False,
|
|
346
|
+
"written_to_disk": False,
|
|
347
|
+
"message": f"Error processing {path.name}: {err}",
|
|
348
|
+
}
|
|
315
349
|
|
|
316
350
|
@server.tool(
|
|
317
351
|
name="scan_vault",
|
|
@@ -423,3 +457,8 @@ def run_mcp_server(transport: str = "stdio", **kwargs: Any) -> None:
|
|
|
423
457
|
server.run(transport="streamable-http", **kwargs)
|
|
424
458
|
else:
|
|
425
459
|
raise ValueError(f"Unsupported transport: {transport}. Expected 'stdio', 'sse', or 'streamable-http'.")
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
if __name__ == "__main__":
|
|
463
|
+
run_mcp_server()
|
|
464
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-color-math
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: A fast, local semantic LaTeX colorizer for Markdown, Jupyter, and LaTeX math equations.
|
|
5
5
|
Author: Aditya
|
|
6
6
|
License: MIT License
|
|
@@ -232,7 +232,7 @@ Integrate `color-math` into your git workflow using [pre-commit](https://pre-com
|
|
|
232
232
|
```yaml
|
|
233
233
|
repos:
|
|
234
234
|
- repo: https://github.com/36ty-blip/color-math
|
|
235
|
-
rev: v0.2.
|
|
235
|
+
rev: v0.2.2
|
|
236
236
|
hooks:
|
|
237
237
|
# Formatter: colorizes modified Markdown, LaTeX, and Jupyter files in-place
|
|
238
238
|
- id: color-math
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
color_math/__init__.py,sha256=
|
|
1
|
+
color_math/__init__.py,sha256=Euh1rIsFDxQn3InlS_a08llorK5KF5PzWcazwXq_0HU,401
|
|
2
2
|
color_math/__main__.py,sha256=lU6t3BklI-5H9EdprlceWLr0UcDmfXUu3Th0tjk2ANA,81
|
|
3
3
|
color_math/adapters.py,sha256=wh9oD0ZB1B6iPmLAiW09WgCA0zNnF7SV5diNT5qEynA,11247
|
|
4
4
|
color_math/completions.py,sha256=Q63B8GNn71vdNohbcNs5WmXY8qFGy2T7qT9W-v8XUuQ,11010
|
|
5
5
|
color_math/config.py,sha256=1EnU2kC8GnWERugtg57EAwTits-PFXsHMrKk3UJq_Rk,15081
|
|
6
6
|
color_math/gui.py,sha256=cBsgNToQdZ7mNQ9JA5_jEv7QbELc4NGtgXowTxZ-IWQ,21413
|
|
7
7
|
color_math/io.py,sha256=iCWMY1ufPZzFCwuHTn_axNetek8PRXGNnrmz59CrlGw,1591
|
|
8
|
-
color_math/main.py,sha256=
|
|
8
|
+
color_math/main.py,sha256=p1IFAzkfdRPAu8sRgU2J2nCsLzx97NnQcaIc6xRZxaE,30062
|
|
9
9
|
color_math/mcp.py,sha256=M-JTnWC-xhJemIv2F0ZI4VBF5_MUmasid5B4PIIPgSo,1112
|
|
10
|
-
color_math/mcp_server.py,sha256=
|
|
10
|
+
color_math/mcp_server.py,sha256=AyDjwKVS-7nnaFu4hBNeBrFC542bs7_WuWosgMflvDg,16086
|
|
11
11
|
color_math/py.typed,sha256=bWew9mHgMy8LqMu7RuqQXFXLBxh2CRx0dUbSx-3wE48,27
|
|
12
12
|
color_math/self_test.py,sha256=O-BLG2c_3jXPl9NfuMIKChUxGFih8DtVchdBMI3X2-o,7735
|
|
13
13
|
color_math/tutorial.py,sha256=RuY_ltf6VNa7CTyE1qM8FCyBB1phvJE9YdYD_WEY8xo,9589
|
|
@@ -42,9 +42,9 @@ color_math/utils/latex_helpers.py,sha256=1cFj0zqv68mD-p0vej6yPrhwgqLfAWcIV1rX15F
|
|
|
42
42
|
color_math/utils/spans.py,sha256=3Lq1_bN0s4vSYnS8Rz9tCHoFoJDY6Ff9CzawWWws3YE,3938
|
|
43
43
|
python_color_math/__init__.py,sha256=Dj5YZXXjmNgbyhHKX2YQXvVggtB9UZy9zotLiV2j5So,329
|
|
44
44
|
python_color_math/__main__.py,sha256=cqUM_fV0E6mtuHeBn2MjuozR2rlpev9AfXfcm2hSpi8,90
|
|
45
|
-
python_color_math-0.2.
|
|
46
|
-
python_color_math-0.2.
|
|
47
|
-
python_color_math-0.2.
|
|
48
|
-
python_color_math-0.2.
|
|
49
|
-
python_color_math-0.2.
|
|
50
|
-
python_color_math-0.2.
|
|
45
|
+
python_color_math-0.2.2.dist-info/licenses/LICENSE,sha256=hveQNxqYFqK9Brs_ruH-8shF2D61hIVKYdCjiE-1wMY,1063
|
|
46
|
+
python_color_math-0.2.2.dist-info/METADATA,sha256=pqqDwEh0BkD4zsCaDdYFhhXIzcUHNLaUiQMttOGD6LQ,10900
|
|
47
|
+
python_color_math-0.2.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
48
|
+
python_color_math-0.2.2.dist-info/entry_points.txt,sha256=ZgzGbO_D3csr693Fd-tVGhls6WzsZiOhCau-liSkE_M,130
|
|
49
|
+
python_color_math-0.2.2.dist-info/top_level.txt,sha256=dkfmCdtILDAgX4wwDW5DKHh9YRLt9Mh2RU0gh1mBDDA,29
|
|
50
|
+
python_color_math-0.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|