posthtml-parser
Advanced tools
Comparing version 0.9.1 to 0.10.0
@@ -0,3 +1,12 @@ | ||
## 0.10.0 (2021-07-28) | ||
* refactor: parse now export not default ([f8ae42d](https://github.com/posthtml/posthtml-parser/commit/f8ae42d)) | ||
* perf: resolve types ([9ed9bd0](https://github.com/posthtml/posthtml-parser/commit/9ed9bd0)) | ||
## <small>0.9.1 (2021-07-26)</small> | ||
* 0.9.1 ([a03017e](https://github.com/posthtml/posthtml-parser/commit/a03017e)) | ||
* Update readme.md ([7081062](https://github.com/posthtml/posthtml-parser/commit/7081062)) | ||
* test: dom nest parsing issues #76 ([fdfe82e](https://github.com/posthtml/posthtml-parser/commit/fdfe82e)), closes [#76](https://github.com/posthtml/posthtml-parser/issues/76) | ||
@@ -13,3 +22,2 @@ * test: remove only ([78b7fc7](https://github.com/posthtml/posthtml-parser/commit/78b7fc7)) | ||
* perf: type for replace ([94ebb8d](https://github.com/posthtml/posthtml-parser/commit/94ebb8d)) | ||
* Update readme.md ([7081062](https://github.com/posthtml/posthtml-parser/commit/7081062)) | ||
@@ -16,0 +24,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT6SARJYHjs = require('./chunk.T6SARJYH.js');var _htmlparser2 = require('htmlparser2');var O={lowerCaseTags:!1,lowerCaseAttributeNames:!1,decodeEntities:!1},v=[{name:"!doctype",start:"<",end:">"}],w=(a,f={})=>{let d=new (0, _chunkT6SARJYHjs.a)(a),s=[],i=[];function c(){return s[s.length-1]}function g(e,t){return e.name instanceof RegExp?new RegExp(e.name.source,"i").test(t):t===e.name}function b(e){let t={};return Object.keys(e).forEach(n=>{let o={};o[n]=String(e[n]).replace(/"/g,'"'),Object.assign(t,o)}),t}function h(e,t){var p;let n=v.concat((p=f.directives)!=null?p:[]),o=c();for(let u of n){let l=u.start+t+u.end;if(g(u,e.toLowerCase())){if(o===void 0){i.push(l);return}typeof o=="object"&&(o.content===void 0&&(o.content=[]),o.content.push(l))}}}function m(e){let t=`<!--${e}-->`,n=c();if(n===void 0){i.push(t);return}typeof n=="object"&&(n.content===void 0&&(n.content=[]),n.content.push(t))}function N(e,t){let n=d.getPosition(r.startIndex),o={tag:e};f.sourceLocations&&(o.location={start:n,end:n}),Object.keys(t).length>0&&(o.attrs=b(t)),s.push(o)}function y(){let e=s.pop();if(e&&typeof e=="object"&&e.location&&r.endIndex!==null&&(e.location.end=d.getPosition(r.endIndex)),e){let t=c();if(s.length<=0){i.push(e);return}typeof t=="object"&&(t.content===void 0&&(t.content=[]),t.content.push(e))}}function A(e){let t=c();if(t===void 0){i.push(e);return}if(typeof t=="object"){if(t.content&&t.content.length>0){let n=t.content[t.content.length-1];if(typeof n=="string"&&!n.startsWith("<!--")){t.content[t.content.length-1]=`${n}${e}`;return}}t.content===void 0&&(t.content=[]),t.content.push(e)}}let r=new (0, _htmlparser2.Parser)({onprocessinginstruction:h,oncomment:m,onopentag:N,onclosetag:y,ontext:A},{...O,...f});return r.write(a),r.end(),i},T= exports.default =w;exports.default = T; | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT6SARJYHjs = require('./chunk.T6SARJYH.js');var _htmlparser2 = require('htmlparser2');var j={lowerCaseTags:!1,lowerCaseAttributeNames:!1,decodeEntities:!1},v=[{name:"!doctype",start:"<",end:">"}],O= exports.parser =(u,a={})=>{let d=new (0, _chunkT6SARJYHjs.a)(u),r=[],i=[];function c(){return r[r.length-1]}function l(e,t){return e.name instanceof RegExp?new RegExp(e.name.source,"i").test(t):t===e.name}function y(e){let t={};return Object.keys(e).forEach(n=>{let o={};o[n]=String(e[n]).replace(/"/g,'"'),Object.assign(t,o)}),t}function b(e,t){var p;let n=v.concat((p=a.directives)!=null?p:[]),o=c();for(let f of n){let g=f.start+t+f.end;if(l(f,e.toLowerCase())){if(o===void 0){i.push(g);return}typeof o=="object"&&(o.content===void 0&&(o.content=[]),Array.isArray(o.content)&&o.content.push(g))}}}function A(e){let t=c(),n=`<!--${e}-->`;if(t===void 0){i.push(n);return}typeof t=="object"&&(t.content===void 0&&(t.content=[]),Array.isArray(t.content)&&t.content.push(n))}function x(e,t){let n=d.getPosition(s.startIndex),o={tag:e};a.sourceLocations&&(o.location={start:n,end:n}),Object.keys(t).length>0&&(o.attrs=y(t)),r.push(o)}function h(){let e=r.pop();if(e&&typeof e=="object"&&e.location&&s.endIndex!==null&&(e.location.end=d.getPosition(s.endIndex)),e){let t=c();if(r.length<=0){i.push(e);return}typeof t=="object"&&(t.content===void 0&&(t.content=[]),Array.isArray(t.content)&&t.content.push(e))}}function m(e){let t=c();if(t===void 0){i.push(e);return}if(typeof t=="object"){if(t.content&&Array.isArray(t.content)&&t.content.length>0){let n=t.content[t.content.length-1];if(typeof n=="string"&&!n.startsWith("<!--")){t.content[t.content.length-1]=`${n}${e}`;return}}t.content===void 0&&(t.content=[]),Array.isArray(t.content)&&t.content.push(e)}}let s=new (0, _htmlparser2.Parser)({onprocessinginstruction:b,oncomment:A,onopentag:x,onclosetag:h,ontext:m},{...j,...a});return s.write(u),s.end(),i};exports.parser = O; |
{ | ||
"name": "posthtml-parser", | ||
"version": "0.9.1", | ||
"version": "0.10.0", | ||
"description": "Parse HTML/XML to PostHTMLTree", | ||
@@ -28,3 +28,3 @@ "license": "MIT", | ||
"version": "conventional-changelog -i changelog.md -s -r 0 && git add changelog.md", | ||
"build": "rm -rf dist && tsup src/*.ts --minify", | ||
"build": "rm -rf dist && tsup src/*.ts --dts --minify", | ||
"dev": "npm run build -- --watch", | ||
@@ -66,3 +66,3 @@ "test": "xo && c8 ava", | ||
}, | ||
"types": "types/index.d.ts" | ||
"types": "dist/index.d.ts" | ||
} |
import test from 'ava'; | ||
import parser from '../src'; | ||
import { parser } from '../src'; | ||
@@ -4,0 +4,0 @@ test('should be parse doctype in uppercase', t => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41433
20
372