prettier-plugin-svelte
Advanced tools
Comparing version 0.4.1 to 0.4.2
{ | ||
"name": "prettier-plugin-svelte", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Svelte plugin for prettier", | ||
@@ -5,0 +5,0 @@ "main": "plugin.js", |
@@ -61,11 +61,7 @@ 'use strict'; | ||
const parts = []; | ||
if (n.css) { | ||
n.css.type = 'Style'; | ||
n.css.content.type = 'StyleProgram'; | ||
parts.push(path.call(print, 'css')); | ||
if (n.module) { | ||
n.module.type = 'Script'; | ||
n.module.attributes = extractAttributes(getText(n.module, options)); | ||
parts.push(path.call(print, 'module')); | ||
} | ||
if (n.js) { | ||
n.js.type = 'Script'; | ||
parts.push(path.call(print, 'js')); | ||
} | ||
if (n.instance) { | ||
@@ -76,6 +72,6 @@ n.instance.type = 'Script'; | ||
} | ||
if (n.module) { | ||
n.module.type = 'Script'; | ||
n.module.attributes = extractAttributes(getText(n.module, options)); | ||
parts.push(path.call(print, 'module')); | ||
if (n.css) { | ||
n.css.type = 'Style'; | ||
n.css.content.type = 'StyleProgram'; | ||
parts.push(path.call(print, 'css')); | ||
} | ||
@@ -460,6 +456,9 @@ parts.push(path.call(print, 'html')); | ||
const regex = new RegExp(`<${tagName}([^]*?)>([^]*?)<\/${tagName}>`, 'gi'); | ||
return source.replace(regex, (_, attributes, content) => { | ||
const tags = []; | ||
const text = source.replace(regex, (_, attributes, content) => { | ||
const encodedContext = Buffer.from(content).toString('base64'); | ||
return `<${tagName}${attributes} ✂prettier:content✂="${encodedContext}">${placeholder}</${tagName}>`; | ||
tags.push(`<${tagName}${attributes} ✂prettier:content✂="${encodedContext}">${placeholder}</${tagName}>`); | ||
return ''; | ||
}); | ||
return [text, tags]; | ||
} | ||
@@ -486,5 +485,7 @@ | ||
preprocess: text => { | ||
text = snipTagContent('style', text); | ||
text = snipTagContent('script', text, '{}'); | ||
return text; | ||
let styles = []; | ||
let scripts = []; | ||
[text, styles] = snipTagContent('style', text); | ||
[text, scripts] = snipTagContent('script', text, '{}'); | ||
return [text.trim(), ...styles, ...scripts].join(''); | ||
}, | ||
@@ -491,0 +492,0 @@ locStart, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57078
493