detect-templating-language 3.0.6 → 3.0.12
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 +1 -1
- package/README.md +4 -5
- package/dist/detect-templating-language.esm.js +2 -33
- package/dist/detect-templating-language.umd.js +20 -4
- package/examples/_quickTake.js +1 -0
- package/package.json +27 -77
- package/types/index.d.ts +1 -1
- package/examples/api.json +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
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
|
-
|
|
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, `2.1.0`.
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm i detect-templating-language
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with `require`, use version 2.1.0
|
|
36
|
-
|
|
37
35
|
## Quick Take
|
|
38
36
|
|
|
39
37
|
```js
|
|
40
38
|
import { strict as assert } from "assert";
|
|
39
|
+
|
|
41
40
|
import { detectLang } from "detect-templating-language";
|
|
42
41
|
|
|
43
42
|
// detects Nunjucks
|
|
@@ -57,7 +56,7 @@ assert.deepEqual(
|
|
|
57
56
|
|
|
58
57
|
## Documentation
|
|
59
58
|
|
|
60
|
-
Please [visit codsen.com](https://codsen.com/os/detect-templating-language/) for a full description of the API
|
|
59
|
+
Please [visit codsen.com](https://codsen.com/os/detect-templating-language/) for a full description of the API.
|
|
61
60
|
|
|
62
61
|
## Contributing
|
|
63
62
|
|
|
@@ -67,6 +66,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
67
66
|
|
|
68
67
|
MIT License
|
|
69
68
|
|
|
70
|
-
Copyright (c) 2010-
|
|
69
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
71
70
|
|
|
72
71
|
<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,41 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name detect-templating-language
|
|
3
3
|
* @fileoverview Detects various templating languages present in string
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.12
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/detect-templating-language/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
11
|
-
import { isJSP } from 'regex-is-jsp';
|
|
12
|
-
import { isJinjaSpecific } from 'regex-jinja-specific';
|
|
13
|
-
|
|
14
|
-
var version$1 = "3.0.6";
|
|
15
|
-
|
|
16
|
-
const version = version$1;
|
|
17
|
-
function detectLang(str) {
|
|
18
|
-
let name = null;
|
|
19
|
-
if (typeof str !== "string") {
|
|
20
|
-
throw new TypeError(`detect-templating-language: [THROW_ID_01] Input must be string! It was given as ${JSON.stringify(str, null, 4)} (type ${typeof str}).`);
|
|
21
|
-
}
|
|
22
|
-
if (!str) {
|
|
23
|
-
return {
|
|
24
|
-
name,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
if (isJinjaNunjucksRegex().test(str)) {
|
|
28
|
-
name = "Nunjucks";
|
|
29
|
-
if (isJinjaSpecific().test(str)) {
|
|
30
|
-
name = "Jinja";
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else if (isJSP().test(str)) {
|
|
34
|
-
name = "JSP";
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
name,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export { detectLang, version };
|
|
10
|
+
import{isJinjaNunjucksRegex as s}from"regex-is-jinja-nunjucks";import{isJSP as i}from"regex-is-jsp";import{isJinjaSpecific as p}from"regex-jinja-specific";var n="3.0.12";var d=n;function g(e){let t=null;if(typeof e!="string")throw new TypeError(`detect-templating-language: [THROW_ID_01] Input must be string! It was given as ${JSON.stringify(e,null,4)} (type ${typeof e}).`);return e?(s().test(e)?(t="Nunjucks",p().test(e)&&(t="Jinja")):i().test(e)&&(t="JSP"),{name:t}):{name:t}}export{g as detectLang,d as version};
|
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name detect-templating-language
|
|
3
3
|
* @fileoverview Detects various templating languages present in string
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.12
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/detect-templating-language/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
var detectTemplatingLanguage=(()=>{var r=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var g=e=>r(e,"__esModule",{value:!0});var m=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},y=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of l(t))!d.call(e,s)&&(n||s!=="default")&&r(e,s,{get:()=>t[s],enumerable:!(i=c(t,s))||i.enumerable});return e};var f=(e=>(t,n)=>e&&e.get(t)||(n=y(g({}),t,1),e&&e.set(t,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var h={};m(h,{detectLang:()=>x,version:()=>v});function a(){return/{%|{{|%}|}}/gi}function p(){return/<%|%>|<\s*jsp:|<\s*cms:|<\s*c:|\${\s*jsp/gi}function u(){return/(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi}var o="3.0.12";var v=o;function x(e){let t=null;if(typeof e!="string")throw new TypeError(`detect-templating-language: [THROW_ID_01] Input must be string! It was given as ${JSON.stringify(e,null,4)} (type ${typeof e}).`);return e?(a().test(e)?(t="Nunjucks",u().test(e)&&(t="Jinja")):p().test(e)&&(t="JSP"),{name:t}):{name:t}}return f(h);})();
|
|
11
11
|
/**
|
|
12
12
|
* @name regex-is-jinja-nunjucks
|
|
13
13
|
* @fileoverview Regular expression for detecting Jinja or Nunjucks code
|
|
14
|
-
* @version 3.0.
|
|
14
|
+
* @version 3.0.12
|
|
15
15
|
* @author Roy Revelt, Codsen Ltd
|
|
16
16
|
* @license MIT
|
|
17
17
|
* {@link https://codsen.com/os/regex-is-jinja-nunjucks/}
|
|
18
|
-
*/
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* @name regex-is-jsp
|
|
21
|
+
* @fileoverview Regular expression for detecting JSP (Java Server Pages) code
|
|
22
|
+
* @version 3.0.12
|
|
23
|
+
* @author Roy Revelt, Codsen Ltd
|
|
24
|
+
* @license MIT
|
|
25
|
+
* {@link https://codsen.com/os/regex-is-jsp/}
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @name regex-jinja-specific
|
|
29
|
+
* @fileoverview Regular expression for detecting Python-specific Jinja code
|
|
30
|
+
* @version 3.0.12
|
|
31
|
+
* @author Roy Revelt, Codsen Ltd
|
|
32
|
+
* @license MIT
|
|
33
|
+
* {@link https://codsen.com/os/regex-jinja-specific/}
|
|
34
|
+
*/
|
package/examples/_quickTake.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "detect-templating-language",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.12",
|
|
4
4
|
"description": "Detects various templating languages present in string",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"check",
|
|
@@ -29,92 +29,42 @@
|
|
|
29
29
|
},
|
|
30
30
|
"types": "types/index.d.ts",
|
|
31
31
|
"scripts": {
|
|
32
|
-
"build": "
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"prettier": "
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"test": "npm run test:ci && npm run perf",
|
|
48
|
-
"test:ci": "npm run unittest && npm run test:examples && npm run format",
|
|
49
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
50
|
-
"tsc": "tsc",
|
|
51
|
-
"unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
|
|
32
|
+
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
33
|
+
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
34
|
+
"devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
35
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
36
|
+
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
37
|
+
"lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
|
|
38
|
+
"letspublish": "yarn publish || :",
|
|
39
|
+
"lint": "eslint . --fix",
|
|
40
|
+
"perf": "node perf/check.js",
|
|
41
|
+
"prepare": "echo 'ready'",
|
|
42
|
+
"prettier": "prettier",
|
|
43
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
44
|
+
"pretest": "yarn run lect && yarn run build",
|
|
45
|
+
"test": "yarn run devtest",
|
|
46
|
+
"unit": "uvu test"
|
|
52
47
|
},
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
50
|
+
},
|
|
51
|
+
"c8": {
|
|
52
|
+
"check-coverage": true,
|
|
53
|
+
"exclude": [
|
|
54
|
+
"**/test/**/*.*"
|
|
59
55
|
],
|
|
60
|
-
"
|
|
56
|
+
"lines": 100
|
|
61
57
|
},
|
|
62
58
|
"lect": {
|
|
63
59
|
"licence": {
|
|
64
60
|
"extras": [
|
|
65
61
|
""
|
|
66
62
|
]
|
|
67
|
-
},
|
|
68
|
-
"req": "{ detectLang }",
|
|
69
|
-
"various": {
|
|
70
|
-
"devDependencies": []
|
|
71
63
|
}
|
|
72
64
|
},
|
|
73
65
|
"dependencies": {
|
|
74
|
-
"
|
|
75
|
-
"regex-is-
|
|
76
|
-
"regex-
|
|
77
|
-
"regex-jinja-specific": "^3.0.6"
|
|
78
|
-
},
|
|
79
|
-
"devDependencies": {
|
|
80
|
-
"@babel/cli": "^7.16.0",
|
|
81
|
-
"@babel/core": "^7.16.0",
|
|
82
|
-
"@babel/node": "^7.16.0",
|
|
83
|
-
"@babel/plugin-external-helpers": "^7.16.0",
|
|
84
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
85
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
86
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
87
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
88
|
-
"@babel/plugin-transform-runtime": "^7.16.4",
|
|
89
|
-
"@babel/preset-env": "^7.16.4",
|
|
90
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
91
|
-
"@babel/register": "^7.16.0",
|
|
92
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
93
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
94
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
95
|
-
"@rollup/plugin-json": "^4.1.0",
|
|
96
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
97
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
98
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
99
|
-
"@types/node": "^16.11.9",
|
|
100
|
-
"@types/tap": "^15.0.5",
|
|
101
|
-
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
102
|
-
"@typescript-eslint/parser": "^5.4.0",
|
|
103
|
-
"core-js": "^3.19.1",
|
|
104
|
-
"cross-env": "^7.0.3",
|
|
105
|
-
"eslint": "^8.3.0",
|
|
106
|
-
"lect": "^0.18.6",
|
|
107
|
-
"rollup": "^2.60.0",
|
|
108
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
109
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
110
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
111
|
-
"rollup-plugin-dts": "^4.0.1",
|
|
112
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
113
|
-
"tap": "^15.1.2",
|
|
114
|
-
"tslib": "^2.3.1",
|
|
115
|
-
"typescript": "^4.5.2"
|
|
116
|
-
},
|
|
117
|
-
"engines": {
|
|
118
|
-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
66
|
+
"regex-is-jinja-nunjucks": "^3.0.12",
|
|
67
|
+
"regex-is-jsp": "^3.0.12",
|
|
68
|
+
"regex-jinja-specific": "^3.0.12"
|
|
119
69
|
}
|
|
120
70
|
}
|
package/types/index.d.ts
CHANGED
package/examples/api.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"_quickTake.js":{"title":"Quick Take","content":"import { strict as assert } from \"assert\";\nimport { detectLang } from \"detect-templating-language\";\n\n// detects Nunjucks\nassert.deepEqual(\n detectLang(`<div>{% if something %}x{% else %}y{% endif %}</div>`),\n { name: \"Nunjucks\" }\n);\n\n// detects JSP (Java Server Pages)\nassert.deepEqual(\n detectLang(\n `<div><c:set var=\"someList\" value=\"\\${jspProp.someList}\" /></div>`\n ),\n { name: \"JSP\" }\n);"}}
|