Initial commit

This commit is contained in:
2024-11-03 17:41:45 +01:00
commit c1640c1754
8043 changed files with 775536 additions and 0 deletions

1
node_modules/posthtml-parser/dist/chunk.2UQLUWPH.js generated vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var i=class{constructor(t){this.source=t,this.lastPosition={line:1,column:1},this.lastIndex=0}getPosition(t){if(t<this.lastIndex)throw new Error("Source indices must be monotonic");for(;this.lastIndex<t;)this.source.charCodeAt(this.lastIndex)===10?(this.lastPosition.line++,this.lastPosition.column=1):this.lastPosition.column++,this.lastIndex++;return{line:this.lastPosition.line,column:this.lastPosition.column}}};exports.a = i;

27
node_modules/posthtml-parser/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import { ParserOptions } from 'htmlparser2';
import { SourceLocation } from './location-tracker';
declare type Directive = {
name: string | RegExp;
start: string;
end: string;
};
declare type Options = {
directives?: Directive[];
sourceLocations?: boolean;
recognizeNoValueAttribute?: boolean;
} & ParserOptions;
declare type Tag = string | boolean;
declare type Attributes = Record<string, string | number | boolean>;
declare type Content = NodeText | Array<Node | Node[]>;
declare type NodeText = string | number;
declare type NodeTag = {
tag?: Tag;
attrs?: Attributes;
content?: Content;
location?: SourceLocation;
};
declare type Node = NodeText | NodeTag;
declare const parser: (html: string, options?: Options) => Node[];
export { Attributes, Content, Directive, Node, NodeTag, NodeText, Options, Tag, parser };

1
node_modules/posthtml-parser/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk2UQLUWPHjs = require('./chunk.2UQLUWPH.js');var _htmlparser2 = require('htmlparser2');var I={lowerCaseTags:!1,lowerCaseAttributeNames:!1,decodeEntities:!1},P=[{name:"!doctype",start:"<",end:">"}],w= exports.parser =(g,c={})=>{let a=new (0, _chunk2UQLUWPHjs.a)(g),i=[],s=[],p=0,f={};function u(){return i[i.length-1]}function y(n,t){return n.name instanceof RegExp?new RegExp(n.name.source,"i").test(t):t===n.name}function x(n){let t={};return Object.keys(n).forEach(e=>{let o={};o[e]=String(n[e]).replace(/&quot;/g,'"'),c.recognizeNoValueAttribute&&f[e]&&(o[e]=!0),Object.assign(t,o)}),t}function A(n,t){var l;let e=P.concat((l=c.directives)!=null?l:[]),o=u();for(let d of e){let b=d.start+t+d.end;if(y(d,n.toLowerCase())){if(o===void 0){s.push(b);return}typeof o=="object"&&(o.content===void 0&&(o.content=[]),Array.isArray(o.content)&&o.content.push(b))}}}function N(n){let t=u(),e=`<!--${n}-->`;if(t===void 0){s.push(e);return}typeof t=="object"&&(t.content===void 0&&(t.content=[]),Array.isArray(t.content)&&t.content.push(e))}function m(n,t,e){e===void 0&&(f[n]=!0)}function h(n,t){let e={tag:n};c.sourceLocations&&(e.location={start:a.getPosition(r.startIndex),end:a.getPosition(r.endIndex)},p=r.endIndex),Object.keys(t).length>0&&(e.attrs=x(t)),f={},i.push(e)}function T(n,t){let e=i.pop();if(e&&typeof e=="object"&&e.location&&r.endIndex!==null&&(t?p<r.startIndex&&(e.location.end=a.getPosition(r.startIndex-1)):e.location.end=a.getPosition(r.endIndex)),e){let o=u();if(i.length<=0){s.push(e);return}typeof o=="object"&&(o.content===void 0&&(o.content=[]),Array.isArray(o.content)&&o.content.push(e))}}function v(n){let t=u();if(t===void 0){s.push(n);return}if(typeof t=="object"){if(t.content&&Array.isArray(t.content)&&t.content.length>0){let e=t.content[t.content.length-1];if(typeof e=="string"&&!e.startsWith("<!--")){t.content[t.content.length-1]=`${e}${n}`;return}}t.content===void 0&&(t.content=[]),Array.isArray(t.content)&&t.content.push(n)}}let r=new (0, _htmlparser2.Parser)({onprocessinginstruction:A,oncomment:N,onattribute:m,onopentag:h,onclosetag:T,ontext:v},{...I,...c});return r.write(g),r.end(),s};exports.parser = w;

