-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (26 loc) · 634 Bytes
/
index.js
File metadata and controls
29 lines (26 loc) · 634 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
* Copyright (c) 1986-2024 Ecmel Ercan (https://ecmel.dev/)
* Licensed under the MIT License
*/
const { parsers } = require("prettier/parser-html");
function parse(text, options, legacy) {
const find =
/(?:<(textarea|title|script).*?<\/\1|<\s*[a-zA-Z!](?:".*?"|.*?)*?[^%]>|<%([^>]*)%>)/gs;
text = text.replace(find, (match, p1, p2) => (p2 ? `<!${p2}!>` : match));
return parsers.html.parse(text, options, legacy);
}
module.exports = {
languages: [
{
name: "EJS",
parsers: ["html"],
extensions: [".ejs"],
},
],
parsers: {
html: {
...parsers.html,
parse,
},
},
};