CSS: Markdown code blocks are rendered with wrong padding #10039

Closed
opened 2025-12-29 21:26:04 +01:00 by adam · 4 comments
Owner

Originally created by @jsenecal on GitHub (Aug 1, 2024).

Originally assigned to: @arthanson on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.0.8

Python Version

3.10

Steps to Reproduce

  1. Set any comment field to include the following markdown:
First line
\```
first code block line
second code block line
third code block line
\```

(Remove the backslashes '\')
2. Click on preview, or save the form.
3. Notice that fist code block line is not aligned with the following lines when rendered

Expected Behavior

All the code block lines should be aligned

Observed Behavior

The first line is padded properly but the remaining lines are more to the left, as if there was no padding:
image

The Tabler CSS for markdown code blocks is unaltered in NetBox with regards to padding (padding: 2px 4px;) and the issue is also visible when live editing their demo using chrome inspect, albeit less evident in some of the examples due to their font choices:
image

Originally created by @jsenecal on GitHub (Aug 1, 2024). Originally assigned to: @arthanson on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.0.8 ### Python Version 3.10 ### Steps to Reproduce 1. Set any comment field to include the following markdown: ``` First line \``` first code block line second code block line third code block line \``` ``` (Remove the backslashes '\\') 2. Click on preview, or save the form. 3. Notice that `fist code block line` is not aligned with the following lines when rendered ### Expected Behavior All the code block lines should be aligned ### Observed Behavior The first line is padded properly but the remaining lines are more to the left, as if there was no padding: ![image](https://github.com/user-attachments/assets/584a9676-46e2-4adf-a459-faf0484e2e1d) The Tabler CSS for markdown code blocks is unaltered in NetBox with regards to padding (`padding: 2px 4px;`) and the issue is also visible when live editing [their demo](https://preview.tabler.io/markdown.html) using chrome inspect, albeit less evident in some of the examples due to their font choices: ![image](https://github.com/user-attachments/assets/da3b51bb-efe9-4a2a-b5fc-073c964569be)
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:26:05 +01:00
adam closed this issue 2025-12-29 21:26:05 +01:00
Author
Owner

@jsenecal commented on GitHub (Aug 1, 2024):

I'm not sure NetBox devs will want to fix what seem to be an upstream bug but I figured I would document it.

@jsenecal commented on GitHub (Aug 1, 2024): I'm not sure NetBox devs will want to fix what seem to be an upstream bug but I figured I would document it.
Author
Owner

@jsenecal commented on GitHub (Aug 1, 2024):

I also created an upstream issue https://github.com/tabler/tabler/issues/1930

@jsenecal commented on GitHub (Aug 1, 2024): I also created an upstream issue https://github.com/tabler/tabler/issues/1930
Author
Owner

@jeremystretch commented on GitHub (Aug 2, 2024):

The fenced_code Markdown extension renders code blocks with a<code> tag inside a <pre> tag. Looks like the first-row indentation results from the padding on the <code> element.

We could either remove the <code> element, or add a CSS rule to remove any padding from <code> elements within a <pre>.

@jeremystretch commented on GitHub (Aug 2, 2024): The `fenced_code` Markdown extension renders code blocks with a`<code>` tag inside a `<pre>` tag. Looks like the first-row indentation results from the padding on the `<code>` element. We could either remove the `<code>` element, or add a CSS rule to remove any padding from `<code>` elements within a `<pre>`.
Author
Owner

@jsenecal commented on GitHub (Aug 2, 2024):

Adding:

pre code {
  padding: unset;
}

in netbox/project-static/styles/overrides/_tabler.scss should do it.

@jsenecal commented on GitHub (Aug 2, 2024): Adding: ```css pre code { padding: unset; } ``` in netbox/project-static/styles/overrides/_tabler.scss should do it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10039