8.0.1 • Published 1 month ago
angular-html-parser v8.0.1
angular-html-parser
An HTML parser extracted from Angular with some modifications
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 toElement
andAttribute
- 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
8.0.1
1 month ago
8.0.0
1 month ago
7.0.0
3 months ago
7.0.1
3 months ago
6.0.1
6 months ago
6.0.0
6 months ago
6.0.2
6 months ago
5.2.0
1 year ago
5.1.0
1 year ago
5.0.2
1 year ago
5.0.1
1 year ago
5.0.0
1 year ago
4.0.1
2 years ago
4.0.0
2 years ago
3.0.0
2 years ago
2.1.0
2 years ago
2.0.0
2 years ago
1.8.0
4 years ago
1.7.1
5 years ago
1.7.0
5 years ago
1.6.0
5 years ago
1.5.0
5 years ago
1.4.0
5 years ago
1.3.0
5 years ago
1.2.0
6 years ago
1.1.0
6 years ago
1.0.0
6 years ago