Highlighter: Use link highlighting for <head profile=""> attributes

This commit is contained in:
networkException 2022-12-19 10:08:56 +01:00
parent 0b0a728f42
commit 0f9b3ea798
Signed by: networkException
GPG key ID: E3877443AE684391

View file

@ -37,7 +37,11 @@ export class Highlighter {
this.spans.push(Span.createFromRange(attribute, attribute.nameRange, Color.Attribute, Font.Italic));
if (attribute.valueRange !== undefined) {
if (attribute.name === 'href') {
if ((token.name === 'a' || token.name === 'link') && attribute.name === 'href') {
this.spans.push(Span.createAnchorFromRange(attribute, attribute.valueRange, Color.String, Font.Underline, Cursor.Pointer, Link.of(attribute.value)));
} else if (token.name === 'head' && attribute.name === 'profile') {
// FIXME: This does not support multiple profiles separated by white space. See
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head#attr-profile (non standard so no link to a specification)
this.spans.push(Span.createAnchorFromRange(attribute, attribute.valueRange, Color.String, Font.Underline, Cursor.Pointer, Link.of(attribute.value)));
} else {
this.spans.push(Span.createFromRange(attribute, attribute.valueRange, Color.String));