From 0e0b3bb2fb1e86ae220c129d6856af1070e73bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 19 Feb 2023 23:09:51 +0100 Subject: [PATCH] shortcodes: don't break build and render for invalid parameters #480 --- exampleSite/content/tests/frontmatter.en.md | 43 ++++++++++++++++++++ exampleSite/content/tests/frontmatter.pir.md | 5 +++ layouts/partials/shortcodes/include.html | 8 ++-- static/css/tabs.css | 4 ++ static/css/theme.css | 9 ++++ 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 exampleSite/content/tests/frontmatter.en.md create mode 100644 exampleSite/content/tests/frontmatter.pir.md diff --git a/exampleSite/content/tests/frontmatter.en.md b/exampleSite/content/tests/frontmatter.en.md new file mode 100644 index 0000000000..cf16d0660f --- /dev/null +++ b/exampleSite/content/tests/frontmatter.en.md @@ -0,0 +1,43 @@ ++++ +description = "Test default settings for snippets of the VSCode Front Matter extension" +title = "VSCode Front Matter" ++++ + +## Empty Properties + +{{< attachments title="" pattern="" sort="" style="" color="" icon="" />}} + +{{< badge title="" style="" color="" icon="" >}}{{< /badge >}} + +{{< button href="" target="" type="" style="" color="" icon="" iconposition="" >}}{{< /button >}} + +{{< children description="" depth="" sort="" showhidden="" containerstyle="" style="" >}} + +{{% expand title="" open="" %}}{{% /expand %}} + +a{{< icon >}}a + +{{< include file="" hidefirstheading="" >}} + +````math align="" + +```` + +````mermaid align="" zoom="" + +```` + +{{% notice title="" style="" color="" icon="" %}}{{% /notice %}} + +{{< siteparam >}} + +{{< swagger src="" >}} + +{{< tabs groupid="" >}} +{{% tab name="" %}} + +{{% /tab %}} +{{% tab name="" %}} + +{{% /tab %}} +{{< /tabs >}} diff --git a/exampleSite/content/tests/frontmatter.pir.md b/exampleSite/content/tests/frontmatter.pir.md new file mode 100644 index 0000000000..a640a540f2 --- /dev/null +++ b/exampleSite/content/tests/frontmatter.pir.md @@ -0,0 +1,5 @@ ++++ +description = "Test default settings for snippets of the VSCode Front Matter extension" +title = "VSCode Front Matter" ++++ +{{< piratify >}} \ No newline at end of file diff --git a/layouts/partials/shortcodes/include.html b/layouts/partials/shortcodes/include.html index 11586594ac..b62997cfe6 100644 --- a/layouts/partials/shortcodes/include.html +++ b/layouts/partials/shortcodes/include.html @@ -4,10 +4,12 @@ {{- if eq (printf "%T" $hideFirstHeading) "string" }} {{- $hideFirstHeading = (eq $hideFirstHeading "true") }} {{- end }} -{{- if $hideFirstHeading }}
{{ end }} -{{- with $context }} +{{- if and (gt (len (trim $file " ")) 0) (fileExists $file) }} + {{- if $hideFirstHeading }}
{{ end }} + {{- with $context }} {{ $file | readFile | safeHTML }} -{{- if $hideFirstHeading }}
{{ end }} + {{- end }} + {{- if $hideFirstHeading }}
{{ end }} {{- end }} \ No newline at end of file diff --git a/static/css/tabs.css b/static/css/tabs.css index 5bb0ca0592..6673db0437 100644 --- a/static/css/tabs.css +++ b/static/css/tabs.css @@ -24,6 +24,10 @@ html[dir="rtl"] #body .tab-nav-button{ float: right; } +#body .tab-nav-button:after { + content: "\200b" +} + #body .tab-nav-button:first-child{ margin-inline-start: 9px; } diff --git a/static/css/theme.css b/static/css/theme.css index 2c25a9e34b..a7cc1cb208 100644 --- a/static/css/theme.css +++ b/static/css/theme.css @@ -1318,6 +1318,11 @@ html[dir="rtl"] .expand > .expand-label > i.fa-chevron-right { white-space: nowrap; } +.btn > *:after { + /* avoid breakage if no content is given */ + content: "\200b" +} + #body #body-inner .btn > *.highlight:after { background-color: transparent; } @@ -1700,6 +1705,10 @@ html[dir] #sidebar .collapsible-menu input.toggle:checked:before { border-end-start-radius: 0; } +.badge-content:after { + /* avoid breakage if no content is given */ + content: "\200b"; +} /* task list and its checkboxes */ article ul li:has(input[type="checkbox"]) { list-style: none;