prettier-plugin-ejs 0.0.18 → 1.0.0

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 +2 -15
  2. package/index.js +8 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -29,16 +29,9 @@ Please check [Prettier Docs](https://prettier.io/docs/en/plugins.html) for other
29
29
  <% if (condition) { %> <% } else if (condition) { %> <% } %>
30
30
  </div>
31
31
 
32
- <!-- prettier-ignore -->
33
- <div>
34
- <%
35
- const a = 0;
36
- %>
37
- </div>
38
-
39
32
  <div class="<%= red %>"><%= 1 > 0 %></div>
40
33
 
41
- <textarea><!= text !></textarea>
34
+ <textarea><%= text %></textarea>
42
35
  <code><%= text %></code>
43
36
  <pre><%= text %></pre>
44
37
  </div>
@@ -54,15 +47,9 @@ Please check [Prettier Docs](https://prettier.io/docs/en/plugins.html) for other
54
47
  <% } %>
55
48
  </div>
56
49
 
57
- <div>
58
- <%
59
- const a = 0;
60
- %>
61
- </div>
62
-
63
50
  <div class="<%= red %>"><%= 1 > 0 %></div>
64
51
 
65
- <textarea><!= text !></textarea>
52
+ <textarea><%= text %></textarea>
66
53
  <code><%= text %></code>
67
54
  <pre><%= text %></pre>
68
55
  </div>
package/index.js CHANGED
@@ -1,12 +1,14 @@
1
- const { parsers } = require("prettier/parser-html");
2
-
3
- const regex =
4
- /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|<title.*?>.*?<\/title>|<textarea.*?>.*?<\/textarea>|<script.*?>.*?<\/script>|(<%([^>]*?)%>)/gs;
1
+ /*
2
+ * Copyright (c) 1986-2023 Ecmel Ercan <ecmel.ercan@gmail.com>
3
+ * Licensed under the MIT License
4
+ */
5
5
 
6
- const replacer = (m, t, c) => (!t ? m : `<!${c}!>`);
6
+ const { parsers } = require("prettier/parser-html");
7
7
 
8
8
  function parse(text, options, legacy) {
9
- return parsers.html.parse(text.replace(regex, replacer), options, legacy);
9
+ const find = /(?:<(textarea|title|script).*?<\/\1|(["']).*?\2|<%([^>]*)%>)/gs;
10
+ text = text.replace(find, (match, p1, p2, p3) => (p3 ? `<!${p3}!>` : match));
11
+ return parsers.html.parse(text, options, legacy);
10
12
  }
11
13
 
12
14
  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.18",
4
+ "version": "1.0.0",
5
5
  "description": "A Prettier plugin for Embedded JavaScript Templating (EJS).",
6
6
  "keywords": [
7
7
  "prettier",