-
Notifications
You must be signed in to change notification settings - Fork 78
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#639 Signed-off-by: azerr <azerr@redhat.com>
- Loading branch information
1 parent
57971ff
commit c34d20d
Showing
6 changed files
with
110 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,70 @@ | ||
# 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. | ||
|
||
## Define Color in Text Content with `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> | ||
<drawable name="notification_template_icon_low_bg">#0cffffff</drawable> | ||
</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()" | ||
}, | ||
{ | ||
"xpath": "resources/drawable/text()" | ||
} | ||
] | ||
} | ||
] | ||
``` | ||
|
||
After saving this setting, you will get color support for text node of `color` in the `colors.xml` file: | ||
|
||
![XML Colors](../images/Features/XMLColorsFeatures.png) | ||
|
||
## Define Color in Attribute with `item/@color` | ||
|
||
Attribute values may also be marked 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