Refactor columns shortcode to use markdownify for consistent HTML output, Add new mdcolumns shortcode to convert markdown column content to HTML, Remove unnecessary comments and reformat code

This commit is contained in:
Andreas Hnida 2024-04-01 09:31:49 +02:00
commit bd43b8aeee
3 changed files with 32 additions and 32 deletions

View file

@ -1,28 +1,30 @@
{{/* TODO Add To Docs "top" */}}
<div class="md:flex {{ if isset .Params "center" }}items-center {{ end }}{{ with .Get "class" }} {{ . }} {{ else }} mt-6 {{ end }}">
<div class="md:flex {{ if isset .Params "center" }}items-center {{ end }}{{ with .Get "class" }} {{ . }} {{ else }} mt-6 {{ end }}">
{{ range split (trim .Inner " \n") "..column.." }}
{{ if ne . "" }} <!-- Check if the column content is not empty -->
{{ printf "<div class=\"markdown-inner items-center flex-1 px-4 \">"| safeHTML }}
{{ . | safeHTML }}
{{ printf "</div>" | safeHTML }}
<!-- Process each column's content through markdownify to ensure consistent HTML output -->
{{ $columnContent := . | markdownify }}
<div class="markdown-inner items-center flex-1 px-4">
<!-- Use safeHTML to insert the processed content as HTML -->
{{ $columnContent | safeHTML }}
</div>
{{ end }}
{{ end }}
</div>
{{/*
Adds the ability to create columns in markdown content.
Usage:
{{< columns class="some-class" >}}
Content
..column..
Content
{{< /columns >}}
Adds the ability to create columns in markdown content.
Usage:
{{< columns class="some-class" >}}
Content
..column..
Content
{{< /columns >}}
*/}}
*/}}