Add an allowed tag name to the HTML language mode

Viewed 35

I'm using Foundation for Emails, which has a few unique tag names that are later parsed. Specifically, VSCode doesn't seem to like <spacer>:

enter image description here

How do I add <spacer> as an known/allowed tag so it's not redded out by VSCode?

1 Answers

You can use HTML custom data. Create a JSON file, e.g. spacer.html-data.json:

{
  "version": 1.1,
  "tags": [
    {
      "name": "spacer",
      "description": "Foundation spacer",
      "attributes": [
        {
          "name": "size",
          "description": "Spacer size"
        }
      ]
    }
  ]
}

And include it in your VS Code JSON configuration:

"html.customData": [
    "./spacer.html-data.json"
]

Note that this has to be a path relative to your opened folder/workspace.


EDIT: Oh, I just realized that this does not prevent the red colouring in this special case. Probably this is becaue spacer used to be a valid HTML tag but is deprecated now. I have no idea how to change this behaviour in VS code.

Related