dsh-latex
IdentifiedRenders `latex` / `tex` code blocks in the chat as KaTeX formulae, and injects a system-prompt section that tells the model to write `$...$` and `$$...$$` instead of fenced code blocks.
dsh-latex
English | 中文
Make the DeepSeek Harness chat render formulae as formulae, and make the model write LaTeX by default instead of wrapping math in latex fences.
What it fixes
DSH's frontend already renders TeX through KaTeX (MarkdownText in @deepseek-ai/dsh-client-ui-primitives), but:
| Symptom | Cause | What this plugin does |
|---|---|---|
| Formulae show up as a grey code block | The model writes them in ```latex / ```tex fences, which the frontend never renders (only $...$, $$...$$, \(...\), \[...\] and ```math are supported) | The host half states the output contract in the system prompt; the browser half renders legacy latex/tex fences in place |
During streaming the answer shows raw $ and \frac | The frontend deliberately keeps TeX literal while streaming and swaps in KaTeX once the message settles | Left alone (upstream design); renders correctly after settling |
| A few formulae turn into harsh red text | KaTeX strict mode: align, \si{}, \ce{} are outside the supported subset | Forbidden by the prompt; the browser half turns the red error into a readable badge |
| Wide display math overflows the bubble | KaTeX display blocks do not scroll by default | The browser half adds horizontal scrolling and padding |
Install
From GitHub (recommended)
dsh plugin --profile desktop add github:sbVAN/dsh-latex
Restart DeepSeek Harness afterwards, then reload the page once (the browser half needs to load the new bundle).
Development: link a local checkout
# 1. register a link dependency in the profile package.json:
# "dsh-latex": "link:Z:/文件留存/deepseek project/dsh-latex"
# 2. create the junction (the equivalent of pnpm's link:)
New-Item -ItemType Junction `
-Path "$env:USERPROFILE\.dsh\profiles\desktop\node_modules\dsh-latex" `
-Target "Z:\文件留存\deepseek project\dsh-latex"
# 3. append to the profile's cordis.patch.yml:
# - insert:
# - id: latex
# name: dsh-latex
# 4. restart DeepSeek Harness (the host half needs the new composition)
After that the browser half can hot-reload through HMR when hmr.root covers the plugin sources.
Configuration
- insert:
- id: latex
name: dsh-latex
config:
strict: true
compact: false
locale: zh
extraRules:
- Write water as $\mathrm{H_2O}$, never \ce{}.
| Key | Default | Meaning |
|---|---|---|
enabled | true | Disables the prompt section entirely (the browser half still runs) |
locale | auto | zh / en / auto (auto follows DSH_LOCALE, LANG, defaulting to Chinese) |
strict | true | true forbids fenced formulae; false only recommends |
compact | false | Shorter prompt, roughly 1/3 of the tokens |
order | 145 | Section order inside the system prompt (tool guidance owns 100–199) |
extraRules | [] | Extra bullet lines appended to the contract |
Behaviour
Host half (lib/index.js)
Registers ctx.systemPrompt.section({ name: 'dsh-latex:math-output', order, text }) with a contract covering inline $...$, display $$...$$, a ban on fenced formulae, the KaTeX-supported subset (aligned over align, pmatrix/bmatrix/cases, \mathrm{} over \si{}/\pu{}/\ce{}, no \label/\tag), CJK only inside \text{}, and splitting long derivations.
The section is disposed with the plugin fiber, so hot reload cannot leave duplicates. The rendered contract is written to $DSH_HOME/cache/dsh-latex/prompt.txt, mount diagnostics to mounted.json.
Browser half (lib/client.js)
- display-math scrolling and an error badge;
pre > code.language-latex|texgets a preview below it, rendered with the sharedMarkdownText(no bundled KaTeX), source folded by default;- toolbar with show/hide source and copy LaTeX;
- 300 ms debounce over a full scan, orphan cleanup, and root unmount when React replaces nodes.
Limitations
- No math while streaming — that is the frontend's deliberate behaviour and this plugin does not fight it.
- Only
latex/texfences are handled —mathfences are already rendered upstream. - No mhchem —
\ce{}/\pu{}still fail; the prompt routes them to\mathrm{}. - No
conversation.chat.nodetakeover — replacing the assistant renderer means duplicating the whole message structure and breaks on upstream upgrades. - No history rewriting — the prompt constrains future output only; old sessions are covered by the browser half.
Rollback
Remove the junction, drop the insert line from cordis.patch.yml, restore the profile package.json, restart. No DSH file is modified.
License
MIT
Comments
Loading…
Similar plugins
Render LaTeX in the DSH web chat: formulas inside your own message bubble and a live preview of the composer draft.
★ 1
MIT
JavaScript
dsh plugin --profile web add dsh-math-renderby sunnystarye-ui
Codex-style text annotation for conversations: select text, add a quote with your comment, inject it into the composer, and expand sent annotations as a pill.
★ 0
MIT
JavaScript
Aug 24, 2026
dsh plugin --profile web add dsh-plugin-text-quoteby HuanLinOTO
在每次会话开头固定注入一段用户配置的文本上下文(设置页输入框可编辑),作为模型可见的 instructions 注入第一轮请求。 | Injects a user-configured text block as model-visible instructions context at the start of every DSH session (editable from the setti
★ 0
↓ 350/wk
TypeScript
Sep 30, 2026
dsh plugin --profile web add @huanlin/dsh-plugin-preface-contextby bainianlaoyao
Codex-shaped coding tools and agent presets for GPT models on DeepSeek Harness: exec_command, write_stdin, apply_patch and view_image, plus OpenAI Chat Completions and Responses API routes, bridged to
★ 0
JavaScript
Sep 13, 2026
dsh plugin --profile web add dsh-codex-modeby Castor6
Codex-style project-less chats for the DeepSeek Harness: a new chat with no project gets its own local working directory, and keeps DSH's native new-chat screen
★ 0
MIT
JavaScript
Oct 8, 2026
dsh plugin --profile web add dsh-auto-workspaceby 1497105876
在 dsh 官方设置页左侧栏添加「文字注入」:把文字注入系统提示词或会话上下文,内容存于独立文件,支持热加载与历史备份。Text injection into the system prompt or session context from a DSH Settings page, persisted in a standalone file with hot-reload and history.
★ 0
MIT
JavaScript
Sep 30, 2026
dsh plugin --profile web add @gw/dsh-text-inject