Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Command line tool that converts HTML to markdown.

License

NotificationsYou must be signed in to change notification settings

jaywcjlove/html-to-markdown-cli

Repository files navigation

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$ sudo npm 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{OptionsasRehypeParseOptions}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$ npm install --workspaces$ npm run build$ npm run build:cli

Related

Contributors

As always, thanks to our amazing contributors!

Made withcontributors.

License

Licensed under theMIT License.


[8]ページ先頭

©2009-2025 Movatter.jp