{{ $package := (index .Params 0) }}
{{ $listname := (index .Params 1) }}
{{ $filter := split (index .Params 2) " " }}
{{ $filter1 := index $filter 0 }}
{{ $filter2 := index $filter 1 }}
{{ $filter3 := index $filter 2 }}

{{ $list := (index (index .Site.Data.docs $package) $listname) }}
{{ $fields := after 3 .Params }}
{{ $list := where $list $filter1 $filter2 $filter3 }}


<div class="overflow-x-auto">
  <table>
    <thead>
      <tr>
        {{ range $fields }}
          <th>{{ . }}</th>
        {{ end }}
      </tr>
    </thead>
    <tbody>
      {{ range $list }}
        <tr>
          {{ range $k, $v := . }}
            {{ $.Scratch.Set $k $v }}
          {{ end }}
          {{ range $k, $v := $fields }}
            <td>
              {{ $tdContent := $.Scratch.Get . }}
              {{ if eq $k 3 }}
                {{ printf "%v" $tdContent |
                  strings.ReplaceRE `\[` "<ol><li>" |
                  strings.ReplaceRE `\s` "</li><li>" |
                  strings.ReplaceRE `\]` "</li></ol>" |
                  safeHTML
                }}
              {{ else }}
                {{ $tdContent }}
              {{ end }}
            </td>
          {{ end }}
        </tr>
      {{ end }}
    </tbody>
  </table>
</div>
