Markdown toolkit built for docsjs workflows. Convert docsjs HTML snapshots or DOCX files into Markdown with extensible rules.
- HTML -> Markdown core entry:
@coding01/docsjs-markdown - DOCX -> Markdown adapter entry:
@coding01/docsjs-markdown/docx - Rule-based conversion architecture (custom per-tag rules)
- Optional YAML frontmatter generation
- CLI for direct
.docx -> .mdconversion
Use @coding01/docsjs for high-fidelity Word/DOCX import, then feed its HTML snapshot into @coding01/docsjs-markdown for Markdown output.
- npm: https://www.npmjs.com/package/@coding01/docsjs
- GitHub: https://github.com/fanly/docsjs
- Product page: https://docsjs.coding01.cn/
To keep all docsjs ecosystem plugin pages consistent, landing pages follow one shared structure template:
- Spec file:
docs/LANDING_TEMPLATE.md - Concrete page:
docs/index.html
npm i @coding01/docsjs-markdownimport { htmlToGfm, htmlToStandardMarkdown } from "@coding01/docsjs-markdown";
const html = "<h1>Hello</h1><p>World</p>";
const gfm = htmlToGfm(html);
const standard = htmlToStandardMarkdown(html);import { docxToMarkdown, docxToMarkdownWithMeta } from "@coding01/docsjs-markdown/docx";
const file = input.files?.[0] as File;
const markdown = await docxToMarkdown(file, {
format: "gfm",
frontmatter: true,
sanitizationProfile: "fidelity-first",
});
const richResult = await docxToMarkdownWithMeta(file, {
format: "gfm",
frontmatter: true,
includeParseReport: true,
});import { htmlToMarkdown } from "@coding01/docsjs-markdown";
const markdown = htmlToMarkdown("<mark>hit</mark>", {
rules: {
mark: (el, ctx) => `==${ctx.convertInline(el)}==`,
},
});htmlToMarkdown(html, options)htmlToMarkdownWithMeta(html, options)htmlToGfm(html, options)htmlToStandardMarkdown(html, options)generateFrontmatter(meta)
docxToMarkdown(file, options)docxToMarkdownWithMeta(file, options)
format:"standard" | "gfm"frontmatter: booleanmetadata: custom metadata objectrules: custom tag conversion rulesincludeParseReport: include docsjs parse report (docx entry)sanitizationProfile:"fidelity-first" | "strict"(docx entry)
docsjs-markdown ./input.docx -o ./output.md --frontmatter --include-parse-reportOptions:
-o, --output <file>-f, --format <gfm|standard>--frontmatter--include-parse-report--strict-h, --help
npm install
npm run verify
npm run buildnpm version patch
git push origin main --follow-tags
npm publish --access public- Trigger by tag:
v*.*.* - Run quality gate:
npm run verify - Publish package:
npm publish --access public
- Workflow:
.github/workflows/publish-github-packages.yml - Trigger: tag
v*.*.*or manual run - Target registry:
https://npm.pkg.github.com - Package name for GitHub Packages:
@fanly/docsjs-markdown
MIT
If this project saves your time, a small tip is appreciated.
