mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 17:24:48 -05:00
LibWebView: Move line-number styling into HTML_HIGHLIGHTER_STYLE
This commit is contained in:
parent
e03da0e600
commit
af23f3890b
Notes:
github-actions[bot]
2024-09-30 07:54:22 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/af23f3890b1 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1513
2 changed files with 24 additions and 45 deletions
|
@ -232,48 +232,7 @@ StringView SourceHighlighterClient::class_for_token(u64 token_type) const
|
|||
}
|
||||
}
|
||||
|
||||
static String generate_style()
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
builder.append(HTML_HIGHLIGHTER_STYLE);
|
||||
builder.append(R"~~~(
|
||||
.html {
|
||||
counter-reset: line;
|
||||
}
|
||||
|
||||
.line {
|
||||
counter-increment: line;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.line::before {
|
||||
content: counter(line) " ";
|
||||
|
||||
display: inline-block;
|
||||
width: 2.5em;
|
||||
|
||||
padding-right: 0.5em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.line::before {
|
||||
color: darkgrey;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
.line::before {
|
||||
color: dimgray;
|
||||
}
|
||||
}
|
||||
)~~~"sv);
|
||||
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
String SourceHighlighterClient::to_html_string(URL::URL const& url) const
|
||||
String SourceHighlighterClient::to_html_string(String const& url, HighlightOutputMode mode) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
@ -306,9 +265,9 @@ String SourceHighlighterClient::to_html_string(URL::URL const& url) const
|
|||
<head>
|
||||
<meta name="color-scheme" content="dark light">)~~~"sv);
|
||||
|
||||
builder.appendff("<title>View Source - {}</title>", escape_html_entities(MUST(url.to_string())));
|
||||
builder.appendff("<style type=\"text/css\">{}</style>", generate_style());
|
||||
builder.append(R"~~~(
|
||||
builder.appendff("<title>View Source - {}</title>", escape_html_entities(url));
|
||||
builder.appendff("<style type=\"text/css\">{}</style>", HTML_HIGHLIGHTER_STYLE);
|
||||
builder.append(R"~~~(
|
||||
</head>
|
||||
<body>
|
||||
<pre class="html">)~~~"sv);
|
||||
|
|
|
@ -76,6 +76,7 @@ constexpr inline StringView HTML_HIGHLIGHTER_STYLE = R"~~~(
|
|||
html {
|
||||
background-color: rgb(30, 30, 30);
|
||||
color: white;
|
||||
counter-reset: line;
|
||||
}
|
||||
|
||||
:root {
|
||||
|
@ -86,6 +87,7 @@ constexpr inline StringView HTML_HIGHLIGHTER_STYLE = R"~~~(
|
|||
--internal-color: darkgrey;
|
||||
--string-color: goldenrod;
|
||||
--error-color: red;
|
||||
--line-number-color: darkgrey;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,6 +100,7 @@ constexpr inline StringView HTML_HIGHLIGHTER_STYLE = R"~~~(
|
|||
--internal-color: dimgrey;
|
||||
--string-color: darkgoldenrod;
|
||||
--error-color: darkred;
|
||||
--line-number-color: dimgrey;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,6 +109,23 @@ constexpr inline StringView HTML_HIGHLIGHTER_STYLE = R"~~~(
|
|||
font-family: Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
}
|
||||
|
||||
.line {
|
||||
counter-increment: line;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.line::before {
|
||||
content: counter(line) " ";
|
||||
|
||||
display: inline-block;
|
||||
width: 2.5em;
|
||||
|
||||
padding-right: 0.5em;
|
||||
text-align: right;
|
||||
|
||||
color: var(--line-number-color);
|
||||
}
|
||||
|
||||
.tag {
|
||||
font-weight: 600;
|
||||
color: var(--keyword-color);
|
||||
|
|
Loading…
Reference in a new issue