File tree

6 files changed

+257
-15
lines changed

6 files changed

+257
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# prettier-plugin-svelte changelog
22

3+
## 3.1.2
4+
5+
- (fix) handle `>` tags in attributes
6+
37
## 3.1.1
48

59
- (fix) handle types on each/await contexts
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "prettier-plugin-svelte",
3-
"version": "3.1.1",
3+
"version": "3.1.2",
44
"description": "Svelte plugin for prettier",
55
"main": "plugin.js",
66
"files": [
@@ -44,7 +44,7 @@
4444
"prettier": "^3.0.0",
4545
"rollup": "2.36.0",
4646
"rollup-plugin-typescript": "1.0.1",
47-
"svelte": "^3.57.0",
47+
"svelte": "^4.2.7",
4848
"ts-node": "^10.1.1",
4949
"tslib": "^2.6.0",
5050
"typescript": "5.1.3"
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { AttributeNode, TextNode } from '../print/nodes';
22

3-
export function extractAttributes(html: string): AttributeNode[] {
4-
const extractAttributesRegex = /<[a-z]+[\s\n]*([\s\S]*?)>/im;
5-
const attributeRegex = /([^\s=]+)(?:=(?:(?:("|')([\s\S]*?)\2)|(?:(\S+?)(?:\s|>|$))))?/gim;
3+
const extractAttributesRegex =
4+
/<[a-z]+((?:\s+[^=>'"\/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"\/]+)*\s*)>/im;
5+
const attributeRegex = /([^\s=]+)(?:=(?:(?:("|')([\s\S]*?)\2)|(?:([^>\s]+?)(?:\s|>|$))))?/gim;
66

7+
export function extractAttributes(html: string): AttributeNode[] {
78
const [, attributesString] = html.match(extractAttributesRegex)!;
89

910
const attrs: AttributeNode[] = [];

0 commit comments

Comments
 (0)