View File

@@ -0,0 +1,17 @@
declare type SourceLocation = {
start: Position;
end: Position;
};
declare type Position = {
line: number;
column: number;
};
declare class LocationTracker {
private readonly source;
private lastPosition;
private lastIndex;
constructor(source: string);
getPosition(index: number): Position;
}
export { LocationTracker, Position, SourceLocation };

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk2UQLUWPHjs = require('./chunk.2UQLUWPH.js');exports.LocationTracker = _chunk2UQLUWPHjs.a;

22
node_modules/posthtml-parser/license generated vendored Normal file
View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2015 Ivan Voischev <voischev.ivan@ya.ru>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

69
node_modules/posthtml-parser/package.json generated vendored Normal file
View File

@@ -0,0 +1,69 @@
{
"name": "posthtml-parser",
"version": "0.11.0",
"description": "Parse HTML/XML to PostHTMLTree",
"license": "MIT",
"repository": "posthtml/posthtml-parser",
"homepage": "https://github.com/posthtml/posthtml-parser#readme",
"bugs": {
"url": "https://github.com/posthtml/posthtml-parser/issues"
},
"author": "Ivan Voischev <voischev@posthtml.org>",
"contributors": [
{
"name": "Ivan Voischev",
"email": "voischev@posthtml.org"
},
{
"name": "Ivan Demidov",
"email": "scrum@posthtml.org"
}
],
"main": "dist",
"engines": {
"node": ">=12"
},
"scripts": {
"version": "conventional-changelog -i changelog.md -s -r 0 && git add changelog.md",
"build": "rm -rf dist && tsup src/*.ts --dts --minify",
"dev": "npm run build -- --watch",
"test": "xo && c8 ava",
"pretest": "clinton",
"prepare": "npm run build"
},
"files": [
"dist"
],
"keywords": [
"html",
"xml",
"parser",
"posthtml",
"posthtmltree"
],
"dependencies": {
"htmlparser2": "^7.1.1"
},
"devDependencies": {
"@antfu/eslint-config-ts": "^0.4.3",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-angular": "^11.0.0",
"@types/node": "^14.14.25",
"ava": "^3.13.0",
"c8": "^7.5.0",
"clinton": "^0.14.0",
"conventional-changelog-cli": "^2.0.34",
"esbuild-register": "^2.0.0",
"eslint": "^7.19.0",
"esm": "^3.2.25",
"husky": "^4.3.8",
"lint-staged": "^10.5.3",
"rewire": "^5.0.0",
"rimraf": "^3.0.0",
"ts-node": "^9.0.0",
"tsup": "^3.7.1",
"typescript": "^4.0.5",
"xo": "^0.37.1"
},
"types": "dist/index.d.ts"
}

130
node_modules/posthtml-parser/readme.md generated vendored Normal file
View File

