Skip to content

omdsh-dev/dsh-tool-markdown

40Last commit Aug 14, 2026

dsh-tool-markdown DSH plugin

This plugin provides deterministic conversion between HTML and Markdown (GFM style), normalizes pipe-delimited tables, and generates table of contents from Markdown headings. It is hand-written, zero-dependency, and runs with a recursive descent parser for security and simplicity.

How to install the dsh-tool-markdown DSH plugin

dsh plugin --profile web add github:omdsh-dev/dsh-tool-markdown

Copying does not run this command. Review the repository and version before installing the dsh-tool-markdown DSH plugin.

dsh-tool-markdown DSH plugin data source

dsh-tool-markdown DSH plugin snapshot date: Aug 16, 2026

discovered

What the dsh-tool-markdown DSH plugin can do

  • Convert HTML to GFM Markdown (html2md): block-level and inline mapping, entity decoding, script/style stripping, link scheme filtering.
  • Convert Markdown to safe HTML (md2html): only outputs whitelist tags (p, h1-h6, ul, ol, etc.), all text HTML-escaped, no tag escape.
  • Normalize HTML <table> or pipe-delimited text into GFM table format, with colspan handling and column alignment.
  • Generate a nested table of contents from Markdown headings (toc) with GitHub-style anchor slugification and duplicate suffix.

Where the dsh-tool-markdown DSH plugin fits

  • Convert a webpage HTML snippet (e.g., email, export) into clean Markdown for further processing.
  • Safely render Markdown as HTML with restricted tag set, preventing XSS via script or javascript: links.
  • Clean up and format pipe-delimited table data into a consistent GFM table for model consumption.
  • Generate a table of contents for long Markdown documents to improve navigation.
  • Extract table data from HTML pages and convert to Markdown table for structured representation.

Who the dsh-tool-markdown DSH plugin is for

  • DSH users who need to process documents or web content in a model-friendly Markdown format.
  • Developers building AI workflows that require reliable HTML-to-Markdown conversion without heavy dependencies.

dsh-tool-markdown DSH plugin limitations

  • Does not perform readability extraction: nav, header, footer are passed through as-is, not removed.
  • Input size limited to 1MB (hard cap) with default 256KB; exceeding results in error, not truncation.
  • Nesting depth limited to 64 levels; deeper HTML causes an error.
  • Only supports a whitelist of HTML tags for md2html output; all other HTML tags are escaped as text.
  • Link scheme whitelist: only http/https/mailto; javascript: and data: links are downgraded to plain text.

dsh-tool-markdown DSH plugin: from the repository README

Quoted from the omdsh-dev/dsh-tool-markdown README, the upstream source of the dsh-tool-markdown DSH plugin. Copyright remains with the original authors.

DSH Markdown 工具插件 —— HTML↔Markdown 转换、GFM 表格规范化、目录生成。零依赖、纯函数、手写轻量解析器。 [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) ## 动机 模型最常见的文档场景:用户贴一段 HTML(网页源码、邮件、导出文件)、贴表格要求整理、或要求"转成 markdown"。没有工具时模型只能硬编码处理——HTML 实体会错、表格会乱、网页噪音(导航/脚本/广告)会混入。本插件提供确定性转换,与 `dsh-tool-csv` 互补:**csv 管结构化表格,markdown 管文档/网页**。 ## 安全模型 - **零依赖**:手写递归下降 HTML 解析器(不引入 cheerio/jsdom——净增数十 MB 且是攻击面) - **零执行面**:不 eval、不 new Function、不加载远程资源、不解析 CSS 布局 - **内容剥离**:script/style/iframe/object/noscript 内容整体剥离(安全 + 噪音) - **md2html 白名单**:只输出 `p h1-h6 ul ol li blockquote pre code a img strong em br hr table thead tbody tr th td`;文本一律 HTML 转义——markdown 内嵌 `<script>` 只会显示为文本 - **链接 scheme 白名单**:`http/https/mailto`;`javascript:`/`data:` 链接降级为纯文本 - **资源上限**:嵌套深度 64 层报错(防栈溢出);输入 `maxBytes` 默认 256KB、硬顶 1MB(超限报错不截断) - 工具参数会记入会话日志,**不要传入含密钥/会话数据的 HTML** ## 工具声明 注册 `markdown` 工具(`@deepseek-ai/dsh-tool-markdown`,row id `tool-markdown`),统一输出文本。 | 参数 | 类型 | 必填 | 说明 | |---|---|---|---| | `action` | string | ✅ | `html2md` / `md2html` / `table` / `toc` | | `html` | string | | html2md 输入(片段或完整文档) | | `markdown` | string | | md2html/toc 输入 | | `text` | string | | table 输入(HTML `<table>` 或管道分隔文本) | | `baseUrl` |

Read the full READMERepository license: MIT

dsh-tool-markdown DSH plugin questions

How do I install the dsh-tool-markdown plugin?

Use the DSH CLI: `dsh plugin --profile web add github:omdsh-dev/dsh-tool-markdown`. For the headless profile, replace `web` with `headless`. You can also install via npm pack tarball: `npm pack` then `dsh plugin --profile web add ./dsh-tool-markdown-*.tgz`.

Can this plugin convert a full HTML page with navigation and ads into clean Markdown?

It converts HTML to Markdown faithfully, but it does not perform readability extraction. Navigation, headers, footers, and ads are passed through as-is. If you need to extract the main content, you should pre-process the HTML with a readability tool before using this plugin.

What is the maximum input size for the markdown tool?

The default `maxBytes` is 256,000 bytes (256 KB), with a hard cap of 1,000,000 bytes (1 MB). If the input exceeds the limit, the tool returns an error message and does not truncate the content.

How does the plugin handle JavaScript links like `javascript:alert(1)`?

The plugin uses a link scheme whitelist that only allows `http`, `https`, and `mailto`. Any link with a `javascript:` or `data:` scheme is downgraded to plain text, so it will appear as the link text only, not as a clickable link.

Does the plugin support custom HTML tags or CSS?

No. The HTML parser is a custom recursive descent parser that only understands standard HTML. For md2html, only a whitelist of tags is output (p, h1-h6, ul, ol, li, blockquote, pre, code, a, img, strong, em, br, hr, table, thead, tbody, tr, th, td). All other tags and CSS are either stripped or escaped as text.