Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hast

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hast

HTML processor powered by plugins

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

hast

hast is an HTML processor powered by plugins. Lots of bla. Bla and Bla. 100% coverbla.

hast is not (yet) fit for human consumption.

Just like what retext did for natural language and mdast for markdown, now comes HTML.

Installation

npm:

npm install wooorm/hast

API

hast.process(value, done?)

Parse an HTML document, apply plugins to it, and compile it.

Signatures

  • doc = hast().process(value, options?, done?).

  • done (function(Error?, File?, string?)) — Callback invoked when the is generated with either an error, or a result. Only strictly needed when async plugins are used.

Returns

string or null: A document. The result is null if a plugin is asynchronous, in which case the callback done should’ve been passed (don’t worry: plugin creators make sure you know it’s async).

hast.use(plugin, options?)

Change the way hast works by using a plugin.

Signatures

  • processor = hast.use(plugin, options?);
  • processor = hast.use(plugins).

Parameters

  • plugin (Function) — A Plugin;
  • plugins (Array.<Function>) — A list of Plugins;
  • options (Object?) — Passed to plugin. Specified by its documentation.

Returns

Object: an instance of HAST: The returned object functions just like hast, but caches the used plugins. This provides the ability to chain use calls to use multiple plugins, but ensures the functioning of the hast module does not change for other dependents.

Nodes

hast exposes the processed document using unist nodes and files (so there are already tools for working with the syntax tree).

interface Node {
    type: string;
    data: Data | null;
}

interface Data { }

interface Properties { }

interface Parent <: Node {
    children: [];
}

interface Element <: Parent {
    type: "element";
    tagName: string;
    properties: Properties;
    children: [];
}

interface Root <: Parent {
    type: "root";
}

interface Directive <: Node {
    type: "directive";
    value: string;
}

interface Comment <: Node {
    type: "comment";
    value: string;
}

interface CharacterData <: Node {
    type: "characterData";
    value: string;
}

interface Text <: Node {
    type: "text";
    value: string;
}

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 09 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc