From 6f71516409a151b58e64678c613fffd9ae8acdaf Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 21 Oct 2021 21:35:11 +0100 Subject: [PATCH] LibWeb: Syntax-highlight CSS within HTML :^) --- .../SyntaxHighlighter/SyntaxHighlighter.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.cpp b/Userland/Libraries/LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.cpp index cae5183436..44e5b74c39 100644 --- a/Userland/Libraries/LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.cpp +++ b/Userland/Libraries/LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -102,7 +103,21 @@ void SyntaxHighlighter::rehighlight(Palette const& palette) spans.extend(proxy_client.corrected_spans()); substring_builder.clear(); } else if (state == State::CSS) { - // FIXME: Highlight CSS code here instead. + Syntax::ProxyHighlighterClient proxy_client { + *m_client, + substring_start_position, + static_cast(AugmentedTokenKind::__Count) + first_free_token_kind_serial_value(), + substring_builder.string_view() + }; + { + CSS::SyntaxHighlighter highlighter; + highlighter.attach(proxy_client); + highlighter.rehighlight(palette); + highlighter.detach(); + register_nested_token_pairs(proxy_client.corrected_token_pairs(highlighter.matching_token_pairs())); + } + + spans.extend(proxy_client.corrected_spans()); substring_builder.clear(); } state = State::HTML;