angular-html-parser
A HTML parser extracted from Angular with some modifications
Last updated 3 years ago by sosukesuzuki .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install angular-html-parser 
SYNC missed versions from official npm registry.

angular-html-parser

npm

An HTML parser extracted from Angular with some modifications

Changelog

Install

# using npm
npm install --save angular-html-parser

# using yarn
yarn add angular-html-parser

Usage

import {parse} from 'angular-html-parser';

const {rootNodes, errors} = parse(`
<!DOCTYPE html>
<html>
  <head>
    <title>Hello world!</title>
  </head>
  <body>
    <div>Hello world!</div>
  </body>
</html>
`);

API

declare function parse(input: string, options?: Options): ng.ParseTreeResult;

interface Options {
  /**
   * any element can self close
   *
   * defaults to false
   */
  canSelfClose?: boolean;
  /**
   * support [`htm`](https://github.com/developit/htm) component closing tags (`<//>`)
   *
   * defaults to false
   */
  allowHtmComponentClosingTags?: boolean;
  /**
   * do not lowercase tag names before querying their tag definitions
   *
   * defaults to false
   */
  isTagNameCaseSensitive?: boolean;
  /**
   * customize tag content type
   *
   * defaults to the content type defined in the HTML spec
   */
  getTagContentType?: (
    tagName: string,
    prefix: string,
    hasParent: boolean,
    attrs: Array<{prefix: string; name: string; value?: string | undefined}>
  ) => void | ng.TagContentType;
  /**
   * tokenize angular control flow block syntax
   */
  tokenizeAngularBlocks?: boolean,
  /**
   * tokenize angular let declaration syntax
   */
  tokenizeAngularLetDeclaration?: boolean,
}

Modifications

  • add CDATA node
  • add DocType node
  • add nameSpan field to Element and Attribute
  • allow case-insensitive closing tags for non-foreign elements
  • fix Comment#sourceSpan
  • support bogus comments (<!...>, <?...>)
  • support full named entities (fixed upstream)
  • add type property to nodes
  • value span for attributes includes quotes

Development

# build
yarn run build

# test
yarn run test

License

MIT © Ika

Current Tags

  • 10.13.0                                ...           latest (2 months ago)

51 Versions

  • 10.13.0                                ...           2 months ago
  • 10.12.0                                ...           3 months ago
  • 10.11.0                                ...           5 months ago
  • 10.10.0                                ...           5 months ago
  • 10.9.0                                ...           5 months ago
  • 10.8.0                                ...           5 months ago
  • 10.7.0                                ...           6 months ago
  • 10.6.1                                ...           6 months ago
  • 10.6.0                                ...           6 months ago
  • 10.5.0                                ...           8 months ago
  • 10.4.0                                ...           10 months ago
  • 10.3.0                                ...           a year ago
  • 10.2.1                                ...           a year ago
  • 10.1.1                                ...           a year ago
  • 10.1.0                                ...           a year ago
  • 10.0.0                                ...           a year ago
  • 9.3.0                                ...           a year ago
  • 9.2.0                                ...           a year ago
  • 9.1.1                                ...           2 years ago
  • 9.1.0                                ...           2 years ago
  • 9.0.2                                ...           2 years ago
  • 9.0.1                                ...           2 years ago
  • 9.0.0                                ...           2 years ago
  • 8.1.0                                ...           2 years ago
  • 8.0.1                                ...           2 years ago
  • 8.0.0                                ...           2 years ago
  • 7.0.1                                ...           2 years ago
  • 7.0.0                                ...           2 years ago
  • 6.0.2                                ...           2 years ago
  • 6.0.1                                ...           2 years ago
  • 6.0.0                                ...           2 years ago
  • 5.2.0                                ...           3 years ago
  • 5.1.0                                ...           3 years ago
  • 5.0.2                                ...           3 years ago
  • 5.0.1                                ...           3 years ago
  • 5.0.0                                ...           3 years ago
  • 4.0.1                                ...           4 years ago
  • 4.0.0                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.8.0                                ...           6 years ago
  • 1.7.1                                ...           6 years ago
  • 1.7.0                                ...           7 years ago
  • 1.6.0                                ...           7 years ago
  • 1.5.0                                ...           7 years ago
  • 1.4.0                                ...           7 years ago
  • 1.3.0                                ...           7 years ago
  • 1.2.0                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
Downloads
Total 112
Today 0
This Week 2
This Month 64
Last Day 0
Last Week 12
Last Month 48
Dependencies (1)
Dev Dependencies (8)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE