Skip to content

Commit 75b600b

Browse files
committed
Update sample to render dark/light mode
1 parent 4201e71 commit 75b600b

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

.github/chatmodes/math.chatmode.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
---
22
description: 'An Ask mode for math-related queries, which can render LaTeX equations.'
3-
tools: ['latex']
3+
tools: ['vscodeAPI', 'latex']
44
---
5-
Actively use the #latex_to_image_markdown tool to render LaTeX equations in your responses as inline markdown images to enhance clarity and visual appeal. This tool is particularly useful for displaying mathematical equations, formulas, and other LaTeX-rendered content in a visually engaging manner.
5+
Actively use the #latex_markdown tool to render LaTeX equations in your responses as inline markdown images to enhance clarity and visual appeal. This tool is particularly useful for displaying mathematical equations, formulas, and other LaTeX-rendered content in a visually engaging manner.
6+
7+
Before invoking #latex_markdown, retrieve the user's theme using the #vscodeAPI to ensure the LaTeX rendering is compatible with their current theme. This will help maintain consistency in the appearance of rendered content across different user interfaces.
8+
9+
Always place the resulting markdown image from the #latex_markdown tool in its own
10+
line to ensure proper formatting and visibility.

samples/latex.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
public class LaTeX(IHttpClientFactory httpFactory)
3030
{
3131
[McpServerTool, Description("Converts LaTeX equations into markdown-formatted images for display inline.")]
32-
public async Task<string> LatexToImageMarkdown(
32+
public async Task<string> LatexMarkdown(
3333
[Description("The LaTeX equation to render.")] string latex,
3434
[Description("Use dark mode by inverting the colors in the output.")] bool darkMode)
3535
{
36-
var colors = darkMode ? @"\bg{black}\fg{white}" : @"\bg{white}\fg{black}";
36+
var colors = darkMode ? @"\fg{white}" : @"\fg{black}";
3737
var query = WebUtility.UrlEncode(@"\small\dpi{300}" + colors + latex);
3838
var url = $"https://latex.codecogs.com/png.image?{query}";
3939
using var client = httpFactory.CreateClient();

src/MCPDemo/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
public class LaTeX(IHttpClientFactory httpFactory)
2222
{
2323
[McpServerTool, Description("Converts LaTeX equations into markdown-formatted images for display inline.")]
24-
public async Task<string> LatexToImageMarkdown(
24+
public async Task<string> LatexMarkdown(
2525
[Description("The LaTeX equation to render.")] string latex,
2626
[Description("Use dark mode by inverting the colors in the output.")] bool darkMode)
2727
{

0 commit comments

Comments
 (0)