From 0f9b3ea798648c039d2097806163211b62a67ccf Mon Sep 17 00:00:00 2001 From: networkException Date: Mon, 19 Dec 2022 10:08:56 +0100 Subject: [PATCH] Highlighter: Use link highlighting for attributes --- src/html/highlighter.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/html/highlighter.ts b/src/html/highlighter.ts index 56fc93e..89b42b1 100644 --- a/src/html/highlighter.ts +++ b/src/html/highlighter.ts @@ -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));