Fossil User Forum

Format markdown tables in wiki with borders?
Login

Format markdown tables in wiki with borders?

Format markdown tables in wiki with borders?

(1.1) By David Reimer (dajare) on 2025-04-30 10:15:24 edited from 1.0 [link] [source]

I've been through all the "skins", but cannot find one that styles (Markdown) tables with borders.

Is there a setting for this? (Wouldn't think so!) Or is there a simple :) way of adding this CSS? Or a skin out there, somewhere, that has this baked in?

I live in hope!

(2.1) By Torsten Berg (torstenberg) on 2025-04-30 12:08:37 edited from 2.0 in reply to 1.1 [link] [source]

You need to modify an existing skin or create your own. There is no simple setting for this.

I have changed the CSS in one of my projects by adding this to the existing code:

.wiki table {border-collapse: collapse;}
.wiki tr {border: none;}
.wiki td {border-right: solid 1px; border-left: solid 1px; padding: 4px 8px 4px 8px;}
.wiki table, .wiki th {border: 1px solid black;}
.wiki th {background-color: #cccccc}

It uses the .wiki class so it only affects wiki pages.

(3) By Stephan Beal (stephan) on 2025-04-30 12:31:22 in reply to 2.1 [source]

You need to modify an existing skin or create your own.

If you specifically want to limit it to tables within markdown comment, as opposed to fossil wiki or tables used for page layout (like the user list), the CSS rules would need to be prefixed with:

.markdown ... {...}

Unfortunately, markdown-generated tables like:

| h1 | h2 |
| a | b |
| c | d |

are not marked as being any different from plain HTML tables, so those cannot currently be reliably targeted distinctly from other tables. We should maybe add the CSS class "md-table" to those for that purpose.

(4) By David Reimer (dajare) on 2025-04-30 13:57:58 in reply to 2.1 [link] [source]

Very helpful — thanks! Watching what was happening via "Inspector" was key, as the .wiki class didn't "take" in my case. I needed to use .markdown as mentioned by Stephan. This is what I ended up with:

.markdown table {border-collapse: collapse; border: 1px solid #ccc;}
.markdown th,
.markdown td {border: 1px solid #ccc; padding: .25em .5em;}
.markdown th {background-color: #f5f3f2;}

The skins help page was also essential! :)

Happy now.

(5) By Stephan Beal (stephan) on 2025-04-30 14:49:54 in reply to 4 [link] [source]

I needed to use .markdown...

As of src:f0d11ab2fb6f67, you can specifically target markdown-generated tables, as distinct from hand-written HTML tables in otherwise-markdown content, by filtering on:

.markdown .md-table {border-collapse: collapse; border: 1px solid #ccc;}
.markdown .md-table th,
.markdown .md-table td {border: 1px solid #ccc; padding: .25em .5em;}
.markdown .md-table th {background-color: #f5f3f2;}

If you need to mark up tables inside markdown content which were not not produced via markdown conversion (i.e. they're "hand-written"), use:

.markdown table:not(.md-table) { ... }

(6) By David Reimer (dajare) on 2025-04-30 14:56:08 in reply to 5 [link] [source]

Wow! That's impressive. Thanks for picking that up.

(And this exercise has been a good entry point for "custom skinning" — one day, hopefully, I'll take that a bit further.)

(7) By Stephan Beal (stephan) on 2025-04-30 15:39:49 in reply to 4 [link] [source]

The skins help page was also essential! :)

That page was just updated to include an alternative (IMO easier) approach for importing a locally-developed skin into one or more repos:

src:/doc/trunk/www/customskin.md#procedure

(8) By Marcelo Huerta (richieadler) on 2025-05-09 22:12:07 in reply to 7 [link] [source]

The procedure includes compiling skintxt2config.c as s2c in a Unixoid OS...

Any suggestion about the proper incantation to do the same under Windows using Visual Studio Build Tools?

(9) By Stephan Beal (stephan) on 2025-05-09 22:24:38 in reply to 8 [link] [source]

Any suggestion about the proper incantation to do the same under Windows using Visual Studio Build Tools?

skintxt2config.c is plain C89, so "should" work as-is with any C compiler or IDE. How it's done in non-Unixoid environments is beyond my ken, though.

Based solely on a cursory examination of an unrelated Makefile.msc, without having actually tried this, it looks to be something like the following for Microsoft C:

$ cl /path/to/skintxt2config.c

(Assuming that cl.exe is in the %PATH%.)

My (mis?)understanding is that that would leave skintxt2config.exe in the current directory.

(10) By Marcelo Huerta (richieadler) on 2025-05-11 02:07:40 in reply to 9 [link] [source]

It worked perfectly.