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 🙏

© 2025 – Pkg Stats / Ryan Hefner

anby

v0.0.6

Published

![license](https://img.shields.io/npm/l/anby) ![downloads](https://img.shields.io/npm/dt/anby) ![npm](https://img.shields.io/npm/v/anby)

Downloads

22

Readme

Anby

license downloads npm

安装 pnpm install anby

parseHTML

基于状态机实现的 html 宽松解析器,转换为 js 对象,方便做富文本渲染。

import { parseHTML } from 'anby'

parseHTML('<p>123</p>').doc

// result
{
  type: 'doc',
  content: [{
    type: 'p',
    content: [{
      type: 'text',
      text: '123'
    }]
  }]
}

配置项

alias

标签别名,用于更改 tag 名称

parseHTML('<p>123</p>', {
  alias: {
    p: 'paragraph'
  }
}).doc

// result
{
  type: 'doc',
  content: [{
    type: 'paragraph',
    content: [{
      type: 'text',
      text: '123'
    }]
  }]
}

也可以根据父子关系修改,如 'audio > p'

parseHTML('<audio><p>123</p></audio>', {
  alias: {
    'audio > p': 'audioText'
  }
}).doc

// result
{
  type: 'doc',
  content: [{
    type: 'audio',
    content: [{
      type: 'audioText',
      content: [{
        type: 'text',
        text: '123'
      }]
    }]
  }]
}

markRule

节点解析为编辑器 marks。类似 tiptap 的 mark 规则,将包裹修饰的标签,转换为 marks 属性

parseHTML('<p><strong>加粗</strong></p>', {
    markRule: [{
      type: 'strong',
      mark: {type: 'bold'}
    }]
  }).doc

// result
{
  type: 'doc',
  content: [{
    type: 'p',
    content: [{
      type: 'text',
      marks: [
        {type: 'bold'}
      ],
      text: '加粗'
    }]
  }]
}

selfClose

自定义自闭合标签

常见的自闭合标签库已处理,可以额外指定自闭合标签

注意:如果标签自带反斜杠,则无需配置,例如 <note />

parseHTML('<p><note>123</p>', {
  selfClose: ['note']
}).doc

{
  type: 'doc',
  content: [{
    type: 'p',
    content: [{
      type: 'note',
    }, {
      type: 'text',
      text: '123'
    }]
  }]
}