|
1 | 1 | " default html syntax should already be including the css syntax |
2 | | -call css_color#init('none', 'none', 'htmlString,htmlCommentPart') |
| 2 | +" but tag style attributes don't properly apply CSS syntax (as of vim 9.0.1378). |
| 3 | +" Correct the bug by replacing htmlCssDefinition with a new htmlCssContent: {{{ |
| 4 | +syn keyword htmlCssArg contained containedin=htmlTag nextgroup=htmlCssEq style |
| 5 | +syn match htmlCssEq contained +=+ nextgroup=htmlCssQuote |
| 6 | +syn match htmlCssQuote contained +["']+ nextgroup=htmlCssContent |
| 7 | +syn region htmlCssContent contained start=+\%("\)\@<=.+ end=+"+ keepend contains=cssTagName,cssAttributeSelector,cssClassName,cssIdentifier,cssAtRule,cssAttrRegion,css.*Prop,cssComment,cssValue.*,cssColor,cssURL,cssImportant,cssCustomProp,cssError,cssStringQ,cssFunction,cssUnicodeEscape,cssVendor,cssHacks,cssNoise |
| 8 | +syn region htmlCssContent contained start=+\%('\)\@<=.+ end=+'+ keepend contains=cssTagName,cssAttributeSelector,cssClassName,cssIdentifier,cssAtRule,cssAttrRegion,css.*Prop,cssComment,cssValue.*,cssColor,cssURL,cssImportant,cssCustomProp,cssError,cssStringQ,cssFunction,cssUnicodeEscape,cssVendor,cssHacks,cssNoise |
| 9 | + |
| 10 | +hi def link htmlCssArg htmlArg |
| 11 | +hi def link htmlCssEq htmlTag |
| 12 | +hi def link htmlCssQuote htmlString |
| 13 | +" end bugfix }}} |
| 14 | + |
| 15 | +" Legacy HTML 3-style color declarations (depcecated) {{{ |
| 16 | +" Search https://www.w3.org/TR/html4/index/attributes.html for `%Color;` |
| 17 | +" Technically, these must be named or #RRGGBB, but both FF and Chrome simply |
| 18 | +" map it to CSS, supporting #RGB, #RGBA, and #RRGGBBAA (though alpha is ignored) |
| 19 | +syn region htmlTag start=+<\s*body\s+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster,htmlTagBodyColors |
| 20 | +syn keyword htmlTagBodyColors contained nextgroup=htmlLegacyColor text bgcolor link alink vlink |
| 21 | +syn region htmlTag start=+<\s*\%(table\|t[rdh]\)\s+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster,htmlBgColors |
| 22 | +syn keyword htmlBgColors contained nextgroup=htmlLegacyColor bgcolor |
| 23 | +syn region htmlTag start=+<\s*\%(base\)\?font\s+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster,htmlFgColors |
| 24 | +syn keyword htmlFgColors contained nextgroup=htmlLegacyColor color |
| 25 | +syn region htmlLegacyColor contained start=+="+ end=+"+ contains=cssColor |
| 26 | +syn region htmlLegacyColor contained start=+='+ end=+'+ contains=cssColor |
| 27 | + |
| 28 | +hi def link htmlTagBody htmlTagName |
| 29 | +hi def link htmlTagBodyColors htmlArg |
| 30 | +hi def link htmlBgColors htmlArg |
| 31 | +hi def link htmlFgColors htmlArg |
| 32 | +" end legacy HTML-3 color attributes }}} |
| 33 | + |
| 34 | +" apply colors within HTML style attributes, legacy HTML-3 attributes, and comments |
| 35 | +call css_color#init('none', 'none', 'htmlCssContent,htmlLegacyColor,htmlCommentPart') |
0 commit comments