You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Formatting.md
+32-32Lines changed: 32 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,67 +10,69 @@
10
10
11
11
Set to `true` to enable experimental formatter. Defaults to `false`.
12
12
13
-
As we have more and more issues with our current XML formatter, we have decided to redo our formatter to try to fix them. This new formatter is in experimental state because it doesn't support all current formatter settings and it could have some bugs. To enable this experimental formatter you can set the setting `xml.format.experimental` to true.
14
-
15
-
Once we have enough good feedback and we support all current formatting settings, we will replace the current formatter with the experimental formatter. Don't hesitate to [create issues](https://github.com/redhat-developer/vscode-xml/issues) to give us feedback with this experimental formatter.
16
-
17
-
The current formatter uses the DOM document and rewrite the XML document or a fragment of XML (when range formatting is processed). This strategy provides a lot of bugs if XML is not valid (ex : <% will format with <null).
18
-
19
-
The new strategy is to format the current XML by adding or removing some spaces without updating the XML content. The experimental formatter categorizes each element as :
20
-
13
+
As the frequency of issues regarding the previous XML formatter increased, we have decided to redo our formatter from scratch. *Note*: this new formatter is flagged as experimental since it doesn't support all current formatter settings and uncaught bugs may occur. To enable this experimental formatter, the setting `xml.format.experimental` should be set to true.
14
+
15
+
We plan to have the experimental formatter replace the current formatter entirely once we have enough positive feedback and all current formatting settings are supported. To help with this, please don't hesitate to [create issues](https://github.com/redhat-developer/vscode-xml/issues) and give us feedback on this experimental formatter.
16
+
17
+
The current formatter uses the DOM document to rewrite the XML document, or simply a fragment of XML (when range formatting is processed). *Note*: This strategy provides a lot of bugs if XML is not valid (ex : `<%` will format with `<null`).
18
+
19
+
Any setting unsupported by the experimental formatter will be marked with **Not supported by the experimental formatter**, while settings exclusive to the experimental formatter will be marked with **This setting is only available with experimental formatter**.
20
+
21
+
The new strategy used by the experimental formatter formats the current XML by adding or removing some spaces without updating the XML content. The experimental formatter categorizes each element as:
22
+
21
23
*`ignore space`
22
-
*`normalize space`
23
-
*`mixed content`
24
-
*and `preserve space`. Also, you can use `xml:space="preserve"` to preserve spaces in some elements or use `xml.format.preserveSpace` to add a given tag element which must preserve spaces.
25
-
24
+
*`normalize space`
25
+
*`mixed content`
26
+
*`preserve space`. (You can use `xml:space="preserve"` to preserve spaces in some elements or use `xml.format.preserveSpace` to add a given tag element which must preserve spaces.)
27
+
26
28
Once the element is categorized, the element content is formatted according the category:
27
29
28
-
*`ignore space` :
30
+
*`ignore space` :
29
31
30
32
```xml
31
33
<foo>
32
34
<bar></bar> </foo>
33
35
```
34
36
35
-
Here `foo` is categorized as `ignore space`, because all children are tag elements and only spaces. it means that it removes all spaces . After formatting you should see this result:
37
+
Here `foo` is categorized as `ignore space`, because all children of `foo`are tag elements and single spaces. All single spaces are removed. After formatting, you should see this result:
36
38
37
39
```xml
38
40
<foo>
39
41
<bar></bar>
40
42
</foo>
41
43
```
42
44
43
-
*`normalize space` :
44
-
45
+
*`normalize space` :
46
+
45
47
```xml
46
48
<foo>
47
-
abc
49
+
abc
48
50
def
49
51
</foo>
50
52
```
51
53
52
-
Here `foo` is categorized as `normalize space`, it means that it removes all spaces with one space. After formatting you should see this result:
54
+
Here `foo` is categorized as `normalize space`, it means that it replaces all spaces with a single space. After formatting, you should see this result:
53
55
54
56
```xml
55
57
<foo> abc def </foo>
56
58
```
57
59
58
60
*`preserve space`
59
-
60
-
If you want to preserve space, you can use `xml:space="preserve"` to preserve spaces in some elements or use `xml.format.preserveSpace`
61
+
62
+
If you want to preserve space, you can use `xml:space="preserve"` to preserve spaces in some elements or use the [`xml.format.preserveSpace`](#xml.format.preserveSpace) setting.
61
63
62
64
```xml
63
65
<fooxml:space="preserve" >
64
-
abc
66
+
abc
65
67
def
66
68
</foo>
67
69
```
68
70
69
-
Here `foo` is categorized as `preserve space`, after formatting you should see this result:
71
+
Here `foo` is categorized as `preserve space`. After formatting, you should see this result:
70
72
71
73
```xml
72
74
<fooxml:space="preserve" >
73
-
abc
75
+
abc
74
76
def
75
77
</foo>
76
78
```
@@ -80,12 +82,12 @@ Here `foo` is categorized as `preserve space`, after formatting you should see t
80
82
```xml
81
83
<foo>
82
84
<bar></bar>
83
-
abc
85
+
abc
84
86
def
85
87
</foo>
86
88
```
87
89
88
-
Here `foo` is categorized as `mixed content` (it contains text and tag element), it means that it removes all spaces with one space. After formatting you should see this result:
90
+
Here `foo` is categorized as `mixed content`, since it contains text and tag element. All single spaces are removed. After formatting, you should see this result:
89
91
90
92
```xml
91
93
<foo>
@@ -120,8 +122,6 @@ Set to `expand` to expand empty elements during formatting.
120
122
```
121
123
***
122
124
123
-
**Not supported by the experimental formatter.**
124
-
125
125
### xml.format.enforceQuoteStyle
126
126
127
127
Enforce `preferred` quote style (set by `xml.preferences.quoteStyle`) or `ignore` quote style when formatting.
@@ -274,7 +274,7 @@ If this value is set to 0, then all blank lines will be removed during formattin
274
274
```
275
275
276
276
**Not supported by the experimental formatter.**
277
-
277
+
278
278
***
279
279
280
280
### xml.format.preserveEmptyContent
@@ -548,16 +548,16 @@ Element names for which spaces will be preserved. Defaults is the following arra
548
548
]
549
549
```
550
550
551
-
This settings is only available with experimental formatter.
551
+
**This setting is only available with experimental formatter.**
552
552
553
553
### xml.format.maxLineWidth
554
554
555
555
Max line width. Default is `80`.
556
556
557
-
This settings is only available with experimental formatter.
557
+
**This setting is only available with experimental formatter.**
558
558
559
559
### xml.format.grammarAwareFormatting
560
560
561
-
Use Schema/DTD grammar information while formatting. Default is `true`.
561
+
Use Schema/DTD grammar information while formatting. Default is `true`.
562
562
563
-
This settings is only available with experimental formatter.
563
+
**This setting is only available with experimental formatter.**
0 commit comments