detect-templating-language 3.0.4 → 3.0.10
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/CHANGELOG.md +0 -20
- package/LICENSE +1 -1
- package/README.md +4 -1
- package/dist/detect-templating-language.esm.js +2 -32
- package/dist/detect-templating-language.umd.js +20 -4
- package/examples/_quickTake.js +1 -0
- package/package.json +24 -81
- package/types/index.d.ts +0 -0
- package/examples/api.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,26 +3,6 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## 3.0.3 (2021-11-02)
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
- bump TS and separate ESLint plugins away from this monorepo ([b1ebce1](https://github.com/codsen/codsen/commit/b1ebce1637d8c41c2d848fc24b0ba4058865bd5d))
|
|
11
|
-
|
|
12
|
-
### Features
|
|
13
|
-
|
|
14
|
-
- migrate to ES Modules ([c579dff](https://github.com/codsen/codsen/commit/c579dff3b23205e383035ca10ddcec671e35d0fe))
|
|
15
|
-
|
|
16
|
-
### BREAKING CHANGES
|
|
17
|
-
|
|
18
|
-
- programs now are in ES Modules and won't work with Common JS require()
|
|
19
|
-
|
|
20
|
-
## 3.0.1 (2021-09-13)
|
|
21
|
-
|
|
22
|
-
### Bug Fixes
|
|
23
|
-
|
|
24
|
-
- bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
|
|
25
|
-
|
|
26
6
|
## 3.0.0 (2021-09-09)
|
|
27
7
|
|
|
28
8
|
### Features
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010
|
|
3
|
+
Copyright (c) 2010-2021 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
|
@@ -38,6 +38,7 @@ If you need a legacy version which works with `require`, use version 2.1.0
|
|
|
38
38
|
|
|
39
39
|
```js
|
|
40
40
|
import { strict as assert } from "assert";
|
|
41
|
+
|
|
41
42
|
import { detectLang } from "detect-templating-language";
|
|
42
43
|
|
|
43
44
|
// detects Nunjucks
|
|
@@ -57,7 +58,7 @@ assert.deepEqual(
|
|
|
57
58
|
|
|
58
59
|
## Documentation
|
|
59
60
|
|
|
60
|
-
Please [visit codsen.com](https://codsen.com/os/detect-templating-language/) for a full description of the API
|
|
61
|
+
Please [visit codsen.com](https://codsen.com/os/detect-templating-language/) for a full description of the API.
|
|
61
62
|
|
|
62
63
|
## Contributing
|
|
63
64
|
|
|
@@ -69,4 +70,6 @@ MIT License
|
|
|
69
70
|
|
|
70
71
|
Copyright (c) 2010-2021 Roy Revelt and other contributors
|
|
71
72
|
|
|
73
|
+
|
|
72
74
|
<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">
|
|
75
|
+
|
|
@@ -1,40 +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.10
|
|
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.4";
|
|
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
|
-
} else if (isJSP().test(str)) {
|
|
33
|
-
name = "JSP";
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
name
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export { detectLang, version };
|
|
10
|
+
import{isJinjaNunjucksRegex as i}from"regex-is-jinja-nunjucks";import{isJSP as r}from"regex-is-jsp";import{isJinjaSpecific as a}from"regex-jinja-specific";var n="3.0.10";var g=n;function d(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?(i().test(e)?(t="Nunjucks",a().test(e)&&(t="Jinja")):r().test(e)&&(t="JSP"),{name:t}):{name:t}}export{d as detectLang,g 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.10
|
|
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 i=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var d=e=>i(e,"__esModule",{value:!0});var m=(e,t)=>{for(var s in t)i(e,s,{get:t[s],enumerable:!0})},f=(e,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of l(t))!g.call(e,n)&&(s||n!=="default")&&i(e,n,{get:()=>t[n],enumerable:!(r=o(t,n))||r.enumerable});return e};var j=(e=>(t,s)=>e&&e.get(t)||(s=f(d({}),t,1),e&&e.set(t,s),s))(typeof WeakMap!="undefined"?new WeakMap:0);var h={};m(h,{detectLang:()=>x,version:()=>v});function a(){return/{%|{{|%}|}}/gi}function u(){return/<%|%>|<\s*jsp:|<\s*cms:|<\s*c:|\${\s*jsp/gi}function c(){return/(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi}var p="3.0.10";var v=p;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",c().test(e)&&(t="Jinja")):u().test(e)&&(t="JSP"),{name:t}):{name:t}}return j(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.10
|
|
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.10
|
|
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.10
|
|
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.10",
|
|
4
4
|
"description": "Detects various templating languages present in string",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"check",
|
|
@@ -29,96 +29,39 @@
|
|
|
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
|
-
"
|
|
44
|
-
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
|
|
45
|
-
"republish": "npm publish || :",
|
|
46
|
-
"tap": "tap",
|
|
47
|
-
"pretest": "npm run build",
|
|
48
|
-
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
49
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
50
|
-
"tsc": "tsc",
|
|
51
|
-
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
|
|
32
|
+
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
33
|
+
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
34
|
+
"dts": "rollup -c",
|
|
35
|
+
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
36
|
+
"lect": "node '../../ops/lect/lect.js'",
|
|
37
|
+
"letspublish": "yarn publish || :",
|
|
38
|
+
"lint": "eslint . --fix",
|
|
39
|
+
"perf": "node perf/check.js",
|
|
40
|
+
"prepare": "echo 'ready'",
|
|
41
|
+
"pretest": "yarn run lect && yarn run build",
|
|
42
|
+
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
43
|
+
"unit": "uvu test"
|
|
52
44
|
},
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"--no-warnings",
|
|
61
|
-
"--experimental-loader",
|
|
62
|
-
"@istanbuljs/esm-loader-hook"
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
47
|
+
},
|
|
48
|
+
"c8": {
|
|
49
|
+
"check-coverage": true,
|
|
50
|
+
"exclude": [
|
|
51
|
+
"**/test/**/*.*"
|
|
63
52
|
],
|
|
64
|
-
"
|
|
53
|
+
"lines": 100
|
|
65
54
|
},
|
|
66
55
|
"lect": {
|
|
67
56
|
"licence": {
|
|
68
57
|
"extras": [
|
|
69
58
|
""
|
|
70
59
|
]
|
|
71
|
-
},
|
|
72
|
-
"req": "{ detectLang }",
|
|
73
|
-
"various": {
|
|
74
|
-
"devDependencies": []
|
|
75
60
|
}
|
|
76
61
|
},
|
|
77
62
|
"dependencies": {
|
|
78
|
-
"
|
|
79
|
-
"regex-is-
|
|
80
|
-
"regex-
|
|
81
|
-
"regex-jinja-specific": "^3.0.4"
|
|
82
|
-
},
|
|
83
|
-
"devDependencies": {
|
|
84
|
-
"@babel/cli": "^7.16.0",
|
|
85
|
-
"@babel/core": "^7.16.0",
|
|
86
|
-
"@babel/node": "^7.16.0",
|
|
87
|
-
"@babel/plugin-external-helpers": "^7.16.0",
|
|
88
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
89
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
90
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
91
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
92
|
-
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
93
|
-
"@babel/preset-env": "^7.16.0",
|
|
94
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
95
|
-
"@babel/register": "^7.16.0",
|
|
96
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
97
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
98
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
99
|
-
"@rollup/plugin-json": "^4.1.0",
|
|
100
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
101
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
102
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
103
|
-
"@types/node": "^16.11.6",
|
|
104
|
-
"@types/tap": "^15.0.5",
|
|
105
|
-
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
|
106
|
-
"@typescript-eslint/parser": "^5.3.0",
|
|
107
|
-
"core-js": "^3.19.1",
|
|
108
|
-
"cross-env": "^7.0.3",
|
|
109
|
-
"eslint": "^8.1.0",
|
|
110
|
-
"lect": "^0.18.4",
|
|
111
|
-
"rollup": "^2.59.0",
|
|
112
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
113
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
114
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
115
|
-
"rollup-plugin-dts": "^4.0.0",
|
|
116
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
117
|
-
"tap": "^15.0.10",
|
|
118
|
-
"tslib": "^2.3.1",
|
|
119
|
-
"typescript": "^4.4.4"
|
|
120
|
-
},
|
|
121
|
-
"engines": {
|
|
122
|
-
"node": ">=12"
|
|
63
|
+
"regex-is-jinja-nunjucks": "^3.0.10",
|
|
64
|
+
"regex-is-jsp": "^3.0.10",
|
|
65
|
+
"regex-jinja-specific": "^3.0.10"
|
|
123
66
|
}
|
|
124
67
|
}
|
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 { 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);"}}
|