@@ -0,0 +1,130 @@
# posthtml-parser
[![npm version](https://badge.fury.io/js/posthtml-parser.svg)](http://badge.fury.io/js/posthtml-parser)
[![Build Status](https://travis-ci.org/posthtml/posthtml-parser.svg?branch=master)](https://travis-ci.org/posthtml/posthtml-parser?branch=master)
[![Coverage Status](https://coveralls.io/repos/posthtml/posthtml-parser/badge.svg?branch=master)](https://coveralls.io/r/posthtml/posthtml-parser?branch=master)
Parse HTML/XML to [PostHTML AST](https://github.com/posthtml/posthtml-parser#posthtml-ast-format).
More about [PostHTML](https://github.com/posthtml/posthtml#readme)
## Install
[NPM](http://npmjs.com) install
```
$ npm install posthtml-parser
```
## Usage
#### Input HTML
```html
<a class="animals" href="#">
<span class="animals__cat" style="background: url(cat.png)">Cat</span>
</a>
```
```js
import { parser } from 'posthtml-parser'
import fs from 'fs'
const html = fs.readFileSync('path/to/input.html', 'utf-8')
console.log(parser(html)) // Logs a PostHTML AST
```
#### input HTML
```html
<a class="animals" href="#">
<span class="animals__cat" style="background: url(cat.png)">Cat</span>
</a>
```
#### Result PostHTMLTree
```js
[{
tag: 'a',
attrs: {
class: 'animals',
href: '#'
},
content: [
'\n ',
{
tag: 'span',
attrs: {
class: 'animals__cat',
style: 'background: url(cat.png)'
},
content: ['Cat']
},
'\n'
]
}]
```
## PostHTML AST Format
Any parser being used with PostHTML should return a standard PostHTML [Abstract Syntax Tree](https://www.wikiwand.com/en/Abstract_syntax_tree) (AST). Fortunately, this is a very easy format to produce and understand. The AST is an array that can contain strings and objects. Any strings represent plain text content to be written to the output. Any objects represent HTML tags.
Tag objects generally look something like this:
```js
{
tag: 'div',
attrs: {
class: 'foo'
},
content: ['hello world!']
}
```
Tag objects can contain three keys. The `tag` key takes the name of the tag as the value. This can include custom tags. The optional `attrs` key takes an object with key/value pairs representing the attributes of the html tag. A boolean attribute has an empty string as its value. Finally, the optional `content` key takes an array as its value, which is a PostHTML AST. In this manner, the AST is a tree that should be walked recursively.
## Options
### `directives`
Type: `Array`
Default: `[{name: '!doctype', start: '<', end: '>'}]`
Description: *Adds processing of custom directives. Note: The property ```name``` in custom directives can be ```String``` or ```RegExp``` type*
### `xmlMode`
Type: `Boolean`
Default: `false`
Description: *Indicates whether special tags (`<script>` and `<style>`) should get special treatment and if "empty" tags (eg. `<br>`) can have children. If false, the content of special tags will be text only. For feeds and other XML content (documents that don't consist of HTML), set this to true.*
### `decodeEntities`
Type: `Boolean`
Default: `false`
Description: *If set to true, entities within the document will be decoded.*
### `lowerCaseTags`
Type: `Boolean`
Default: `false`
Description: *If set to true, all tags will be lowercased. If `xmlMode` is disabled.*
### `lowerCaseAttributeNames`
Type: `Boolean`
Default: `false`
Description: *If set to true, all attribute names will be lowercased. This has noticeable impact on speed.*
### `recognizeCDATA`
Type: `Boolean`
Default: `false`
Description: *If set to true, CDATA sections will be recognized as text even if the `xmlMode` option is not enabled. NOTE: If `xmlMode` is set to `true` then CDATA sections will always be recognized as text.*
### `recognizeSelfClosing`
Type: `Boolean`
Default: `false`
Description: *If set to true, self-closing tags will trigger the `onclosetag` event even if `xmlMode` is not set to `true`. NOTE: If `xmlMode` is set to `true` then self-closing tags will always be recognized.*
### `sourceLocations`
Type: `Boolean`
Default: `false`
Description: *If set to true, AST nodes will have a `location` property containing the `start` and `end` line and column position of the node.*
### `recognizeNoValueAttribute`
Type: `Boolean`
Default: `false`
Description: *If set to true, AST nodes will recognize attribute with no value and mark as `true` which will be correctly rendered by `posthtml-render` package*
## License
[MIT](LICENSE)