Hello,
I propose adding the below shortcode to Hugo so that I can do:
{{% table style="width:50%" %}}
| a | b |
|---|---|
| c | d |
{{% /table %}}
<style>.toto { width:20%; } .toto th, .toto td { padding: 15px; text-align: left; }</style>
{{% table class="toto" %}}
| a | b |
|---|---|
| c | d |
{{% /table %}}
{{% table "zuzu" "border:3px dashed red;" %}}
| a | b |
|---|---|
| c | d |
{{% /table %}}
To result in:
table
Shortcode
{{ $.Scratch.Set "__table.class" "" }}
{{ $.Scratch.Set "__table.style" "" }}
{{ if .IsNamedParams }}
{{ with .Get "class" }}
{{ $.Scratch.Set "__table.class" (printf "%s%s%s" " class=\"" . "\"") }}
{{ end }}
{{ with .Get "style" }}
{{ $.Scratch.Set "__table.style" (printf "%s%s%s" " style=\"" . "\"") }}
{{ end }}
{{ else }}
{{ if len .Params | le 1 }}
{{ $.Scratch.Set "__table.class" (printf "%s%s%s" " class=\"" (.Get 0) "\"") }}
{{ end }}
{{ if len .Params | eq 2 }}
{{ $.Scratch.Set "__table.style" (printf "%s%s%s" " style=\"" (.Get 1) "\"") }}
{{ end }}
{{ end }}
{{ replace .Inner "<table>" (printf "%s%s%s%s" "<table" ($.Scratch.Get "__table.class") ($.Scratch.Get "__table.style") ">") | markdownify }}