@zackad/prettier-plugin-twig 0.7.0-alpha.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# Prettier Plugin for Twig
|
|
2
2
|
|
|
3
|
-
> [!WARNING]
|
|
4
|
-
> Not ready. DON'T USE!
|
|
5
|
-
|
|
6
3
|
Forked from [trivago/prettier-plugin-twig-melody](https://github.com/trivago/prettier-plugin-twig-melody) with focus on twig template only.
|
|
7
4
|
|
|
8
5
|

|
package/package.json
CHANGED
|
@@ -497,7 +497,7 @@ export default class Lexer {
|
|
|
497
497
|
(c === 95 ||
|
|
498
498
|
isAlpha(c) ||
|
|
499
499
|
isDigit(c) ||
|
|
500
|
-
(inElement && (c
|
|
500
|
+
(inElement && isValidAttributeName(c)))
|
|
501
501
|
) {
|
|
502
502
|
input.next();
|
|
503
503
|
}
|
|
@@ -561,17 +561,15 @@ export default class Lexer {
|
|
|
561
561
|
matchAttributeValue(pos) {
|
|
562
562
|
const input = this.input;
|
|
563
563
|
const start = this.state === State.STRING_SINGLE ? "'" : '"';
|
|
564
|
-
let c;
|
|
565
|
-
|
|
564
|
+
let c = input.la(0);
|
|
565
|
+
const c2 = input.la(1);
|
|
566
|
+
if (c === "{" && (c2 === "{" || c2 === "#" || c2 === "%")) {
|
|
566
567
|
return this.matchExpressionToken(pos);
|
|
567
568
|
}
|
|
568
569
|
while ((c = input.la(0)) !== start && c !== EOF) {
|
|
569
570
|
if (c === "\\" && input.la(1) === start) {
|
|
570
571
|
input.next();
|
|
571
572
|
input.next();
|
|
572
|
-
} else if (c === "{") {
|
|
573
|
-
// interpolation start
|
|
574
|
-
break;
|
|
575
573
|
} else if (c === start) {
|
|
576
574
|
break;
|
|
577
575
|
} else {
|
|
@@ -663,3 +661,48 @@ function isAlpha(c) {
|
|
|
663
661
|
function isDigit(c) {
|
|
664
662
|
return c >= 48 && c <= 57;
|
|
665
663
|
}
|
|
664
|
+
|
|
665
|
+
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
|
666
|
+
function isValidAttributeName(c) {
|
|
667
|
+
const is_c0_control = c >= 0 && c <= 31;
|
|
668
|
+
const is_control = is_c0_control || (c >= 127 && c <= 159);
|
|
669
|
+
const is_invalid =
|
|
670
|
+
c === 32 || c === 34 || c === 39 || c === 62 || c === 47 || c === 61;
|
|
671
|
+
const is_noncharacter =
|
|
672
|
+
(c >= 64976 && c <= 65007) ||
|
|
673
|
+
c === 65534 ||
|
|
674
|
+
c === 65535 ||
|
|
675
|
+
c === 131070 ||
|
|
676
|
+
c === 131071 ||
|
|
677
|
+
c === 196606 ||
|
|
678
|
+
c === 196607 ||
|
|
679
|
+
c === 262142 ||
|
|
680
|
+
c === 262143 ||
|
|
681
|
+
c === 327678 ||
|
|
682
|
+
c === 327679 ||
|
|
683
|
+
c === 393214 ||
|
|
684
|
+
c === 393215 ||
|
|
685
|
+
c === 458750 ||
|
|
686
|
+
c === 458751 ||
|
|
687
|
+
c === 524286 ||
|
|
688
|
+
c === 524287 ||
|
|
689
|
+
c === 589822 ||
|
|
690
|
+
c === 589823 ||
|
|
691
|
+
c === 655358 ||
|
|
692
|
+
c === 655359 ||
|
|
693
|
+
c === 720894 ||
|
|
694
|
+
c === 720895 ||
|
|
695
|
+
c === 786430 ||
|
|
696
|
+
c === 786431 ||
|
|
697
|
+
c === 851966 ||
|
|
698
|
+
c === 851967 ||
|
|
699
|
+
c === 917502 ||
|
|
700
|
+
c === 917503 ||
|
|
701
|
+
c === 983038 ||
|
|
702
|
+
c === 983039 ||
|
|
703
|
+
c === 1048574 ||
|
|
704
|
+
c === 1048575 ||
|
|
705
|
+
c === 1114106 ||
|
|
706
|
+
c === 1114107;
|
|
707
|
+
return !is_control && !is_invalid && !is_noncharacter;
|
|
708
|
+
}
|