Introduction¶
When you select a passage in a DeepSeek Harness (DSH) conversation and press Cmd/Ctrl+C, the clipboard receives the rendered output. Formulas appear as rendered math symbols, code blocks as highlighted text, and tables as visual grids. When you paste that into an editor, an issue tracker, or a note-taking app, the structural information is lost: formulas no longer carry LaTeX, code blocks lose their language annotation, and tables degrade into plain text.
Copy Enhancement (@local/dsh-copy-markdown) takes over the copy behavior within DSH conversation transcripts: after selecting a passage and pressing Cmd/Ctrl+C, the clipboard receives the Markdown source of that selection. Formulas return to $…$ / $$…$$, code blocks return to fenced blocks, tables return to GFM tables, diff cards return to ```diff fences, terminal blocks return to fences, and footnotes return to [^n] references with their definitions. Any Markdown syntax that appears literally in the body text is escaped so it won’t be re-interpreted as emphasis, list items, or formulas.
The plugin runs entirely on the browser side, is written in pure JavaScript, and requires no build step.
Installation¶
Requirements: DeepSeek Harness 0.2.2-rc.3 or later (the plugin manifest declares this range via engines.dsh; older versions will be rejected at install time).
Install from GitHub (v1.0.0 is a tag; you can also omit it and track main):
dsh plugin --profile <profile> add github:Rayzenchen/dsh-copy-markdown#v1.0.0
Install from a local directory:
dsh plugin --profile <profile> add /path/to/dsh-copy-markdown
In the Desktop app, you can also have the agent use plugin_manager’s install_bundle to install the same spec. After installation, simply refresh the page (all functionality lives on the browser side); to uninstall, run:
dsh plugin --profile <profile> remove @local/dsh-copy-markdown
Usage¶
There is only one rule: select a passage in the conversation transcript and press Cmd/Ctrl+C.
- What you get is source code, not rendered text. Paste it directly into an editor, issue, or note.
- The input box, sidebar, and settings pages are not intercepted; copy behavior there remains the browser default.
- DSH’s own copy buttons (on code blocks, diffs, and terminal blocks) are not overridden.
- If any step of the detection fails, the plugin falls through to the browser’s default copy, so “copy” will never be entirely broken.
Supported Constructs¶
| Rendered form you select | Clipboard content |
|---|---|
| Formula (entire) | Author’s original source, $…$ / $$…$$ |
| Formula (partial selection) | Structurally equivalent source for that fragment, e.g. $\sum_{i=1}^{n}$ |
| Code block | Fence + language (language taken from DSH’s own banner) |
| Table | GFM table, with alignment written back as :---: / ---: / :--- |
| Diff card | ```diff fence, with -/+/ at line starts |
| Terminal block | Fence, with both command lines and output lines preserved, blank lines intact |
| Footnote | [^n] reference + [^n]: … definition (when the definition is also in the selection) |
| Headings / lists / blockquotes / bold / inline code | Corresponding Markdown markup |
| Buttons, icons, expand/copy and other UI widgets | Skipped; not included in the clipboard |
Literal Escaping¶
Since the clipboard carries source code, any body text that “looks like Markdown” must be escaped, otherwise pasting it back will trigger re-parsing:
| Appears in body text | Output | Why |
|---|---|---|
*args, **kwargs |
\*args, \*\*kwargs |
Otherwise they become emphasis |
Line start (with up to 3 leading spaces) # - + > 1., or a line consisting only of - or = |
\# \- \> 1\. \- \= |
Otherwise they become headings / list items / blockquotes / thematic breaks / setext headings |
Literal newlines inside pre-wrap, leading spaces/Tabs on continuation lines |
\ + newline;   / 	 |
Otherwise soft line breaks collapse into one line and leading whitespace is swallowed |
Line start [1]: x |
[1]\: x |
Otherwise it becomes a link reference definition and the line disappears |
| Line start with four spaces or a Tab |   / 	 |
Otherwise it becomes an indented code block |
Any $ (e.g. $5 to $10) |
\$5 to \$10 |
DSH has single-$ inline math enabled; even unpaired $ is treated as a formula |
`, ~, &, <div> |
\``,\~,\&,\` |
Otherwise they become inline code / strikethrough / entity / raw HTML |
Trailing literal \ |
\\ |
Otherwise it swallows the next line and becomes a hard line break |
snake_case |
Unchanged | In CommonMark, intra-word underscores do not form emphasis |
[x](y) |
\[x](y) |
Otherwise it becomes a link |
Only text nodes are escaped: markup generated by the serializer itself (headings, fences, **, etc.) is appended after escaping, so it is never affected. Content inside <code> / <pre> is left completely untouched.
Available to Other Plugins¶
The plugin exposes a markdownSource service on the browser side, so other plugins can reuse the same projection instead of reimplementing it:
const source = ctx.get('markdownSource')
source.fromRange(range) // A DOM Range → Markdown ('' means no content)
source.fromNodes(nodeList) // Node list → Markdown
source.fromHtml(htmlString) // HTML string → Markdown
source.fromSelection() // Current browser selection → Markdown
source.isTranscriptRange(range) // Whether the selection falls within the conversation transcript
If the service is unavailable, fall back to your own implementation—this does not affect the primary functionality.
Known Limitations¶
- Only intercepts copy within the conversation transcript: the input box, sidebar, and settings pages are never touched; DSH’s own copy buttons are not overridden.
- Formulas: a full selection yields the original source; a partial selection yields a structurally equivalent reconstructed fragment; if either endpoint of the selection falls outside the formula, the entire formula is treated as a unit. Unrecognized constructs also fall back to the full formula.
- Non-text blocks such as Mermaid diagrams or image previews are treated as plain images or skipped; their definitions are not reconstructed.
- Footnote references are only restored to
[^n]when the corresponding definition list is also selected; otherwise they remain as inline HTML (still rendering as superscripts). - Terminal blocks and diff cards are identified by “full coverage”: if only one or two lines within a block are selected, you get the raw text of those lines—
+/-markers will not be fabricated. - Inline HTML fallback:
<mark>/<u>/<kbd>/<sup>/<sub>have no equivalent Markdown syntax and can only be restored as inline HTML. - Bold adjacent to CJK punctuation (e.g.
**"注意"**是) does not satisfy CommonMark’s flanking rules; after pasting, the**will display literally. - Hard line breaks:
<br>is emitted as\+ newline; inside headings and table cells it becomes a space. - User / steering bubbles are copied verbatim: when the selection falls entirely within a single user or steering line, the original input text is copied—no backslashes are added to
**,-,$, etc. - Partial code selection: when only part of a code block or inline code is selected, you get the raw text—no fences, no escaping—so pasting into an editor or terminal yields the code itself.
- Editable areas are not intercepted: if focus or a selection endpoint is inside an
input/textarea/contenteditableelement, the browser’s default copy is used. - Bare URLs:
http://…in body text will be auto-recognized as a link when pasted back into GFM (consistent with the original rendering).
Verification and Compatibility¶
Self-tests cover: inline/block-level formulas, KaTeX error fallback, partial formula reconstruction, fragment equivalence (re-rendering with KaTeX and comparing node-by-node against the original MathML subtree), various boundary cases for formula selections, headings / code / lists / nested lists / blockquotes / tables / inline styles / task lists, code block banners and language detection, backtick fence promotion, table pipe escaping, bold snapping in partial selections, region detection between transcript and input box, each literal-escaping rule, links and images, table alignment, mark/u/sup/sub, diff cards / terminal blocks / footnotes (including sr-only headings, ↩ backlinks, and multi-paragraph definitions), end-to-end copy events (interception, preventDefault, non-interception inside input boxes), and linear-time performance under large text volumes.
Compatibility seams carry no official guarantee: if DSH renames internal elements after an upgrade, the plugin will silently degrade to “browser default copy.” After upgrading DSH, it is recommended to run the self-test once and manually verify with a response containing formulas, code, and tables.
Declared support: DSH >=0.2.2-rc.3 <0.3.0 (engines.dsh). Last verified against: DSH 0.2.2-rc.5.
License¶
MIT © 2026 Rayzenchen