detect-is-it-html-or-xhtml 5.0.5 → 5.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-2021 Roy Revelt and other contributors
3
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -26,18 +26,17 @@
26
26
 
27
27
  ## Install
28
28
 
29
- This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
29
+ The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `4.1.0`.
30
30
 
31
31
  ```bash
32
32
  npm i detect-is-it-html-or-xhtml
33
33
  ```
34
34
 
35
- If you need a legacy version which works with `require`, use version 4.1.0
36
-
37
35
  ## Quick Take
38
36
 
39
37
  ```js
40
38
  import { strict as assert } from "assert";
39
+
41
40
  import { detectIsItHTMLOrXhtml } from "detect-is-it-html-or-xhtml";
42
41
 
43
42
  assert.equal(
@@ -50,7 +49,7 @@ assert.equal(
50
49
 
51
50
  ## Documentation
52
51
 
53
- Please [visit codsen.com](https://codsen.com/os/detect-is-it-html-or-xhtml/) for a full description of the API and examples.
52
+ Please [visit codsen.com](https://codsen.com/os/detect-is-it-html-or-xhtml/) for a full description of the API.
54
53
 
55
54
  ## Contributing
56
55
 
@@ -60,6 +59,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
60
59
 
61
60
  MIT License
62
61
 
63
- Copyright (c) 2010-2021 Roy Revelt and other contributors
62
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
64
63
 
65
64
  <img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
@@ -1,56 +1,10 @@
1
1
  /**
2
2
  * @name detect-is-it-html-or-xhtml
3
3
  * @fileoverview Answers, is the string input string more an HTML or XHTML (or neither)
4
- * @version 5.0.5
4
+ * @version 5.0.11
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/detect-is-it-html-or-xhtml/}
8
8
  */
9
9
 
10
- var version$1 = "5.0.5";
11
-
12
- const version = version$1;
13
- function detectIsItHTMLOrXhtml(input) {
14
- function existy(x) {
15
- return x != null;
16
- }
17
- if (!input) {
18
- return null;
19
- }
20
- if (typeof input !== "string") {
21
- throw new TypeError("detect-is-it-html-or-xhtml: [THROW_ID_01] Input must be string");
22
- }
23
- const metaTag = /<\s*!\s*doctype[^>]*>/im;
24
- const imgTag = /<\s*img[^>]*>/gi;
25
- const brTag = /<\s*br[^>]*>/gi;
26
- const hrTag = /<\s*hr[^>]*>/gi;
27
- const closingSlash = /\/\s*>/g;
28
- const extractedMetaTag = input.match(metaTag);
29
- if (extractedMetaTag) {
30
- const xhtmlRegex = /xhtml/gi;
31
- const svgRegex = /svg/gi;
32
- if (extractedMetaTag[0].match(xhtmlRegex) || extractedMetaTag[0].match(svgRegex)) {
33
- return "xhtml";
34
- }
35
- return "html";
36
- }
37
- const allImageTagsArr = input.match(imgTag) || [];
38
- const allBRTagsArr = input.match(brTag) || [];
39
- const allHRTagsArr = input.match(hrTag) || [];
40
- const allConcernedTagsArr = allImageTagsArr.concat(allBRTagsArr).concat(allHRTagsArr);
41
- if (allConcernedTagsArr.length === 0) {
42
- return null;
43
- }
44
- let slashCount = 0;
45
- for (let i = 0, len = allConcernedTagsArr.length; i < len; i++) {
46
- if (existy(allConcernedTagsArr[i].match(closingSlash))) {
47
- slashCount += 1;
48
- }
49
- }
50
- if (slashCount > allConcernedTagsArr.length / 2) {
51
- return "xhtml";
52
- }
53
- return "html";
54
- }
55
-
56
- export { detectIsItHTMLOrXhtml, version };
10
+ var i="5.0.11";var T=i;function b(e){function o(t){return t!=null}if(!e)return null;if(typeof e!="string")throw new TypeError("detect-is-it-html-or-xhtml: [THROW_ID_01] Input must be string");let c=/<\s*!\s*doctype[^>]*>/im,a=/<\s*img[^>]*>/gi,m=/<\s*br[^>]*>/gi,h=/<\s*hr[^>]*>/gi,d=/\/\s*>/g,s=e.match(c);if(s){let t=/xhtml/gi,l=/svg/gi;return s[0].match(t)||s[0].match(l)?"xhtml":"html"}let u=e.match(a)||[],p=e.match(m)||[],g=e.match(h)||[],r=u.concat(p).concat(g);if(r.length===0)return null;let n=0;for(let t=0,l=r.length;t<l;t++)o(r[t].match(d))&&(n+=1);return n>r.length/2?"xhtml":"html"}export{b as detectIsItHTMLOrXhtml,T as version};
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name detect-is-it-html-or-xhtml
3
3
  * @fileoverview Answers, is the string input string more an HTML or XHTML (or neither)
4
- * @version 5.0.5
4
+ * @version 5.0.11
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/detect-is-it-html-or-xhtml/}
8
8
  */
9
9
 
10
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).detectIsItHtmlOrXhtml={})}(this,(function(t){"use strict";t.detectIsItHTMLOrXhtml=function(t){if(!t)return null;if("string"!=typeof t)throw new TypeError("detect-is-it-html-or-xhtml: [THROW_ID_01] Input must be string");const e=/\/\s*>/g,n=t.match(/<\s*!\s*doctype[^>]*>/im);if(n){const t=/svg/gi;return n[0].match(/xhtml/gi)||n[0].match(t)?"xhtml":"html"}const i=t.match(/<\s*img[^>]*>/gi)||[],l=t.match(/<\s*br[^>]*>/gi)||[],o=t.match(/<\s*hr[^>]*>/gi)||[],r=i.concat(l).concat(o);if(0===r.length)return null;let s=0;for(let t=0,n=r.length;t<n;t++)null!=r[t].match(e)&&(s+=1);return s>r.length/2?"xhtml":"html"},t.version="5.0.5",Object.defineProperty(t,"__esModule",{value:!0})}));
10
+ var detectIsItHtmlOrXhtml=(()=>{var a=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var b=t=>a(t,"__esModule",{value:!0});var v=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},j=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of f(e))!T.call(t,s)&&(r||s!=="default")&&a(t,s,{get:()=>e[s],enumerable:!(n=y(e,s))||n.enumerable});return t};var R=(t=>(e,r)=>t&&t.get(e)||(r=j(b({}),e,1),t&&t.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var A={};v(A,{detectIsItHTMLOrXhtml:()=>k,version:()=>I});var h="5.0.11";var I=h;function k(t){function e(l){return l!=null}if(!t)return null;if(typeof t!="string")throw new TypeError("detect-is-it-html-or-xhtml: [THROW_ID_01] Input must be string");let r=/<\s*!\s*doctype[^>]*>/im,n=/<\s*img[^>]*>/gi,s=/<\s*br[^>]*>/gi,d=/<\s*hr[^>]*>/gi,u=/\/\s*>/g,o=t.match(r);if(o){let l=/xhtml/gi,c=/svg/gi;return o[0].match(l)||o[0].match(c)?"xhtml":"html"}let p=t.match(n)||[],g=t.match(s)||[],x=t.match(d)||[],i=p.concat(g).concat(x);if(i.length===0)return null;let m=0;for(let l=0,c=i.length;l<c;l++)e(i[l].match(u))&&(m+=1);return m>i.length/2?"xhtml":"html"}return R(A);})();
@@ -1,6 +1,7 @@
1
1
  // Quick Take
2
2
 
3
3
  import { strict as assert } from "assert";
4
+
4
5
  import { detectIsItHTMLOrXhtml } from "../dist/detect-is-it-html-or-xhtml.esm.js";
5
6
 
6
7
  assert.equal(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "detect-is-it-html-or-xhtml",
3
- "version": "5.0.5",
3
+ "version": "5.0.11",
4
4
  "description": "Answers, is the string input string more an HTML or XHTML (or neither)",
5
5
  "keywords": [
6
6
  "check",
@@ -37,93 +37,36 @@
37
37
  },
38
38
  "types": "types/index.d.ts",
39
39
  "scripts": {
40
- "build": "rollup -c",
41
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
42
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
43
- "clean_types": "../../scripts/cleanTypes.js",
44
- "dev": "rollup -c --dev",
45
- "devunittest": "npm run dev && tap --only -R 'base'",
46
- "esbuild": "node '../../scripts/esbuild.js'",
47
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
48
- "format": "npm run lect && npm run prettier && npm run lint",
49
- "lect": "lect",
50
- "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
51
- "perf": "node perf/check",
52
- "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
53
- "republish": "npm publish || :",
54
- "tap": "tap",
55
- "pretest": "npm run build",
56
- "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
57
- "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
58
- "tsc": "tsc",
59
- "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
40
+ "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
41
+ "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
42
+ "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
43
+ "examples": "node '../../ops/scripts/run-examples.js'",
44
+ "lect": "node '../../ops/lect/lect.js'",
45
+ "letspublish": "yarn publish || :",
46
+ "lint": "eslint . --fix",
47
+ "perf": "node perf/check.js",
48
+ "prepare": "echo 'ready'",
49
+ "prettier": "prettier",
50
+ "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
51
+ "pretest": "yarn run lect && yarn run build",
52
+ "test": "c8 yarn run unit && yarn run examples && yarn run lint",
53
+ "unit": "uvu test"
60
54
  },
61
- "tap": {
62
- "check-coverage": false,
63
- "coverage-report": [
64
- "json-summary",
65
- "text"
66
- ],
67
- "node-arg": [
68
- "--no-warnings",
69
- "--experimental-loader",
70
- "@istanbuljs/esm-loader-hook"
55
+ "engines": {
56
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
57
+ },
58
+ "c8": {
59
+ "check-coverage": true,
60
+ "exclude": [
61
+ "**/test/**/*.*"
71
62
  ],
72
- "timeout": 0
63
+ "lines": 100
73
64
  },
74
65
  "lect": {
75
66
  "licence": {
76
67
  "extras": [
77
68
  ""
78
69
  ]
79
- },
80
- "req": "{ detectIsItHTMLOrXhtml }",
81
- "various": {
82
- "devDependencies": []
83
70
  }
84
- },
85
- "dependencies": {
86
- "@babel/runtime": "^7.16.0"
87
- },
88
- "devDependencies": {
89
- "@babel/cli": "^7.16.0",
90
- "@babel/core": "^7.16.0",
91
- "@babel/node": "^7.16.0",
92
- "@babel/plugin-external-helpers": "^7.16.0",
93
- "@babel/plugin-proposal-class-properties": "^7.16.0",
94
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
95
- "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
96
- "@babel/plugin-proposal-optional-chaining": "^7.16.0",
97
- "@babel/plugin-transform-runtime": "^7.16.0",
98
- "@babel/preset-env": "^7.16.0",
99
- "@babel/preset-typescript": "^7.16.0",
100
- "@babel/register": "^7.16.0",
101
- "@istanbuljs/esm-loader-hook": "^0.1.2",
102
- "@rollup/plugin-babel": "^5.3.0",
103
- "@rollup/plugin-commonjs": "^21.0.1",
104
- "@rollup/plugin-json": "^4.1.0",
105
- "@rollup/plugin-node-resolve": "^13.0.6",
106
- "@rollup/plugin-strip": "^2.1.0",
107
- "@rollup/plugin-typescript": "^8.3.0",
108
- "@types/node": "^16.11.6",
109
- "@types/tap": "^15.0.5",
110
- "@typescript-eslint/eslint-plugin": "^5.3.0",
111
- "@typescript-eslint/parser": "^5.3.0",
112
- "core-js": "^3.19.1",
113
- "cross-env": "^7.0.3",
114
- "eslint": "^8.2.0",
115
- "lect": "^0.18.5",
116
- "rollup": "^2.59.0",
117
- "rollup-plugin-ascii": "^0.0.3",
118
- "rollup-plugin-banner": "^0.2.1",
119
- "rollup-plugin-cleanup": "^3.2.1",
120
- "rollup-plugin-dts": "^4.0.1",
121
- "rollup-plugin-terser": "^7.0.2",
122
- "tap": "^15.0.10",
123
- "tslib": "^2.3.1",
124
- "typescript": "^4.4.4"
125
- },
126
- "engines": {
127
- "node": ">=12"
128
71
  }
129
72
  }
package/types/index.d.ts CHANGED
File without changes
package/examples/api.json DELETED
@@ -1 +0,0 @@
1
- {"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; detectIsItHTMLOrXhtml &#x7D; from \"detect-is-it-html-or-xhtml\";\n\nassert.equal(\n detectIsItHTMLOrXhtml(\n `<img src=\"some.jpg\" width=\"zzz\" height=\"zzz\" border=\"0\" style=\"display:block;\" alt=\"zzz\"/>`\n ),\n \"xhtml\"\n);"}}