Skip to content

Commit b7c0f67

Browse files
Alexander Chenangelozerr
authored andcommitted
Fixes to Formatting.md for xml.format.experimental
Signed-off-by: Alexander Chen <alchen@redhat.com>
1 parent 1ad2e0c commit b7c0f67

1 file changed

Lines changed: 32 additions & 32 deletions

File tree

docs/Formatting.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,69 @@
1010

1111
Set to `true` to enable experimental formatter. Defaults to `false`.
1212

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+
2123
* `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+
2628
Once the element is categorized, the element content is formatted according the category:
2729

28-
* `ignore space` :
30+
* `ignore space` :
2931

3032
```xml
3133
<foo>
3234
<bar></bar> </foo>
3335
```
3436

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:
3638

3739
```xml
3840
<foo>
3941
<bar></bar>
4042
</foo>
4143
```
4244

43-
* `normalize space` :
44-
45+
* `normalize space` :
46+
4547
```xml
4648
<foo>
47-
abc
49+
abc
4850
def
4951
</foo>
5052
```
5153

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:
5355

5456
```xml
5557
<foo> abc def </foo>
5658
```
5759

5860
* `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.
6163

6264
```xml
6365
<foo xml:space="preserve" >
64-
abc
66+
abc
6567
def
6668
</foo>
6769
```
6870

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:
7072

7173
```xml
7274
<foo xml:space="preserve" >
73-
abc
75+
abc
7476
def
7577
</foo>
7678
```
@@ -80,12 +82,12 @@ Here `foo` is categorized as `preserve space`, after formatting you should see t
8082
```xml
8183
<foo>
8284
<bar></bar>
83-
abc
85+
abc
8486
def
8587
</foo>
8688
```
8789

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:
8991

9092
```xml
9193
<foo>
@@ -120,8 +122,6 @@ Set to `expand` to expand empty elements during formatting.
120122
```
121123
***
122124

123-
**Not supported by the experimental formatter.**
124-
125125
### xml.format.enforceQuoteStyle
126126

127127
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
274274
```
275275

276276
**Not supported by the experimental formatter.**
277-
277+
278278
***
279279

280280
### xml.format.preserveEmptyContent
@@ -548,16 +548,16 @@ Element names for which spaces will be preserved. Defaults is the following arra
548548
]
549549
```
550550

551-
This settings is only available with experimental formatter.
551+
**This setting is only available with experimental formatter.**
552552

553553
### xml.format.maxLineWidth
554554

555555
Max line width. Default is `80`.
556556

557-
This settings is only available with experimental formatter.
557+
**This setting is only available with experimental formatter.**
558558

559559
### xml.format.grammarAwareFormatting
560560

561-
Use Schema/DTD grammar information while formatting. Default is `true`.
561+
Use Schema/DTD grammar information while formatting. Default is `true`.
562562

563-
This settings is only available with experimental formatter.
563+
**This setting is only available with experimental formatter.**

0 commit comments

Comments
 (0)