Preface¶
When reading conversations or documents containing formulas in the DSH Web UI, selecting and copying a KaTeX-rendered mathematical expression often results in visual glyph text in the clipboard (e.g., the superscript x^2 becomes x2), rather than editable TeX that can be pasted into papers or Markdown. For developers who need to extract formulas from agent outputs, take notes, or integrate with LaTeX workflows, this is a daily friction point. The following introduces the client-side plugin dsh-math-copy (maintainer YizhouLouisLu), which intercepts copy behavior, replaces formulas within the selection with delimited LaTeX, and writes it to the clipboard.
What is this¶
dsh-math-copy is a client-side plugin for DeepSeek Harness: it listens for the copy event in the browser. When the user’s selection intersects with at least one KaTeX formula, it replaces the visible glyphs with the application/x-tex annotation preserved in the formula’s accessibility subtree. It then wraps the result with inline or block mathematical delimiters according to configuration and writes it to text/plain (optionally rewriting text/html as well). If the selection contains no formulas, it does nothing, behaving consistently with the system’s default copy.
The plugin belongs to the community ecosystem; see skillhub.cn for the directory page, and GitHub for source code and documentation. DSH itself follows an “everything is a plugin” extension approach. The community directory is an independent site and has no official affiliation with DeepSeek or 幻方 (High-Flyer).
Core Features¶
Difference from Default Copy¶
The Web UI uses KaTeX to render mathematical expressions. The DOM structure is roughly: an outer katex container, an inner katex-mathml containing <annotation encoding="application/x-tex">…</annotation>, and a separate katex-html carrying the visible glyphs. The browser copies based on visible layout, resulting in glyph text. This plugin clones the selection, identifies intersecting formula nodes, replaces them block-by-block with TeX, and cancels the default copy behavior.
Selection Behavior¶
- Selection covers a complete formula or multiple formulas: The clipboard contains the corresponding LaTeX (with configured delimiters).
- Selection covers only a part of a formula: It still outputs the TeX for the entire formula to avoid half-broken glyphs.
- Selection contains no mathematical content: The plugin does not intervene.
Configurable Options¶
Modify these in Plugins → dsh-math-copy → math-copy row → configuration. Settings are written to the Cordis patch of the current profile and persist after restarting DSH.
| Field | Default | Meaning |
|---|---|---|
| Inline formula delimiter | "$" |
Wrapper for inline formulas; if empty, outputs raw TeX only. |
| Display formula delimiter | "$$" |
Wrapper for block formulas; if empty, outputs raw TeX only. |
| Also replace the rich-text flavor | true |
If true, replaces formulas in text/html as well; if false, the HTML flavor retains the original selection markup, facilitating paste into rich-text targets. |
Host-side fields are declared in index.js within export const Config and marked with .volatile(); the client subscribes via ctx.configForms.get("math-copy") and merges with built-in defaults.
Installation and Activation¶
The installation command follows the repository README (requires a session with Full access):
# from a session with Full access:
# plugin_manager action=install_bundle target=<this directory>
Replace <this directory> with the path to this plugin bundle (e.g., a path pointing to the directory after installation via the marketplace or a local package; refer to your environment’s plugin_manager usage for specifics).
After installation:
- Reload the Web UI page to include the new client bundle in the boot graph.
- If the host portion (
index.js) is modified later, you must restart DSH: host modules are cached within the process lifecycle, and the profile’s HMR is set toroot: []for the host (it does not watch source code). If onlyclient.jsis changed, simply refreshing the page is sufficient.
The README specifies the development and validation environment as dsh core 0.2.0-rc.2 (DSH Desktop 2.0.15-beta.1). The version in package.json is 0.1.0, and the license is MIT; compatibility ranges have not yet been declared in engines.dsh.
Typical Usage¶
No separate command-line operation is required: simply use the mouse to select text containing formulas (or just part of a formula) in the Web UI as usual, and execute copy (Ctrl+C / system copy). If the selection contains KaTeX formulas, the plain text on the clipboard should be LaTeX. For example, with default delimiters, a block formula will look like:
$$\frac{a}{b}$$
rather than the string of glyphs corresponding to the rendered \frac{a}{b}. Paste the result into an editor supporting $…$ / $$…$$ or a TeX source file to continue editing.
If you primarily paste into rich-text environments like Word, you can disable Also replace the rich-text flavor as needed to retain the HTML selection structure; keep it enabled by default if you require pure LaTeX strings.
Scenarios and Notes¶
Who is it for
- Developers who frequently copy formulas from DSH conversations to Obsidian, LaTeX, Markdown, or code comments.
- Users who want copy results to be directly usable as
$…$/$$…$$fragments.
Permissions and Security
The plugin runs within the current DSH process and Web client context. Before installation, please review the GitHub source code and the MIT license yourself to ensure the bundle source is trustworthy; do not execute install_bundle from an untrusted path without review.
Implementation Details (Optional Reading)
- The configuration panel is registered in the
plugins.row.configslot with the keydsh-math-copy#math-copy; there is no built-in UI auto-rendering this form, so the plugin renders it itself. - When installing from a directory,
@deepseek-ai/schemasterycan usually parse directly; however, when a directory bundle is linked into a profile, a fallback may occur. Without a schema, default copying still works, but the configuration form will be missing.
Conclusion¶
dsh-math-copy solves the issue of obtaining glyphs instead of LaTeX when copying KaTeX formulas in the Web UI. By listening for document-level copy events and backfilling TeX annotations, it ensures clipboard content is consistent with formula semantics. It requires installing the bundle, refreshing the page, and restarting DSH after modifying host configurations.