support latex better

This commit is contained in:
lda
2026-08-31 01:26:13 +07:00 Verified
parent ba49cae434
commit 32d628677c
7 changed files with 37 additions and 4 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ from fastapi.testclient import TestClient
from ipython_mcp.app import app as mcp_app
from ipython_shell import App, AppInfo
from ipython_webapp.app import app as web_app
from langchain_demo.ipython_wrapper import get_app_info
from ipython_agent.ipython_wrapper import get_app_info
class AppInfoTests(unittest.IsolatedAsyncioTestCase):
+19 -1
View File
@@ -8,7 +8,7 @@ from ipython_shell.jupyter.messages import (
UnknownJupyterMessage,
)
from st_demo.app import visible_records
from st_demo.ui import event_to_record, preferred_mime
from st_demo.ui import event_to_record, latex_body, preferred_mime
class UIDisplayTests(unittest.TestCase):
@@ -44,6 +44,24 @@ class UIDisplayTests(unittest.TestCase):
self.assertEqual((mime, value), ("text/html", "<b>rich</b>"))
def test_preferred_mime_chooses_latex_before_plain_text(self):
latex = r"\\int_0^1 x^2\\,dx = \\frac{1}{3}"
mime, value = preferred_mime(
{
"text/plain": "integral",
"text/latex": latex,
}
)
self.assertEqual((mime, value), ("text/latex", latex))
def test_latex_body_unwraps_ipython_math_delimiters(self):
self.assertEqual(
latex_body(r"$\displaystyle x^{2} - x - 6$"),
r"\displaystyle x^{2} - x - 6",
)
def test_execute_result_record_keeps_mime_and_repr(self):
event = ExecuteResultMessage(
message_id="message-1",