-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect code fence width affecting background color #10723
Comments
Rendering of fenced code blocks varies with:
I use this CSS to produce the same visual output (approximately) for all combinations of the above: main.css/* Applies when there are no line numbers, or when line numbers are inline. */
.highlight > pre {
padding: 1em 0 1em 1em;
}
/* Applies when line numbers are in a table cell. */
.highlight div {
padding: 0 0 0 1em;
}
/* Applies to all. */
.highlight div,
.highlight > pre {
overflow-x: auto;
/* add border-radius and box-shadow here */
}
/* Applies when using an external style sheet. */
/* https://github.com/alecthomas/chroma/issues/722 */
.highlight .chroma .lntable .lnt,
.highlight .chroma .lntable .hl {
display: flex;
}
/* Applies when using an external style sheet. */
/* https://github.com/alecthomas/chroma/issues/722 */
.highlight .chroma .lntable .lntd + .lntd {
width: 100%;
} Example:
There's an open issue upstream about one of the combinations, but otherwise I'm not sure this is actionable. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
yes. currently using latest release.
The {{ highlight }} function resulting in generating html/css that does not fully span the entire width of the fenced code block when there is long lines.
After inspecting the generated css this issue can be resolved by adding
width: fit-content
to the div that immediately follows<div class="highlight">
Here is a simple example to reproduce:
Here is the generated html for a simplified example (line numbers option off):
and here is the rendered output:
and here is the rended output after adding
width: fit-content
to the<pre>
element:Additional Information:
When
lineNos = true
there are several additional element generated in a code block compared to whenlineNos = false
When
lineNos = true
the classless<div>
that immediately follows<div class="highlight">
can be assignedwidth: fit-content
to resolve the issue described.When
lineNos = false
, there are fewer additional elements generated. The described issue can be resolved by addingwidth: fit-content
to the<pre>
element.The text was updated successfully, but these errors were encountered: