mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 18:50:50 +00: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: af23f3890b
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()
|
String SourceHighlighterClient::to_html_string(String const& url, HighlightOutputMode mode) const
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
||||||
|
@ -306,8 +265,8 @@ String SourceHighlighterClient::to_html_string(URL::URL const& url) const
|
||||||
<head>
|
<head>
|
||||||
<meta name="color-scheme" content="dark light">)~~~"sv);
|
<meta name="color-scheme" content="dark light">)~~~"sv);
|
||||||
|
|
||||||
builder.appendff("<title>View Source - {}</title>", escape_html_entities(MUST(url.to_string())));
|
builder.appendff("<title>View Source - {}</title>", escape_html_entities(url));
|
||||||
builder.appendff("<style type=\"text/css\">{}</style>", generate_style());
|
builder.appendff("<style type=\"text/css\">{}</style>", HTML_HIGHLIGHTER_STYLE);
|
||||||
builder.append(R"~~~(
|
builder.append(R"~~~(
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -76,6 +76,7 @@ constexpr inline StringView HTML_HIGHLIGHTER_STYLE = R"~~~(
|
||||||
html {
|
html {
|
||||||
background-color: rgb(30, 30, 30);
|
background-color: rgb(30, 30, 30);
|
||||||
color: white;
|
color: white;
|
||||||
|
counter-reset: line;
|
||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
|
@ -86,6 +87,7 @@ constexpr inline StringView HTML_HIGHLIGHTER_STYLE = R"~~~(
|
||||||
--internal-color: darkgrey;
|
--internal-color: darkgrey;
|
||||||
--string-color: goldenrod;
|
--string-color: goldenrod;
|
||||||
--error-color: red;
|
--error-color: red;
|
||||||
|
--line-number-color: darkgrey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +100,7 @@ constexpr inline StringView HTML_HIGHLIGHTER_STYLE = R"~~~(
|
||||||
--internal-color: dimgrey;
|
--internal-color: dimgrey;
|
||||||
--string-color: darkgoldenrod;
|
--string-color: darkgoldenrod;
|
||||||
--error-color: darkred;
|
--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;
|
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 {
|
.tag {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--keyword-color);
|
color: var(--keyword-color);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue