emerald-ocean6 downloadsFix table column widths by dragging, and give cells background and text colours. Styles are saved in each cell as hidden comments, so they move with the cell.
An Obsidian plugin for Markdown tables: fix column widths and give cells background and text colours.
Colours are edited in Live Preview and Source mode. Reading view shows them and lets you adjust column widths.
Styles live inside the table cells as Obsidian comments, which Reading view hides:
| Sample %%{width:120px}%% | Yield |
| ------------------------ | -------------------- |
| MOF-5 %%{bg:green}%% | 82 % %%{color:red}%% |
| ZIF-8 %%{bg:#1e3a8a}%% | 64 % |
bg and color take a palette name (red, blue, ...) or any CSS colour (#e0f2fe, black, rgb(...)).width is read from the header cell only and fixes the whole column (120px, 12em, 30%; a bare number means pixels).Because each style sits in its own cell, it moves with the cell when rows or columns are moved, sorted or inserted, by Obsidian's table editor or by hand. You can also edit the comments directly in Source mode. Without the plugin, the table still renders normally and the comments stay hidden.
Until the plugin is in the community list, install it by hand:
main.js, manifest.json and styles.css from the latest release (or from this repository).<your vault>/.obsidian/plugins/table-styler/.With the BRAT plugin you can instead add TtWang3024/obsidian-table-styler as a beta plugin.
main.js is written by hand as plain CommonJS; there is no build step. The parser and CSS logic have unit tests that run with the JavaScript engine built into macOS:
osascript -l JavaScript tests/core-test.js main.js
The idea of keeping table data inside the note itself comes from Advanced Tables by Tony Grosinger. No code was copied from it.
MIT