prettier-plugin-ejs 0.0.14 → 0.0.16

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.
Files changed (3) hide show
  1. package/README.md +14 -2
  2. package/index.js +6 -7
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -8,6 +8,16 @@ This plugin formats [EJS](https://ejs.co/) markup in `html` files. It uses the d
8
8
  npm install --save-dev prettier-plugin-ejs
9
9
  ```
10
10
 
11
+ For Prettier v2, the plugin will be loaded automatically.
12
+
13
+ For Prettier v3, you'll need to manually load the plugin:
14
+
15
+ ```sh
16
+ prettier --plugin=prettier-plugin-ejs --write .
17
+ ```
18
+
19
+ Please check [Prettier Docs](https://prettier.io/docs/en/plugins.html) for other loading methods.
20
+
11
21
  ## Example
12
22
 
13
23
  ### Before
@@ -27,7 +37,8 @@ npm install --save-dev prettier-plugin-ejs
27
37
  </div>
28
38
 
29
39
  <div class="<%= red %>"><%= 1 > 0 %></div>
30
- <textarea><%= text %></textarea>
40
+
41
+ <textarea><!= text !></textarea>
31
42
  <code><%= text %></code>
32
43
  <pre><%= text %></pre>
33
44
  </div>
@@ -50,7 +61,8 @@ npm install --save-dev prettier-plugin-ejs
50
61
  </div>
51
62
 
52
63
  <div class="<%= red %>"><%= 1 > 0 %></div>
53
- <textarea><%= text %></textarea>
64
+
65
+ <textarea><!= text !></textarea>
54
66
  <code><%= text %></code>
55
67
  <pre><%= text %></pre>
56
68
  </div>
package/index.js CHANGED
@@ -1,13 +1,12 @@
1
1
  const { parsers } = require("prettier/parser-html");
2
2
 
3
- const regex = /"[^"]*"|<textarea.*?<\/textarea|(<%([^>]*?)%>)/gs;
3
+ const regex =
4
+ /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|<title\s*>.*?<\/title|<textarea\s*>.*?<\/textarea|(<%([^>]*?)%>)/gs;
4
5
 
5
- function parse(text, parsersOrOptions, optionsOrUndefined) {
6
- return parsers.html.parse(
7
- text.replace(regex, (m, t, c) => (!t ? m : `<!${c}!>`)),
8
- parsersOrOptions,
9
- optionsOrUndefined
10
- );
6
+ const replacer = (m, t, c) => (!t ? m : `<!${c}!>`);
7
+
8
+ function parse(text, options, legacy) {
9
+ return parsers.html.parse(text.replace(regex, replacer), options, legacy);
11
10
  }
12
11
 
13
12
  module.exports = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prettier-plugin-ejs",
3
3
  "displayName": "Prettier EJS Plugin",
4
- "version": "0.0.14",
4
+ "version": "0.0.16",
5
5
  "description": "A Prettier plugin for Embedded JavaScript Templating (EJS).",
6
6
  "keywords": [
7
7
  "prettier",
@@ -25,7 +25,7 @@
25
25
  "type": "commonjs",
26
26
  "scripts": {
27
27
  "clean": "git clean -Xdf",
28
- "format": "prettier --ignore-path .gitignore --plugin ./index.js --write ."
28
+ "format": "prettier --ignore-path=.gitignore --plugin=./index.js --write ."
29
29
  },
30
30
  "devDependencies": {
31
31
  "prettier": "^2.8.8"