Render hooks for tables?

Currently, we have render-hooks for images, anchor tags, and headings. Are there any plans for implementing render-hooks for tables as well?

I use Bootstrap and tables in Bootstrap need to have classes like “table”, “table-*” for styling them. For now, I made a shortcode as a hack to apply these classes to .Inner. But I feel it would be really great if we had render-hooks for tables as well.

{{ .Inner | markdownify | replaceRE "<table>" (printf `<table class="table %s">` (.Get 0 | default "")) | safeHTML }}

I “fixed” this requirement by creating a class “prose” for my content. That prose class then is receiving all the classes required in the SCSS, something like this:

.prose {
table {
  .dark & {
    @extend .table-dark;
  }

  .light & {
    @extend .table-light;
  }

  @extend .table;
  @extend .table-sm;
}
}

I think a render hook would be great, but will be hard to implement, because it requires more than just one single loop around the code (as in <a>something</a>) for headers/footers, rows and definitions for instance for column span, width etc…

If you simply need to apply one or more classes to the <table> element…

config.toml

[markup.goldmark.parser.attribute]
block = true

markdown

Name|Type
:--|:--
Spot|Dog
Felix|Cat
{.table .foo}
6 Likes