python-color-math 0.2.13__tar.gz → 0.2.15__tar.gz
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.
- {python_color_math-0.2.13/python_color_math.egg-info → python_color_math-0.2.15}/PKG-INFO +4 -1
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/__init__.py +1 -1
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/ipython.py +74 -22
- {python_color_math-0.2.13 → python_color_math-0.2.15}/pyproject.toml +3 -2
- {python_color_math-0.2.13 → python_color_math-0.2.15/python_color_math.egg-info}/PKG-INFO +4 -1
- {python_color_math-0.2.13 → python_color_math-0.2.15}/python_color_math.egg-info/requires.txt +4 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_ipython.py +2 -2
- {python_color_math-0.2.13 → python_color_math-0.2.15}/.pre-commit-hooks.yaml +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/LICENSE +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/MANIFEST.in +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/README.md +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/__main__.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/adapters.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/colormath.default.json +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/completions.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/config.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/converters/__init__.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/converters/align.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/converters/block.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/converters/derivative.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/converters/equation.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/converters/generic.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/converters/integral.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/converters/limit.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/converters/matrix.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/converters/semantic.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/converters/unicode_converter.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/custom_definitions.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/gui.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/io.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/jupyter.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/main.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/mcp.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/mcp_server.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/__init__.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/alignment.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/braket.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/constants.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/delimiters.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/differentials.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/dimensionless.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/frontmatter.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/latex_spans.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/markdown_scanner.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/math_parser.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/physics.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/scanner.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/taxonomy.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/units.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/variable_hash.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/py.typed +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/self_test.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/tutorial.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/undo.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/unicode.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/utils/__init__.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/utils/coloring.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/utils/latex_helpers.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/utils/spans.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/python_color_math/__init__.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/python_color_math/__main__.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/python_color_math.egg-info/SOURCES.txt +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/python_color_math.egg-info/dependency_links.txt +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/python_color_math.egg-info/entry_points.txt +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/python_color_math.egg-info/top_level.txt +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/setup.cfg +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_adversarial.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_cli.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_config_tolerance.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_custom_definitions.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_extreme_adversarial.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_features.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_frontmatter.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_fuzz.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_gui.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_mcp_hardcore.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_mcp_server.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_physics.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_unicode.py +0 -0
- {python_color_math-0.2.13 → python_color_math-0.2.15}/tests/test_unicode_converter.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-color-math
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.15
|
|
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
|
|
@@ -56,10 +56,13 @@ Requires-Dist: mcp>=1.0.0; extra == "mcp"
|
|
|
56
56
|
Provides-Extra: tutorial
|
|
57
57
|
Requires-Dist: rich>=13.0.0; extra == "tutorial"
|
|
58
58
|
Requires-Dist: questionary>=2.0.0; extra == "tutorial"
|
|
59
|
+
Provides-Extra: jupyter
|
|
60
|
+
Requires-Dist: ipython>=8.0.0; extra == "jupyter"
|
|
59
61
|
Provides-Extra: all
|
|
60
62
|
Requires-Dist: mcp>=1.0.0; extra == "all"
|
|
61
63
|
Requires-Dist: rich>=13.0.0; extra == "all"
|
|
62
64
|
Requires-Dist: questionary>=2.0.0; extra == "all"
|
|
65
|
+
Requires-Dist: ipython>=8.0.0; extra == "all"
|
|
63
66
|
Dynamic: license-file
|
|
64
67
|
|
|
65
68
|
# 🎨 Python Color Math
|
|
@@ -37,10 +37,11 @@ def colormath(
|
|
|
37
37
|
If is_fragment is True, text is treated as raw math without $ delimiters.
|
|
38
38
|
"""
|
|
39
39
|
active_palette = THEMES.get(theme) if theme else palette
|
|
40
|
+
opts = options if options is not None else ColorMathOptions.extended()
|
|
40
41
|
if is_fragment:
|
|
41
|
-
converted = convert_math_block(f"$${text}$$", palette=active_palette, options=
|
|
42
|
+
converted = convert_math_block(f"$${text}$$", palette=active_palette, options=opts)
|
|
42
43
|
return converted[2:-2]
|
|
43
|
-
return convert_text(text, palette=active_palette, options=
|
|
44
|
+
return convert_text(text, palette=active_palette, options=opts)
|
|
44
45
|
|
|
45
46
|
|
|
46
47
|
if HAS_IPYTHON:
|
|
@@ -68,50 +69,101 @@ if HAS_IPYTHON:
|
|
|
68
69
|
super().__init__(shell)
|
|
69
70
|
self._auto_hook_active = False
|
|
70
71
|
self._orig_math_repr = None
|
|
72
|
+
self._options = ColorMathOptions.extended()
|
|
73
|
+
|
|
74
|
+
def _parse_magic_args(self, arg_str: str) -> tuple[str | None, ColorMathOptions, str]:
|
|
75
|
+
"""Parse leading flags (--theme, -v, --variables) without corrupting LaTeX backslashes."""
|
|
76
|
+
theme = None
|
|
77
|
+
opts = ColorMathOptions(
|
|
78
|
+
enable_taxonomy=self._options.enable_taxonomy,
|
|
79
|
+
rainbow_delimiters=self._options.rainbow_delimiters,
|
|
80
|
+
variable_data_flow=self._options.variable_data_flow,
|
|
81
|
+
color_units=self._options.color_units,
|
|
82
|
+
color_differentials=self._options.color_differentials,
|
|
83
|
+
color_braket=self._options.color_braket,
|
|
84
|
+
color_dimensionless=self._options.color_dimensionless,
|
|
85
|
+
color_alignment=self._options.color_alignment,
|
|
86
|
+
color_single_constants=self._options.color_single_constants,
|
|
87
|
+
normalize_braces=self._options.normalize_braces,
|
|
88
|
+
extended_functions=self._options.extended_functions,
|
|
89
|
+
color_quantum_operators=self._options.color_quantum_operators,
|
|
90
|
+
rainbow_bare_braces=self._options.rainbow_bare_braces,
|
|
91
|
+
highlight_unmatched_braces=self._options.highlight_unmatched_braces,
|
|
92
|
+
field=self._options.field,
|
|
93
|
+
)
|
|
94
|
+
raw = arg_str.strip()
|
|
95
|
+
while raw.startswith("-"):
|
|
96
|
+
if raw.startswith("--theme "):
|
|
97
|
+
parts = raw.split(maxsplit=2)
|
|
98
|
+
theme = parts[1]
|
|
99
|
+
raw = parts[2].strip() if len(parts) > 2 else ""
|
|
100
|
+
elif raw.startswith("--variables") or raw.startswith("-v"):
|
|
101
|
+
opts.variable_data_flow = True
|
|
102
|
+
parts = raw.split(maxsplit=1)
|
|
103
|
+
raw = parts[1].strip() if len(parts) > 1 else ""
|
|
104
|
+
elif raw.startswith("--no-variables") or raw.startswith("-nv"):
|
|
105
|
+
opts.variable_data_flow = False
|
|
106
|
+
parts = raw.split(maxsplit=1)
|
|
107
|
+
raw = parts[1].strip() if len(parts) > 1 else ""
|
|
108
|
+
else:
|
|
109
|
+
break
|
|
110
|
+
|
|
111
|
+
return theme, opts, raw
|
|
71
112
|
|
|
72
113
|
@line_magic("color_math")
|
|
73
114
|
@line_magic("colormath")
|
|
74
115
|
def color_math_line(self, line: str) -> Any:
|
|
75
|
-
"""Colorize and display a single LaTeX formula.
|
|
116
|
+
r"""Colorize and display a single LaTeX formula.
|
|
76
117
|
|
|
77
118
|
Usage:
|
|
78
119
|
%color_math \int_0^1 x^2 dx = \frac{1}{3}
|
|
79
120
|
%color_math --theme catppuccin \hat{H}\psi = E\psi
|
|
121
|
+
%color_math -v \hat{H}\psi = E\psi
|
|
80
122
|
"""
|
|
81
|
-
theme =
|
|
82
|
-
raw_line = line.strip()
|
|
83
|
-
if raw_line.startswith("--theme "):
|
|
84
|
-
parts = shlex.split(raw_line)
|
|
85
|
-
if len(parts) >= 3 and parts[0] == "--theme":
|
|
86
|
-
theme = parts[1]
|
|
87
|
-
raw_line = " ".join(parts[2:])
|
|
88
|
-
|
|
123
|
+
theme, opts, raw_line = self._parse_magic_args(line)
|
|
89
124
|
if not raw_line:
|
|
90
125
|
display(Markdown("*Color Math: please provide a LaTeX expression.*"))
|
|
91
126
|
return None
|
|
92
127
|
|
|
93
|
-
|
|
94
|
-
colored = colormath(raw_line, theme=theme, is_fragment=True)
|
|
128
|
+
colored = colormath(raw_line, theme=theme, options=opts, is_fragment=True)
|
|
95
129
|
return Math(colored)
|
|
96
130
|
|
|
97
131
|
@cell_magic("color_math")
|
|
98
132
|
@cell_magic("colormath")
|
|
99
133
|
def color_math_cell(self, line: str, cell: str) -> Any:
|
|
100
|
-
"""Colorize and display a cell containing LaTeX or Markdown math.
|
|
134
|
+
r"""Colorize and display a cell containing LaTeX or Markdown math.
|
|
101
135
|
|
|
102
136
|
Usage:
|
|
103
137
|
%%color_math
|
|
104
|
-
|
|
105
|
-
$$ \
|
|
106
|
-
"""
|
|
107
|
-
theme = None
|
|
108
|
-
args = shlex.split(line.strip()) if line.strip() else []
|
|
109
|
-
if len(args) >= 2 and args[0] == "--theme":
|
|
110
|
-
theme = args[1]
|
|
138
|
+
The equation is:
|
|
139
|
+
$$ \hat{H}\psi = E\psi $$
|
|
111
140
|
|
|
112
|
-
|
|
141
|
+
%%color_math -v
|
|
142
|
+
$$ \hat{H}\psi = E\psi $$
|
|
143
|
+
"""
|
|
144
|
+
theme, opts, _ = self._parse_magic_args(line)
|
|
145
|
+
converted = colormath(cell, theme=theme, options=opts, is_fragment=False)
|
|
113
146
|
display(Markdown(converted))
|
|
114
147
|
|
|
148
|
+
@line_magic("color_math_variables")
|
|
149
|
+
def color_math_variables(self, line: str) -> None:
|
|
150
|
+
"""Toggle variable data-flow hash coloring for Latin symbols (E, m, x, etc.).
|
|
151
|
+
|
|
152
|
+
Usage:
|
|
153
|
+
%color_math_variables on
|
|
154
|
+
%color_math_variables off
|
|
155
|
+
"""
|
|
156
|
+
cmd = line.strip().lower()
|
|
157
|
+
if cmd in ("on", "enable", "1", "true"):
|
|
158
|
+
self._options.variable_data_flow = True
|
|
159
|
+
print("Color Math: Variable data-flow coloring enabled.")
|
|
160
|
+
elif cmd in ("off", "disable", "0", "false"):
|
|
161
|
+
self._options.variable_data_flow = False
|
|
162
|
+
print("Color Math: Variable data-flow coloring disabled.")
|
|
163
|
+
else:
|
|
164
|
+
status = "ENABLED" if self._options.variable_data_flow else "DISABLED"
|
|
165
|
+
print(f"Color Math: Variable data-flow coloring is currently {status}.")
|
|
166
|
+
|
|
115
167
|
@line_magic("color_math_auto")
|
|
116
168
|
def color_math_auto(self, line: str) -> None:
|
|
117
169
|
"""Toggle automatic semantic colorization for all IPython.display.Math outputs.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python-color-math"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.15"
|
|
8
8
|
description = "A fast, local semantic LaTeX colorizer for Markdown, Jupyter, and LaTeX math equations."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -35,7 +35,8 @@ dependencies = []
|
|
|
35
35
|
[project.optional-dependencies]
|
|
36
36
|
mcp = ["mcp>=1.0.0"]
|
|
37
37
|
tutorial = ["rich>=13.0.0", "questionary>=2.0.0"]
|
|
38
|
-
|
|
38
|
+
jupyter = ["ipython>=8.0.0"]
|
|
39
|
+
all = ["mcp>=1.0.0", "rich>=13.0.0", "questionary>=2.0.0", "ipython>=8.0.0"]
|
|
39
40
|
|
|
40
41
|
[project.urls]
|
|
41
42
|
Homepage = "https://github.com/36ty-blip/python-color-math"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-color-math
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.15
|
|
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
|
|
@@ -56,10 +56,13 @@ Requires-Dist: mcp>=1.0.0; extra == "mcp"
|
|
|
56
56
|
Provides-Extra: tutorial
|
|
57
57
|
Requires-Dist: rich>=13.0.0; extra == "tutorial"
|
|
58
58
|
Requires-Dist: questionary>=2.0.0; extra == "tutorial"
|
|
59
|
+
Provides-Extra: jupyter
|
|
60
|
+
Requires-Dist: ipython>=8.0.0; extra == "jupyter"
|
|
59
61
|
Provides-Extra: all
|
|
60
62
|
Requires-Dist: mcp>=1.0.0; extra == "all"
|
|
61
63
|
Requires-Dist: rich>=13.0.0; extra == "all"
|
|
62
64
|
Requires-Dist: questionary>=2.0.0; extra == "all"
|
|
65
|
+
Requires-Dist: ipython>=8.0.0; extra == "all"
|
|
63
66
|
Dynamic: license-file
|
|
64
67
|
|
|
65
68
|
# 🎨 Python Color Math
|
|
@@ -25,12 +25,12 @@ class TestIPythonIntegration(unittest.TestCase):
|
|
|
25
25
|
|
|
26
26
|
# Full markdown test
|
|
27
27
|
md = colormath("Let $f(x) = x^2$.")
|
|
28
|
-
self.assertIn(r"
|
|
28
|
+
self.assertIn(r"\textcolor{#7aa2f7}{f}", md)
|
|
29
29
|
|
|
30
30
|
def test_colormath_display_object(self):
|
|
31
31
|
obj = ColorMath(r"\frac{df}{dx} = f'(x)")
|
|
32
32
|
self.assertIsInstance(obj, Math)
|
|
33
|
-
self.assertIn(r"\textcolor{#7aa2f7}{f'}
|
|
33
|
+
self.assertIn(r"\textcolor{#7aa2f7}{f'}", obj.data)
|
|
34
34
|
|
|
35
35
|
def test_load_and_unload_extension(self):
|
|
36
36
|
load_ipython_extension(self.shell)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/converters/unicode_converter.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_color_math-0.2.13 → python_color_math-0.2.15}/color_math/parsers/markdown_scanner.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_color_math-0.2.13 → python_color_math-0.2.15}/python_color_math.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{python_color_math-0.2.13 → python_color_math-0.2.15}/python_color_math.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{python_color_math-0.2.13 → python_color_math-0.2.15}/python_color_math.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|