mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
chore: revert unintended linter formatting changes
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
export const parseSvgContent = (content: string, framework: 'Vue' | 'Svelte') => {
|
||||
if (content.includes('<?xml')) {
|
||||
content = content.replace(/<\?xml[^>]*\?>/i, '');
|
||||
}
|
||||
// Regular expression to match <style> tags in the SVG content
|
||||
const styleTagRegex = /<style[^>]*>([\s\S]*?)<\/style>/gi;
|
||||
|
||||
// Extract styles and store them in an array
|
||||
const styles = [];
|
||||
let matched;
|
||||
while ((matched = styleTagRegex.exec(content)) !== null) {
|
||||
styles.push(matched[1]); // Add the style content (not including the style tag)
|
||||
}
|
||||
|
||||
// Remove <style> tags from the SVG content
|
||||
const templateContent = content.replace(styleTagRegex, '');
|
||||
|
||||
const componentStyle = styles.length
|
||||
? `<style${framework === 'Vue' ? ' scoped' : ''}>\n${styles.join('\n')}\n</style>`
|
||||
: '';
|
||||
|
||||
return {
|
||||
componentStyle,
|
||||
templateContent
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user