@wcj/html-to-markdownHTML conversion tool to markdown. Command line tool =>@wcj/html-to-markdown-cli.
This package isESM only: Node 14+ is needed to use it and it must be import instead of require.
npm i @wcj/html-to-markdownCommand line tool
$ npx @wcj/html-to-markdown-cli ./html/index.html# 🌐 Request: /Users/xxx/index.html# 🎉 Compliled successfully!# ╰┈ Output: /Users/xxx/dist/index.md$ npx @wcj/html-to-markdown-cli https://jaywcjlove.github.io/idoc/# 🌐 Request: https://jaywcjlove.github.io/idoc/# 🎉 Compliled successfully!# ╰┈ Output: /Users/xxx/dist/idoc.md# Or$sudonpm i @wcj/html-to-markdown-cli-g$ html-to-markdown ./html/index.html# 🌐 Request: /Users/xxx/html/index.html# 🎉 Compliled successfully!# ╰┈ Output: /Users/xxx/html/dist/index.md$ html-to-markdown https://jaywcjlove.github.io/idoc/# 🌐 Request: https://jaywcjlove.github.io/idoc/# 🎉 Compliled successfully!# ╰┈ Output: /Users/xxx/dist/idoc.mdCommand Help
Usage: html-to-markdown<URL|file path|->[options][--help|h][--version|v]Passing"-" as the first arg will take input from STDINOptions: -v, --version, Show version number -h, --help, Displayshelp information. -o,--output<dir-path>, Output directory. defalut(dist) -s, --stdout, Output to stdoutExample: html-to-markdown ./html/index.html html-to-markdown https://jaywcjlove.github.io/idoc/ html-to-markdown--output="dist"echo"<h1>hello world</h1>"| html-to-markdown ---stdoutSupport Config
In the project's root directory, add a.htm2mdrc.js file with the following configuration to enable therehype andremark plugins.
/** *@typedef{import("@wcj/html-to-markdown").Options}Options *@type{Options} **/exportdefault{rehypeParseOption:{},rehypePlugins:[],remarkPlugins:[],};importhtmlToMarkdownfrom'@wcj/html-to-markdown';htmlToMarkdown({html:'<h1>Markdown String</h1>'});// => # Markdown Stringimport{ PluggableList}from'unified';import{ Optionsas RehypeParseOptions}from'rehype-parse';declaretypeOptions={ html?:string; url?:string; rehypeParseOption?: RehypeParseOptions;/** * List of [remark plugins](https://github.com/remarkjs/remark/blob/main/doc/plugins.md#list-of-plugins) to use. * See the next section for examples on how to pass options */ remarkPlugins?: PluggableList;/** * List of [rehype plugins](https://github.com/rehypejs/rehype/blob/main/doc/plugins.md#list-of-plugins) to use. * See the next section for examples on how to pass options */ rehypePlugins?: PluggableList;};exportdefaultfunctionhtmlToMarkdown(options?: Options):Promise<string>;$npm i$npminstall--workspaces$npm run build$npm run build:cliAs always, thanks to our amazing contributors!
Made withcontributors.
Licensed under theMIT License.