In the DSH file pane, Markdown files are usually displayed only as plain text, with limited layout and interaction. dock-markdown aims to solve this problem by registering viewers for .md, .markdown, and .mdx files. It provides GFM rendering, DOMPurify content sanitization, document outlines, and quick switching to the editor, giving Markdown content an editor-level reading experience in DSH.
Features¶
Markdown Rendering and Security¶
The plugin uses the marked library to support GitHub Flavored Markdown (GFM) syntax. The rendered HTML output is sanitized with DOMPurify.sanitize() to ensure that the content written to the DOM is safe.
Relative Path Resource Resolution¶
Relative images and internal links in Markdown are resolved with the following priority:
1. The directory containing the Markdown file
2. The git repository root of the current path
3. The session workspace root directory
Images are displayed as inline data URLs. Clicking an internal link opens the target file in the workbench. Anchor links (#anchor) support smooth scrolling.
Document Outline¶
The ☰ button in the toolbar expands or collapses the outline pane. The outline lists headings by level (h1–h6) with indentation. Clicking a heading navigates to it, and the current section is highlighted automatically while scrolling.
Viewer Switching and Theme¶
The toolbar provides a button to switch with one click between View mode and the dock-editor editing mode. Layout styles follow DSH theme tokens and adapt automatically to light/dark themes. Common GFM elements such as code blocks, tables, and blockquotes have dedicated styles.
Installation and Dependencies¶
This plugin runs in the DSH Web environment and depends on the dock, dock-files, and dock-editor plugins.
dsh plugin --profile web add dock-base
dsh plugin --profile web add dock-files
dsh plugin --profile web add dock-editor
dsh plugin --profile web add dock-markdown
Dependency requirements:
* dock >= 0.1.0: Provides ctx.workbench.
* dock-files >= 0.1.0: Registers the markdown viewer.
* dock-editor >= 0.1.0: Provides the /desk-editor/fs.read API and editing view.
* cordis ^4.0.0-rc.7: Plugin framework.
* react ^18.2.0: Required for client-side rendering (optional; if not provided, the viewer UI remains inactive).
* marked / dompurify: Bundled with the plugin and do not need separate installation.
Notes¶
- Security risk: DOMPurify allows the
styleattribute by default. In theory, malicious Markdown could use CSS for external tracking. If a stricter security policy is required, configureFORBID_ATTR: ['style']. - File access permissions: Relative path resource resolution is not restricted by the session workspace. Markdown files may be located anywhere on the host (e.g.,
~/.dsh/skills/...), and the plugin attempts to read files under candidate paths according to the priority. - License: This plugin is licensed under the MIT License.
Summary¶
dock-markdown adds structured Markdown reading capabilities to the DSH plugin ecosystem. By integrating outline navigation, one-click editing switching, and a safe rendering mechanism, it can meet requirements in scenarios such as document review and skill library browsing.
- GitHub: https://github.com/AKS1st/dock-markdown
- Directory: https://www.skillhub.cn/plugins/AKS1st/dock-markdown