Add table formatting, requires using custom "table" shortcode

This commit is contained in:
BBaoVanC 2022-04-23 17:54:05 -05:00
parent f4c056b99c
commit 5ffca36b84
Signed by: bbaovanc
GPG Key ID: 18089E4E3CCF1D3A
2 changed files with 31 additions and 0 deletions

View File

@ -436,6 +436,27 @@ hr {
border-color: var(--background-5); border-color: var(--background-5);
} }
table.markdown {
border-collapse: collapse;
border: 2px solid var(--text-normal);
}
.markdown thead {
background-color: var(--background-4);
}
.markdown th,
.markdown td {
padding: 8px;
}
.markdown tbody tr:nth-child(odd) {
background-color: var(--background);
}
.markdown tbody tr:nth-child(even) {
background-color: var(--background-2);
}
* { * {
box-sizing: border-box; box-sizing: border-box;
} }

View File

@ -0,0 +1,10 @@
{{/* See https://willschenk.com/articles/2020/styling_tables_with_hugo/ */}}
{{ $class := "markdown" }}
{{ with .Get "class" }}
{{ $class = delimit (slice $class .) " " }}
{{ end }}
{{ $htmlTable := .Inner | markdownify }}
{{ $new := printf `<table class="%s">` $class }}
{{ (replace $htmlTable "<table>" $new) | safeHTML }}