Skip to content

Commit 27b83b0

Browse files
committed
feat: add css patch to respect marked.js table alignment formatting
1 parent 943c1d8 commit 27b83b0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

assets/css/custom.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,24 @@
2828
border-left: 0.25rem solid #e7352c;
2929
margin-top: 1.6em;
3030
}
31+
32+
/*
33+
Fix table column alignment for markdown injected with marked.js.
34+
By default, marked.js uses the deprecated HTML "align" attribute
35+
(e.g. <td align="center">), while Hugo/Goldmark uses inline CSS
36+
(e.g. <td style="text-align:center;">).
37+
38+
Many modern CSS resets override "align", so without this rule
39+
the alignment is lost in dynamically injected tables.
40+
These selectors re-enable the expected alignment for tables
41+
coming from marked.js, without affecting Hugo-built tables.
42+
*/
43+
table th[align="left"], table td[align="left"] {
44+
text-align: left;
45+
}
46+
table th[align="center"], table td[align="center"] {
47+
text-align: center;
48+
}
49+
table th[align="right"], table td[align="right"] {
50+
text-align: right;
51+
}

0 commit comments

Comments
 (0)