Skip to content

Commit

Permalink
custom 'html' tags are in red color. Fixes #56467
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Oct 4, 2018
1 parent 7ff8bda commit cfc2a22
Show file tree
Hide file tree
Showing 7 changed files with 576 additions and 484 deletions.
18 changes: 16 additions & 2 deletions extensions/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"vscode": "0.10.x"
},
"scripts": {
"update-grammar": "node ../../build/npm/update-grammar.js textmate/html.tmbundle Syntaxes/HTML.plist ./syntaxes/html.tmLanguage.json"
"update-grammar": "node ../../build/npm/update-grammar.js textmate/html.tmbundle Syntaxes/HTML.plist ./syntaxes/html.tmLanguage.json Syntaxes/HTML%20%28Derivative%29.tmLanguage ./syntaxes/html-derivative.tmLanguage.json"
},
"contributes": {
"languages": [
Expand Down Expand Up @@ -46,7 +46,6 @@
],
"grammars": [
{
"language": "html",
"scopeName": "text.html.basic",
"path": "./syntaxes/html.tmLanguage.json",
"embeddedLanguages": {
Expand All @@ -59,6 +58,21 @@
"tokenTypes": {
"meta.tag string.quoted": "other"
}
},
{
"language": "html",
"scopeName": "text.html.derivative",
"path": "./syntaxes/html-derivative.tmLanguage.json",
"embeddedLanguages": {
"text.html": "html",
"source.css": "css",
"source.js": "javascript",
"source.python": "python",
"source.smarty": "smarty"
},
"tokenTypes": {
"meta.tag string.quoted": "other"
}
}
],
"snippets": [
Expand Down
49 changes: 49 additions & 0 deletions extensions/html/syntaxes/html-derivative.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"information_for_contributors": [
"This file has been converted from https://github.com/textmate/html.tmbundle/blob/master/Syntaxes/HTML%20%28Derivative%29.tmLanguage",
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/textmate/html.tmbundle/commit/390c8870273a2ae80244dae6db6ba064a802f407",
"name": "HTML (Derivative)",
"scopeName": "text.html.derivative",
"injections": {
"R:text.html - (comment.block, text.html meta.embedded, meta.tag.*.*.html, meta.tag.*.*.*.html, meta.tag.*.*.*.*.html)": {
"comment": "Uses R: to ensure this matches after any other injections.",
"patterns": [
{
"match": "<",
"name": "invalid.illegal.bad-angle-bracket.html"
}
]
}
},
"patterns": [
{
"include": "text.html.basic#core-minus-invalid"
},
{
"begin": "(</?)(\\w[^\\s>]*)(?<!/)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.tag.begin.html"
},
"2": {
"name": "entity.name.tag.html"
}
},
"end": "((?: ?/)?>)",
"endCaptures": {
"1": {
"name": "punctuation.definition.tag.end.html"
}
},
"name": "meta.tag.other.unrecognized.html.derivative",
"patterns": [
{
"include": "text.html.basic#attribute"
}
]
}
]
}
119 changes: 74 additions & 45 deletions extensions/html/syntaxes/html.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/textmate/html.tmbundle/commit/6a6fb2967e2f562a634fca97d18018104d428f1c",
"version": "https://github.com/textmate/html.tmbundle/commit/390c8870273a2ae80244dae6db6ba064a802f407",
"name": "HTML",
"scopeName": "text.html.basic",
"injections": {
Expand All @@ -20,55 +20,13 @@
},
"patterns": [
{
"begin": "(<\\?)(xml)",
"captures": {
"1": {
"name": "punctuation.definition.tag.html"
},
"2": {
"name": "entity.name.tag.html"
}
},
"end": "(\\?>)",
"name": "meta.tag.metadata.processing.xml.html",
"patterns": [
{
"include": "#attribute"
}
]
"include": "#xml-processing"
},
{
"include": "#comment"
},
{
"begin": "<!(?=(?i:DOCTYPE\\s))",
"beginCaptures": {
"0": {
"name": "punctuation.definition.tag.begin.html"
}
},
"end": ">",
"endCaptures": {
"0": {
"name": "punctuation.definition.tag.end.html"
}
},
"name": "meta.tag.metadata.doctype.html",
"patterns": [
{
"match": "\\G(?i:DOCTYPE)",
"name": "entity.name.tag.html"
},
{
"begin": "\"",
"end": "\"",
"name": "string.quoted.double.html"
},
{
"match": "[^\\s>]+",
"name": "entity.other.attribute-name.html"
}
]
"include": "#doctype"
},
{
"include": "#cdata"
Expand Down Expand Up @@ -468,6 +426,59 @@
}
]
},
"core-minus-invalid": {
"comment": "This should be the root pattern array includes minus #tags-invalid",
"patterns": [
{
"include": "#xml-processing"
},
{
"include": "#comment"
},
{
"include": "#doctype"
},
{
"include": "#cdata"
},
{
"include": "#tags-valid"
},
{
"include": "#entities"
}
]
},
"doctype": {
"begin": "<!(?=(?i:DOCTYPE\\s))",
"beginCaptures": {
"0": {
"name": "punctuation.definition.tag.begin.html"
}
},
"end": ">",
"endCaptures": {
"0": {
"name": "punctuation.definition.tag.end.html"
}
},
"name": "meta.tag.metadata.doctype.html",
"patterns": [
{
"match": "\\G(?i:DOCTYPE)",
"name": "entity.name.tag.html"
},
{
"begin": "\"",
"end": "\"",
"name": "string.quoted.double.html"
},
{
"match": "[^\\s>]+",
"name": "entity.other.attribute-name.html"
}
]
},
"entities": {
"patterns": [
{
Expand Down Expand Up @@ -2559,6 +2570,24 @@
]
}
]
},
"xml-processing": {
"begin": "(<\\?)(xml)",
"captures": {
"1": {
"name": "punctuation.definition.tag.html"
},
"2": {
"name": "entity.name.tag.html"
}
},
"end": "(\\?>)",
"name": "meta.tag.metadata.processing.xml.html",
"patterns": [
{
"include": "#attribute"
}
]
}
}
}
Loading

2 comments on commit cfc2a22

@adamk33n3r
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aeschli Could we also get this for php?

@aeschli
Copy link
Contributor Author

@aeschli aeschli commented on cfc2a22 Jul 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamk33n3r Please file a separate issue with a small code sample...

Please sign in to comment.