prettier-plugin-ejs 0.0.2 → 0.0.4

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 (2) hide show
  1. package/index.js +7 -11
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,19 +1,15 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
- var parserHtml = require("prettier/parser-html");
3
+ var parserHtml = require('prettier/parser-html');
4
4
 
5
- const regex = /<%(.*?)%>/gs;
5
+ const regex = /"[^"]*"|(<%(.*?)%>)/gs;
6
6
  function parse(text, parsers, options) {
7
- return parserHtml.parsers.html.parse(
8
- text.replace(regex, "<?$1?>"),
9
- parsers,
10
- options
11
- );
7
+ return parserHtml.parsers.html.parse(text.replace(regex, (m, t, c) => (!t ? m : `<?${c}?>`)), parsers, options);
12
8
  }
13
9
  var index = {
14
- parsers: {
15
- html: Object.assign(Object.assign({}, parserHtml.parsers.html), { parse }),
16
- },
10
+ parsers: {
11
+ html: Object.assign(Object.assign({}, parserHtml.parsers.html), { parse }),
12
+ },
17
13
  };
18
14
 
19
15
  module.exports = index;
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.2",
4
+ "version": "0.0.4",
5
5
  "description": "A prettier plugin for Embedded JavaScript Templating.",
6
6
  "keywords": [
7
7
  "pretiier",