dsh-md-export
Manifest valid★ 5DSH web plugin (dsh-better-sidebar companion): adds an export button to the markdown editor toolbar — one-click export of the current .md file to standalone HTML (with mermaid diagrams inlined) or PDF (via browser print dialog)
dsh-md-export
简体中文:README.zh.md
DSH (DeepSeek Harness) Web plugin — Markdown export extension for dsh-better-sidebar.
Adds an Export button to the Markdown file viewer toolbar in better-sidebar. Click it to open a dropdown with two choices:
- 📄 Save HTML (same directory) — Renders the current
.mdfile into a standalone.htmland writes it directly next to the .md file (Markdown tables / code blocks / Mermaid diagrams all inlined; layout follows the original md preview theme — not A4 print-oriented) - 🖨️ Export PDF (print) — Opens the browser print dialog (the printed content is the rendered document); choose "Save as PDF" to produce a PDF
Features
- Zero-dependency, keeps built-in behavior: does not replace better-sidebar's built-in Markdown preview/edit (preview, edit, save and Mermaid rendering all remain); it only appends an export button to the toolbar
- What you see is what you get: the exported HTML is taken directly from the built-in previewer's rendered DOM (including Mermaid SVG) — no second rendering pass
- Saves next to the .md: writes the HTML into the md's directory via better-sidebar's
/sidebar/api/fs.writechannel (same basename,.htmlextension); falls back to a browser download if session detection fails - Layout follows the original md preview: the exported HTML uses the current preview theme's colors and typography (dark/light auto-follow), content width adapts — no A4 paper size
- Edit-mode friendly: if you are in edit mode with unsaved content, export automatically switches to preview first
- Auto-follow: the button appears on the Markdown toolbar whenever the file or preview/edit mode changes
Prerequisites
- DSH
dsh webrunning - dsh-better-sidebar installed (or the aggregator package
@linxin666/dsh-web-ui-allthat brings it in)
Install
dsh plugin --profile web add <dsh-md-export-0.1.0.tgz>
After installing, restart dsh web (a new bundle needs a host-side reload), then hard-refresh the browser (Cmd/Ctrl+Shift+R).
Open any
.mdfile in the sidebar — the "Export ▾" button appears right next to the "Preview | Edit" toggle.
Usage
- Open any
.mdfile in better-sidebar (e.g.docs/AOI端保存图片逻辑.md) - Click the "Export ▾" button on the toolbar
- Choose:
- Save HTML (same dir): the HTML is written next to the md (e.g.
docs/AOI端保存图片逻辑.html), layout matches the md preview - Export PDF (print): the print dialog opens; choose "Save as PDF"
- Save HTML (same dir): the HTML is written next to the md (e.g.
Development
node --check lib/client.js # syntax check (hand-written single-file client bundle, no build step)
lib/index.js— host-side placeholder plugin (emptyapply, so the loader entry mounts)lib/client.js— client logic: MutationObserver watches the markdown toolbar → injects the export button + dropdown → grabs the preview DOM → saves next to the md via/sidebar/api/fs.write/ triggers print
Implementation notes
| Step | How |
|---|---|
| Button injection | MutationObserver watches document.body, finds .nArs4W_editorModeToggle (Markdown/HTML previewer toolbar) and injects when the current file is .md |
| Path resolution | Takes the md absolute path from the .nArs4W_editorPathInput title attribute; the output is the same directory + same basename + .html |
| Session detection | Scans localStorage keys dsh-sidebar:v1:*, picks the newest sessionId |
| Save to same dir | POST /sidebar/api/fs.write (payload: sessionId + absolute path + HTML content); falls back to a browser download on failure |
| HTML layout | Reads colors/fonts from .nArs4W_editorMd and the page theme; exported content width adapts (non-A4) |
| PDF export | Writes the same HTML into a hidden iframe → window.print() → user chooses "Save as PDF" in the print dialog |
Known limitations
- PDF export relies on the browser print feature (Chrome/Edge both support "Save as PDF"); it does not generate a
.pdfbinary directly, so PDF cannot be saved to the md directory - HTML save-to-same-dir depends on session detection (localStorage); in edge cases it falls back to a browser download
- Depends on better-sidebar's internal CSS class names (
nArs4W_prefix); if a major better-sidebar upgrade changes the class names, this plugin needs a sync update - Only applies to
.mdfiles;.markdownextension is also supported
License
MIT
Comments
Loading…
Similar plugins
by LeslieWylie
Render Markdown to a standalone, self-contained HTML page: an `md_html_render` tool that works in a headless profile, plus a web drawer to browse, preview, edit and export local `.md` files; both shar
★ 1
MIT
JavaScript
Aug 18, 2026
dsh plugin --profile web add dsh-md-html-renderby AnakinCao
DSH web plugin (dsh-better-sidebar companion): code file preview with per-language syntax highlighting, symbol outline navigation (class / method / variable) and in-file search
★ 2
MIT
JavaScript
Aug 26, 2026
dsh plugin --profile web add dsh-code-navby jiavenzhong
DSH 插件:发送文件先转 Markdown — 让大模型直接读懂 PDF/Word/Excel/PPT/HTML/CSV/EPUB,基于 Microsoft MarkItDown
★ 0
MIT
JavaScript
Aug 18, 2026
dsh plugin --profile web add dsh-tool-markitdownby BioAIEvolu
Markdown Studio - DeepSeek Harness 原生右侧 Markdown 预览插件:Mermaid 图表 · KaTeX 公式 · 代码高亮,渲染引擎随包内置完全离线 / Native DSH sidebar preview with offline Mermaid, KaTeX and highlighting
★ 4
↓ 1.7k/wk
MIT
JavaScript
Nov 6, 2026
dsh plugin --profile web add dsh-md-studioby omdsh-dev
DSH plugin for PaddleOCR-VL document layout parsing: convert PDFs and images to Markdown with async jobs, progress tracking, and workspace export.
★ 3
BSD-3-Clause
TypeScript
Aug 19, 2026
dsh plugin --profile web add dsh-paddle-ocrby 2017java
DSH web 插件:在 dsh-better-sidebar 侧边栏内把 Markdown 富渲染为预览(代码高亮 / 目录 / 一键复制)。
★ 0
MIT
JavaScript
Aug 25, 2026
dsh plugin --profile web add dsh-md-viewer