Unable to Align Markdown Tables Values #8267

Closed
opened 2025-12-29 20:34:30 +01:00 by adam · 2 comments
Owner

Originally created by @adparis99 on GitHub (Jun 29, 2023).

Originally assigned to: @kkthxbye-code on GitHub.

NetBox version

3.5.1 (also tested on 3.5.4)

Python version

3.10

Steps to Reproduce

  1. Edit any object that supports the Comments field
  2. Add a table with colons on one or both sides of the hyphens in header row, thus indicating desired alignment, such as:
| Left Alignment| Center Alignment | Right Aligment     |
| :---        |    :----:   |          ---: |
| Words     | Title       | Here's this   |
| Values   | Text        | And more      |
  1. Either preview the table on the Edit page, or save the object and view the Comments field

Expected Behavior

I expected the table to be aligned per the documentation on markdown support, which would involve it appearing like below:

Left Alignment Center Alignment Right Aligment
Words Title Here's this
Values Text And more

Observed Behavior

The colons seem to be totally ignored, as shown in the screenshots below (using the same markdown syntax as above):

image

image

Originally created by @adparis99 on GitHub (Jun 29, 2023). Originally assigned to: @kkthxbye-code on GitHub. ### NetBox version 3.5.1 (also tested on 3.5.4) ### Python version 3.10 ### Steps to Reproduce 1. Edit any object that supports the Comments field 2. Add a table with colons on one or both sides of the hyphens in header row, thus indicating desired alignment, such as: ``` | Left Alignment| Center Alignment | Right Aligment | | :--- | :----: | ---: | | Words | Title | Here's this | | Values | Text | And more | ``` 3. Either preview the table on the Edit page, or save the object and view the Comments field ### Expected Behavior I expected the table to be aligned per [the documentation on markdown support](https://docs.netbox.dev/en/stable/reference/markdown/), which would involve it appearing like below: | Left Alignment| Center Alignment | Right Aligment | | :--- | :----: | ---: | | Words | Title | Here's this | | Values | Text | And more | ### Observed Behavior The colons seem to be totally ignored, as shown in the screenshots below (using the same markdown syntax as above): ![image](https://github.com/netbox-community/netbox/assets/16410007/33b7ce9e-851a-4de3-971f-912cf2f0bf18) ![image](https://github.com/netbox-community/netbox/assets/16410007/05d2ef73-fd87-4a49-8a24-02a0dbbf66e1)
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 20:34:30 +01:00
adam closed this issue 2025-12-29 20:34:30 +01:00
Author
Owner

@kkthxbye-code commented on GitHub (Jul 23, 2023):

I wanted to fix this, but there's really no good solution right now because of python dependency hell.

It's easily fixable by adding:

        "th": ["align"],
        "td": ["align"],

0f0cf683c4/netbox/utilities/utils.py (L521)

Here, but this doesn't fix th as boostrap has some css that sets the text-align property, and it's not possible to unset.

The Markdown library extension for tables does support setting a css class instead of the align attribute, but that was added in 3.4.x. We can't use 3.4.x because of:

The conflict is caused by:
    The user requested Markdown==3.4.3
    mkdocs-material 9.1.18 depends on markdown>=3.2
    mkdocstrings[python-legacy] 0.22.0 depends on Markdown>=3.3
    mkdocs 1.4.3 depends on markdown<3.4 and >=3.2.1
    The user requested Markdown==3.4.3
    mkdocs-material 9.1.18 depends on markdown>=3.2
    mkdocstrings[python-legacy] 0.22.0 depends on Markdown>=3.3
    mkdocs 1.4.2 depends on markdown<3.4 and >=3.2.1

This is caused by the maintainer of mkdocs that limited the max version of markdown for years:

https://github.com/mkdocs/mkdocs/pull/3222 (not part of a release yet)

It's still not in a realease, so we can't update the Markdown package past 3.3.x and as such we cannot get the updated tables extension. So we would have to hack a fix on our own.

If anyone wants to figure this out, feel free to. We could copy the upstream table extension and just vendor it I guess or maybe there's some hack in CSS that I don't know about where you can unset a css property. Anyway I'm done trying to work around pythons insane packaging rules.

@kkthxbye-code commented on GitHub (Jul 23, 2023): I wanted to fix this, but there's really no good solution right now because of python dependency hell. It's easily fixable by adding: ``` "th": ["align"], "td": ["align"], ``` https://github.com/netbox-community/netbox/blob/0f0cf683c44f058a72a50fa90b889ab3fc6bea08/netbox/utilities/utils.py#L521 Here, but this doesn't fix th as boostrap has some css that sets the text-align property, and it's not possible to unset. The Markdown library extension for tables does support setting a css class instead of the align attribute, but that was added in 3.4.x. We can't use 3.4.x because of: ``` The conflict is caused by: The user requested Markdown==3.4.3 mkdocs-material 9.1.18 depends on markdown>=3.2 mkdocstrings[python-legacy] 0.22.0 depends on Markdown>=3.3 mkdocs 1.4.3 depends on markdown<3.4 and >=3.2.1 The user requested Markdown==3.4.3 mkdocs-material 9.1.18 depends on markdown>=3.2 mkdocstrings[python-legacy] 0.22.0 depends on Markdown>=3.3 mkdocs 1.4.2 depends on markdown<3.4 and >=3.2.1 ``` This is caused by the maintainer of mkdocs that limited the max version of markdown for years: https://github.com/mkdocs/mkdocs/pull/3222 (not part of a release yet) It's still not in a realease, so we can't update the Markdown package past 3.3.x and as such we cannot get the updated tables extension. So we would have to hack a fix on our own. If anyone wants to figure this out, feel free to. We could copy the upstream table extension and just vendor it I guess or maybe there's some hack in CSS that I don't know about where you can unset a css property. Anyway I'm done trying to work around pythons insane packaging rules.
Author
Owner

@kkthxbye-code commented on GitHub (Jul 23, 2023):

I figured out a hackish solution to overriding the CSS. See the linked PR. It's not optimal, but wasting more time on trying to upgrade the Markdown library seems counter-productive.

@kkthxbye-code commented on GitHub (Jul 23, 2023): I figured out a hackish solution to overriding the CSS. See the linked PR. It's not optimal, but wasting more time on trying to upgrade the Markdown library seems counter-productive.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8267