Socket
Socket
Sign inDemoInstall

angular-html-parser

Package Overview
Dependencies
1
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    angular-html-parser

A HTML parser extracted from Angular with some modifications


Version published
Maintainers
3
Install size
348 kB
Created

Changelog

Source

14.0.1 (2022-06-08)

bazel

| Commit | Type | Description | | -- | -- | -- | | b00d237c0e | fix | update API extractor version (#46259) | | 9a0a7bac21 | perf | reduce input files for ng_package rollup and type bundle actions (#46187) |

forms

| Commit | Type | Description | | -- | -- | -- | | dde0b7f4b3 | fix | allow FormBuilder.group(...) to accept optional fields. (#46253) |

Special Thanks

Adrien Crivelli, Alan Agius, Alex Rickabaugh, Andrew Kushnir, Andrew Scott, Dylan Hunn, Fabrizio Fallico, George Kalpakas, Jelle Bruisten, JoostK, Kristiyan Kostadinov, Krzysztof Platis, Paul Gschwendtner, Phalgun Vaddepalli, San Leen, dario-piotrowicz, mgechev and wellWINeo

<!-- CHANGELOG SPLIT MARKER -->

<a name="14.0.0"></a>

Readme

Source

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;
}

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

FAQs

Last updated on 30 Jan 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc