npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wcj/html-to-markdown

v2.1.1

Published

html conversion tool to markdown.

Downloads

11,193

Readme

@wcj/html-to-markdown

Buy me a coffee CI NPM @wcj/html-to-markdown version NPM @wcj/html-to-markdown-cli version

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

Installation

This package is ESM 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 STDIN

Options:

  -v, --version, Show version number
  -h, --help, Displays help information.
  -o, --output <dir-path>, Output directory. defalut(dist)
  -s, --stdout, Output to stdout

Example:

  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 the rehype and remark plugins.

/**
 * @typedef {import("@wcj/html-to-markdown").Options} Options
 * @type {Options}
 **/
export default { 
  rehypeParseOption: {},
  rehypePlugins: [],
  remarkPlugins: [],
};

Usage

import htmlToMarkdown from '@wcj/html-to-markdown';

htmlToMarkdown({ html: '<h1>Markdown String</h1>' });
// => # Markdown String

API

import { PluggableList } from 'unified';
import { Options as RehypeParseOptions } from 'rehype-parse';
declare type Options = {
  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;
};
export default function htmlToMarkdown(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 with contributors.

License

Licensed under the MIT License.