forked from redhat-developer/vscode-xml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See eclipse-lemminx/lemminx#639 Signed-off-by: azerr <azerr@redhat.com>
- Loading branch information
1 parent
57971ff
commit b746503
Showing
6 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# XML Colors Features | ||
|
||
XML colors support provides the capability to mark a DOM node (attribute or text) as color with the `xml.colors` settings by using XPath expression : | ||
|
||
* `color/text()` defines the text node of the `color` element. | ||
* `item/@color` defines the `color` attribute node of the `item` element. | ||
|
||
## Text node color (color/text()) | ||
|
||
Given this [android color](https://developer.android.com/guide/topics/resources/more-resources#Color) XML file sample: | ||
|
||
```xml | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="opaque_red">#f00</color> | ||
<color name="translucent_red">rgb(222,82,0.82)</color> | ||
</resources> | ||
``` | ||
|
||
In this sample, text of `color` tag element `<color name="opaque_red">#f00</color>` declare a color with hexadecimal. [vscode-xml](https://github.com/redhat-developer/vscode-xml) provides a color support with the `xml.colors` settings. For [android color](https://developer.android.com/guide/topics/resources/more-resources#Color) case, you can declare this settings: | ||
|
||
```json | ||
"xml.colors": [ | ||
{ | ||
"pattern": "**/res/values/colors.xml", | ||
"expressions": [ | ||
{ | ||
"xpath": "resources/color/text()" | ||
} | ||
] | ||
} | ||
] | ||
``` | ||
|
||
After saving this setting, you will get color support for text noe of `color` in the colors.xml file: | ||
|
||
![XML Colors](../images/Features/XMLColorsFeatures.png) | ||
|
||
## Attribute node color (item/@color) | ||
|
||
It is possible too to mark attribute as color, by using the proper XPath. | ||
|
||
Given this `colors.xml` XML file: | ||
|
||
```xml | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<item color="#f00" /> | ||
<item color="rgb(222,82,0.82)" /> | ||
</resources> | ||
``` | ||
|
||
You can declare this settings: | ||
|
||
```json | ||
"xml.colors": [ | ||
{ | ||
"pattern": "**/colors.xml", | ||
"expressions": [ | ||
{ | ||
"xpath": "item/@color" | ||
} | ||
] | ||
} | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters