🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

prettier-plugin-templ-script

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-templ-script - npm Package Compare versions

Comparing version

to
0.0.2

12

index.js

@@ -22,7 +22,13 @@ import prettier from 'prettier';

const { text } = path.getValue();
const matches = text.matchAll(/^(\s*)<script>([\s\S]+?)<\/script>$/gm);
const scriptRegex = /^(\s*)<script([^>]*?)>([\s\S]+?)<\/script>$/gm;
const matches = text.matchAll(scriptRegex);
let transformedText = text;
try {
for (const [match, leadingWhitespace, scriptContent] of matches) {
for (const [
match,
leadingWhitespace,
scriptAttributes,
scriptContent,
] of matches) {
const formattedScript = await prettier.format(scriptContent.trim(), {

@@ -39,3 +45,3 @@ ...options,

const replacementScript = `${leadingWhitespace}<script>\n${indentedScript}\n${leadingWhitespace}</script>`;
const replacementScript = `${leadingWhitespace}<script${scriptAttributes}>\n${indentedScript}\n${leadingWhitespace}</script>`;
transformedText = transformedText.replace(match, replacementScript);

@@ -42,0 +48,0 @@ }

{
"name": "prettier-plugin-templ-script",
"version": "0.0.1",
"version": "0.0.2",
"description": "Prettier plugin for `<script>` tags in templ.",

@@ -5,0 +5,0 @@ "repository": "github:therealparmesh/prettier-plugin-templ-script",