In the DSH web chat interface, messages containing mathematical formulas are usually displayed only as plain text. For developers or users who need precise rendering of formula symbols, this is not intuitive enough. The dsh-math-render plugin solves this problem. It takes over the rendering logic for message bubbles and provides real-time formula previews above the input box.
What Is This¶
It is a client-side plugin for rendering LaTeX formulas in the DSH web client. It supports rendering formulas in message bubbles (such as $...$, $$...$$, etc.) and provides a real-time preview of drafts while the user is typing. The plugin is maintained by huanglianqi and licensed under the MIT License.
Installation and Activation¶
Run the following command to install the plugin:
dsh plugin --profile web add dsh-math-render
After installation, restart the harness (to read the bundle list) and refresh the GUI page before the plugin takes effect.
Core Features¶
-
Message Bubble Rendering
The plugin overrides the original user bubble renderer. When messages use$...$,$$...$$,\(...\)or\[...\]syntax, the content is rendered as mathematical formulas in the chat. Assistant replies continue to be rendered by the shell’s KaTeX pipeline and are not affected by this plugin. -
Real-Time Preview
When the editor draft contains formulas, a preview bar appears above the input box, showing the current formula effects. If the draft contains no formulas, the preview bar does not appear. -
Diagnostics Routing
The plugin provides a diagnostics route that can be used to monitor the plugin’s mounting status.
Typical Usage¶
- Input Preview: Enter
$x^2$in the input box, and a preview bar appears above it, showing the square formula. - Message Display: Send a message containing
$E=mc^2$, and the message is rendered as a formula in the chat.
Behavioral Details¶
- No Formula Rendering: If a message does not contain TeX syntax, the rendering behavior is consistent with the official plugin. Plain text is not affected (for example,
*,#, and backticks retain their original meaning). - Escaping: Content inside backticks (
`) is an escape outlet and is not parsed as formulas. - Currency Symbols: A standalone
$symbol (for example, immediately after a number or a space) is not mistakenly interpreted as a mathematical symbol. - Error Handling: TeX with syntax errors is reported by the KaTeX rendering engine, with error information consistent with assistant replies.
- Fallback: If the renderer crashes, the plugin abandons that cell and falls back to the official bubble rendering without corrupting the conversation record.
Limitations and Cautions¶
-
Bubble Style Limitations
The geometric styling (CSS) of bubbles is copied directly and cannot be customized by renaming hashed class names through the plugin. Colors, fonts, and spacing rely on DSH’s--dsh-*/--dsw-*custom properties, which are controlled by the shell. After removing the plugin, bubbles revert to the official style. -
Preview Mode Limitation
The preview is a separate strip, not inline WYSIWYG editing inside the editor. The editor itself is a Lexical editor, and the plugin does not expose inline components. -
Mutually Exclusive Configuration
Thedsh.bundleconfiguration provided by the plugin and the manually writtenfile://line setting cannot be enabled at the same time; they are mutually exclusive Loader sources.
Compatibility¶
- Engine Requirement: Requires
dsh >= 0.1.5-rc.1. - Verified Version: Verified on
dsh 0.1.5-rc.2.
Conclusion¶
dsh-math-render adds basic LaTeX rendering capability to the DSH web client. With simple installation, it improves the display experience of mathematical symbols. For more details, refer to the GitHub repository or the community directory.