mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
LibWeb: Syntax-highlight CSS within HTML :^)
This commit is contained in:
parent
38f6140159
commit
6f71516409
1 changed files with 16 additions and 1 deletions
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <AK/Debug.h>
|
#include <AK/Debug.h>
|
||||||
#include <LibJS/SyntaxHighlighter.h>
|
#include <LibJS/SyntaxHighlighter.h>
|
||||||
|
#include <LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.h>
|
||||||
#include <LibWeb/HTML/Parser/HTMLTokenizer.h>
|
#include <LibWeb/HTML/Parser/HTMLTokenizer.h>
|
||||||
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
|
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
|
||||||
|
|
||||||
|
@ -102,7 +103,21 @@ void SyntaxHighlighter::rehighlight(Palette const& palette)
|
||||||
spans.extend(proxy_client.corrected_spans());
|
spans.extend(proxy_client.corrected_spans());
|
||||||
substring_builder.clear();
|
substring_builder.clear();
|
||||||
} else if (state == State::CSS) {
|
} else if (state == State::CSS) {
|
||||||
// FIXME: Highlight CSS code here instead.
|
Syntax::ProxyHighlighterClient proxy_client {
|
||||||
|
*m_client,
|
||||||
|
substring_start_position,
|
||||||
|
static_cast<u64>(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();
|
substring_builder.clear();
|
||||||
}
|
}
|
||||||
state = State::HTML;
|
state = State::HTML;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue