feat: add support for center-aligned alerts in admonition syntax (#640)

This commit is contained in:
Cell
2025-10-11 17:45:43 +08:00
committed by GitHub
parent 969d0cc090
commit 94968bbbe1
2 changed files with 9 additions and 1 deletions
@@ -154,3 +154,8 @@ This is the default example type admonition.
{{< admonition quote "" false >}}
This is the default quote type admonition. Aliases: `cite`
{{< /admonition >}}
## Special Types
> [!center]
> This paragraph is **center-aligned**.
+4 -1
View File
@@ -1,6 +1,9 @@
{{- $basicTypes := slice "note" "tip" "important" "warning" "caution" -}}
{{- if .AlertTitle | or .AlertSign | or (.AlertType | in $basicTypes | not) -}}
{{- if eq .AlertType "center" -}}
{{- /* The "center" type is a special case for centering content. */ -}}
<blockquote class="blockquote-center">{{ .Text }}</blockquote>
{{- else if .AlertTitle | or .AlertSign | or (.AlertType | in $basicTypes | not) -}}
{{- /* The extended syntax is compatible with Obsidian and FixIt admonition shortcode. */ -}}
{{- $openMap := dict "+" true "-" false -}}
{{- $open := index $openMap .AlertSign | default true -}}