dsh-math-copy
English | 中文
Copying rendered math from the DSH Web UI puts the formula's LaTeX source on
the clipboard, instead of KaTeX's visual glyph text (x2 for x^2).
What it does
The Web UI renders math with KaTeX, and KaTeX keeps the original TeX source in the formula's accessibility subtree:
<span class="katex">
<span class="katex-mathml"><math>…<annotation encoding="application/x-tex">\frac{a}{b}</annotation>…</math></span>
<span class="katex-html" aria-hidden="true">…glyphs…</span>
</span>
The browser's own selection copy walks the visible layout (and the clipped MathML
arm), so it produces glyph text. This plugin listens for copy on the document;
when the selection intersects at least one formula it marks those formulas,
clones the selection, swaps each formula for its TeX wrapped in math delimiters,
writes text/plain (and text/html) and cancels the default action. A copy
whose selection holds no math is left completely alone.
Selecting half a formula still yields the whole formula's TeX.
Configuration
Three fields, editable in the Plugins page:
| field | default | meaning |
|---|---|---|
| Inline formula delimiter | "$" |
wrapped around inline math (empty → bare TeX) |
| Display formula delimiter | "$$" |
wrapped around display math (empty → bare TeX) |
| Also replace the rich-text flavor | true |
substitute math in the text/html flavor too; off keeps the untouched selection markup for rich paste targets |
How the form is wired
index.jsdeclares the fields onexport const Configand marks each one.volatile(). Only volatile fields are projected into a form: the settings service serves them under this entry's profile row id,math-copy.client.jssubscribes to that form throughctx.configForms.get("math-copy")(the same way the shippedui-chatreads its preferences) and folds it over its own defaults, so the copy handler always reads the current values.- The panel is registered into the
plugins.row.configslot with the key<package name>#<row id>(dsh-math-copy#math-copy). No shipped client renders settings forms automatically, so the plugin renders its own.
Find it at 插件 (Plugins) → dsh-math-copy → the math-copy row → its
configuration block. Writes go through the settings transport and are
persisted into the active profile's Cordis patch, so they survive restarts.
Changing the host half (index.js) needs a DSH restart: the host module
generation is cached for the process lifetime, and the profile's HMR entry runs
with root: [] (no source watching). Client-only edits (client.js) reach the
page on a reload.
Install
# from a session with Full access:
# plugin_manager action=install_bundle target=<this directory>
Reload the Web UI page afterwards so the new client bundle enters the boot graph.
Restarting DSH after a host-half change is required — the host module generation is cached for the process lifetime.
Status
Developed and verified against dsh core 0.2.0-rc.2 (DSH Desktop
2.0.15-beta.1). No engines.dsh range is declared yet: the plugin uses
long-standing client services (slots, locale, configForms, ctx.inject),
but only this version has actually been run, and a range that admits prerelease
builds has to name each major.minor.patch tuple explicitly. Declare one once
another version has been tested.
Development
tools/asar-extract.mjs reads Electron's app.asar (list or extract by path
substring) — used to read the shipped client code that renders markdown and math:
node tools/asar-extract.mjs "/Applications/DeepSeek Harness.app/Contents/Resources/app.asar" list katex
node tools/asar-extract.mjs "/Applications/DeepSeek Harness.app/Contents/Resources/app.asar" extract dsh-client-ui-primitives /tmp/dshx
index.js resolves @deepseek-ai/schemastery through the active profile when
the direct specifier misses (a directory-installed bundle is linked into the
profile, so Node resolves its imports from the workspace instead). Without the
schema the plugin still copies with its built-in defaults; only the form is
missing. A normally installed copy (npm or GitHub, which is what
dshmarket performs) resolves the direct specifier and never reaches the
fallback.
submission/ holds the one-file catalog entry for
awesome-dsh-plugin;
see the notes inside it.
No comments yet. Be the first to write one.