Movatterモバイル変換


[0]ホーム

URL:


top
HTML To Markdown logoHTML To Markdown

@wcj/html-to-markdown

Buy me a coffeeCINPM @wcj/html-to-markdown versionNPM @wcj/html-to-markdown-cli version

HTML conversion tool to markdown. Command line tool =>@wcj/html-to-markdown-cli.

Installation

This package isESM only: Node 14+ is needed to use it and it must be import instead of require.

npm i @wcj/html-to-markdown

Command 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.md

Command 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 ---stdout

Support 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:[],};

Usage

importhtmlToMarkdownfrom'@wcj/html-to-markdown';htmlToMarkdown({html:'<h1>Markdown String</h1>'});// => # Markdown String

API

import{ 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>;

Development

$npm i$npminstall--workspaces$npm run build$npm run build:cli

Related

Contributors

As always, thanks to our amazing contributors!

Made withcontributors.

License

Licensed under theMIT License.

Edit this page on GitHub2024/06/26
Released under the MIT License. Copyright © 2022 Kenny Wong
Generated byidoc v1.31.0

[8]ページ先頭

©2009-2025 Movatter.jp