chore(style): update code style
This commit is contained in:
@@ -1,42 +1,54 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` -}}
|
||||
{{ $iconMap := dict "note" "fas fa-pencil-alt" -}}
|
||||
{{ $iconMap = dict "abstract" "fas fa-list-ul" | merge $iconMap -}}
|
||||
{{ $iconMap = dict "info" "fas fa-info-circle" | merge $iconMap -}}
|
||||
{{ $iconMap = dict "tip" "fas fa-lightbulb" | merge $iconMap -}}
|
||||
{{ $iconMap = dict "success" "fas fa-check-circle" | merge $iconMap -}}
|
||||
{{ $iconMap = dict "question" "fas fa-question-circle" | merge $iconMap -}}
|
||||
{{ $iconMap = dict "warning" "fas fa-exclamation-triangle" | merge $iconMap -}}
|
||||
{{ $iconMap = dict "failure" "fas fa-times-circle" | merge $iconMap -}}
|
||||
{{ $iconMap = dict "danger" "fas fa-skull-crossbones" | merge $iconMap -}}
|
||||
{{ $iconMap = dict "bug" "fas fa-bug" | merge $iconMap -}}
|
||||
{{ $iconMap = dict "example" "fas fa-list-ol" | merge $iconMap -}}
|
||||
{{ $iconMap = dict "quote" "fas fa-quote-right" | merge $iconMap -}}
|
||||
{{ $iconMap = dict "details" "fas fa-angle-down" | merge $iconMap -}}
|
||||
{{- $_hugo_config := `{ "version": 1 }` -}}
|
||||
{{- $iconMap := dict "note" "fas fa-pencil-alt" -}}
|
||||
{{- $iconMap = dict "abstract" "fas fa-list-ul" | merge $iconMap -}}
|
||||
{{- $iconMap = dict "info" "fas fa-info-circle" | merge $iconMap -}}
|
||||
{{- $iconMap = dict "tip" "fas fa-lightbulb" | merge $iconMap -}}
|
||||
{{- $iconMap = dict "success" "fas fa-check-circle" | merge $iconMap -}}
|
||||
{{- $iconMap = dict "question" "fas fa-question-circle" | merge $iconMap -}}
|
||||
{{- $iconMap = dict "warning" "fas fa-exclamation-triangle" | merge $iconMap -}}
|
||||
{{- $iconMap = dict "failure" "fas fa-times-circle" | merge $iconMap -}}
|
||||
{{- $iconMap = dict "danger" "fas fa-skull-crossbones" | merge $iconMap -}}
|
||||
{{- $iconMap = dict "bug" "fas fa-bug" | merge $iconMap -}}
|
||||
{{- $iconMap = dict "example" "fas fa-list-ol" | merge $iconMap -}}
|
||||
{{- $iconMap = dict "quote" "fas fa-quote-right" | merge $iconMap -}}
|
||||
{{- $iconMap = dict "details" "fas fa-angle-down" | merge $iconMap -}}
|
||||
|
||||
{{ if .IsNamedParams -}}
|
||||
{{ $type := .Get "type" }}
|
||||
{{ if eq (.Get "details") "true" -}}
|
||||
{{- if .IsNamedParams -}}
|
||||
{{- $type := .Get "type" -}}
|
||||
{{- if eq (.Get "details") "true" -}}
|
||||
<details class="admonition {{ $type }}">
|
||||
{{- with .Get "title" }}<summary class="admonition-title"><i class="icon {{ index $iconMap $type }}"></i>{{ . }}<i class="details {{ index $iconMap "details" }}"></i></summary>{{ end }}
|
||||
{{- with .Get "title" -}}
|
||||
<summary class="admonition-title">
|
||||
<i class="icon {{ index $iconMap $type }}"></i>{{ . }}<i class="details {{ index $iconMap "details" }}"></i>
|
||||
</summary>
|
||||
{{- end -}}
|
||||
{{- .Inner -}}
|
||||
</details>
|
||||
{{- else -}}
|
||||
<div class="admonition {{ $type }}">
|
||||
{{- with .Get "title" }}<p class="admonition-title"><i class="icon {{ index $iconMap $type }}"></i>{{ . }}</p>{{ end }}
|
||||
{{- with .Get "title" -}}
|
||||
<p class="admonition-title"><i class="icon {{ index $iconMap $type }}"></i>{{ . }}</p>
|
||||
{{- end -}}
|
||||
{{- .Inner -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{ else -}}
|
||||
{{ $type := .Get 0 }}
|
||||
{{ if eq (.Get 2) "true" }}
|
||||
{{- else -}}
|
||||
{{- $type := .Get 0 -}}
|
||||
{{- if eq (.Get 2) "true" -}}
|
||||
<details class="admonition {{ $type }}">
|
||||
{{- with .Get 1 }}<summary class="admonition-title"><i class="icon {{ index $iconMap $type }}"></i>{{ . }}<i class="details {{ index $iconMap "details" }}"></i></summary>{{ end }}
|
||||
{{- with .Get 1 -}}
|
||||
<summary class="admonition-title">
|
||||
<i class="icon {{ index $iconMap $type }}"></i>{{ . }}<i class="details {{ index $iconMap "details" }}"></i>
|
||||
</summary>
|
||||
{{- end -}}
|
||||
{{- .Inner -}}
|
||||
</details>
|
||||
{{- else -}}
|
||||
<div class="admonition {{ $type }}">
|
||||
{{- with .Get 1 }}<p class="admonition-title"><i class="icon {{ index $iconMap $type }}"></i>{{ . }}</p>{{ end }}
|
||||
{{- with .Get 1 -}}
|
||||
<p class="admonition-title"><i class="icon {{ index $iconMap $type }}"></i>{{ . }}</p>
|
||||
{{- end -}}
|
||||
{{- .Inner -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
@@ -1,12 +1,12 @@
|
||||
{{ if .Get "date" -}}
|
||||
{{ $date := .Get "date" }}
|
||||
{{ $id := delimit (split (md5 $date) "" | shuffle) "" | printf "countdown-%s" -}}
|
||||
{{ $defaultPattern := printf "%%D %s %%H %s %%M %s %%S %s" (T "day") (T "hour") (T "minute") (T "second") }}
|
||||
{{ $new := dict $id (dict "date" $date "pattern" (.Get "pattern" | default $defaultPattern)) }}
|
||||
{{ with .Page.Scratch.Get "countdownMap" -}}
|
||||
{{ .Page.Scratch.Set "countdownMap" (merge . $new) -}}
|
||||
{{ else -}}
|
||||
{{ .Page.Scratch.Set "countdownMap" $new -}}
|
||||
{{ end -}}
|
||||
{{- if .Get "date" -}}
|
||||
{{- $date := .Get "date" -}}
|
||||
{{- $id := delimit (split (md5 $date) "" | shuffle) "" | printf "countdown-%s" -}}
|
||||
{{- $defaultPattern := printf "%%D %s %%H %s %%M %s %%S %s" (T "day") (T "hour") (T "minute") (T "second") -}}
|
||||
{{- $new := dict $id (dict "date" $date "pattern" (.Get "pattern" | default $defaultPattern)) -}}
|
||||
{{- with .Page.Scratch.Get "countdownMap" -}}
|
||||
{{- .Page.Scratch.Set "countdownMap" (merge . $new) -}}
|
||||
{{- else -}}
|
||||
{{- .Page.Scratch.Set "countdownMap" $new -}}
|
||||
{{- end -}}
|
||||
<div id="{{ $id }}" style={{ .Get "style" | safeCSS }}></div>
|
||||
{{ end -}}
|
||||
{{- end -}}
|
||||
@@ -1,10 +1,10 @@
|
||||
<!-- shuffle md5 as id -->
|
||||
{{ $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "echarts-%s" -}}
|
||||
{{ $echartsMap := .Page.Scratch.Get "echartsMap" -}}
|
||||
{{ if $echartsMap -}}
|
||||
{{- $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "echarts-%s" -}}
|
||||
{{- $echartsMap := .Page.Scratch.Get "echartsMap" -}}
|
||||
{{- if $echartsMap -}}
|
||||
{{ $echartsMap = .Inner | printf "{%s}" | dict $id | merge $echartsMap -}}
|
||||
{{ else -}}
|
||||
{{- else -}}
|
||||
{{ $echartsMap = .Inner | printf "{%s}" | dict $id -}}
|
||||
{{ end -}}
|
||||
{{ .Page.Scratch.Set "echartsMap" $echartsMap -}}
|
||||
{{- end -}}
|
||||
{{- .Page.Scratch.Set "echartsMap" $echartsMap -}}
|
||||
<div class="echarts" id="{{ $id }}"></div>
|
||||
@@ -1,10 +1,10 @@
|
||||
<!-- shuffle md5 as id -->
|
||||
{{ $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "mermaid-%s" -}}
|
||||
{{ $mermaidMap := .Page.Scratch.Get "mermaidMap" -}}
|
||||
{{ if $mermaidMap -}}
|
||||
{{ $mermaidMap = trim .Inner "\n" | dict $id | merge $mermaidMap -}}
|
||||
{{ else -}}
|
||||
{{ $mermaidMap = trim .Inner "\n" | dict $id -}}
|
||||
{{ end -}}
|
||||
{{ .Page.Scratch.Set "mermaidMap" $mermaidMap -}}
|
||||
{{- $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "mermaid-%s" -}}
|
||||
{{- $mermaidMap := .Page.Scratch.Get "mermaidMap" -}}
|
||||
{{- if $mermaidMap -}}
|
||||
{{- $mermaidMap = trim .Inner "\n" | dict $id | merge $mermaidMap -}}
|
||||
{{- else -}}
|
||||
{{- $mermaidMap = trim .Inner "\n" | dict $id -}}
|
||||
{{- end -}}
|
||||
{{- .Page.Scratch.Set "mermaidMap" $mermaidMap -}}
|
||||
<div class="mermaid" id="{{ $id }}"></div>
|
||||
@@ -1,22 +1,22 @@
|
||||
{{ .Page.Scratch.Set "music" "true" -}}
|
||||
{{ if .IsNamedParams }}
|
||||
{{- .Page.Scratch.Set "music" "true" -}}
|
||||
{{- if .IsNamedParams -}}
|
||||
<meting-js server={{ .Get "server" }} type={{ .Get "type" }} id={{ .Get "id" }}
|
||||
{{ with .Get "autoplay" }}
|
||||
{{- with .Get "autoplay" -}}
|
||||
autoplay={{ . }}
|
||||
{{ end }}
|
||||
{{ with .Get "mini" }}
|
||||
{{- end -}}
|
||||
{{- with .Get "mini" -}}
|
||||
mini={{ . }}
|
||||
{{ end }}
|
||||
{{ with .Get "fixed" }}
|
||||
{{- end -}}
|
||||
{{- with .Get "fixed" -}}
|
||||
fixed={{ . }}
|
||||
{{ end }}
|
||||
{{ with .Get "list-folded" }}
|
||||
{{- end -}}
|
||||
{{- with .Get "list-folded" -}}
|
||||
list-folded={{ . }}
|
||||
{{ end }}
|
||||
{{ with .Get "list-max-height" }}
|
||||
{{- end -}}
|
||||
{{- with .Get "list-max-height" -}}
|
||||
list-max-height={{ . }}
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
theme="#A9A9B3"></meting-js>
|
||||
{{ else }}
|
||||
{{- else -}}
|
||||
<meting-js server={{ .Get 0 }} type={{ .Get 1 }} id={{ .Get 2 }} theme="#A9A9B3"></meting-js>></meting-js>
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
@@ -1,50 +1,56 @@
|
||||
<!-- only the trailing newline is retained -->
|
||||
{{ $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner }}
|
||||
{{- $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner -}}
|
||||
<!-- shuffle md5 as id -->
|
||||
{{ $id := delimit (split (md5 $content) "" | shuffle) "" | printf "typeit-%s" }}
|
||||
{{- $id := delimit (split (md5 $content) "" | shuffle) "" | printf "typeit-%s" -}}
|
||||
|
||||
<div class={{ .Get "class" | default "typeit" }}>
|
||||
<!-- raw html content -->
|
||||
{{ if .Get "raw" }}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>{{ $content | safeHTML }}</div>
|
||||
{{- if .Get "raw" -}}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>
|
||||
{{- $content | safeHTML -}}
|
||||
</div>
|
||||
<div id={{ $id }}></div>
|
||||
{{ else if .Get "code" }}
|
||||
{{- else if .Get "code" -}}
|
||||
<!-- highlight code content without line number -->
|
||||
{{ $content = highlight $content (.Get "code") "linenos=false" }}
|
||||
{{- $content = highlight $content (.Get "code") "linenos=false" -}}
|
||||
<!-- delete outer label -->
|
||||
{{ $content = replaceRE `<div class="highlight"><pre class="chroma"><code[^<>]*>(?s)(.*)</code></pre></div>` "$1" $content }}
|
||||
{{- $content = replaceRE `<div class="highlight"><pre class="chroma"><code[^<>]*>(?s)(.*)</code></pre></div>` "$1" $content -}}
|
||||
<!-- parsing markdown links -->
|
||||
{{ $content = replaceRE `(<span[^<>]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)(</span>)` "$1$2$6<a href=$4>$3</a>$1$5$6" $content }}
|
||||
{{- $content = replaceRE `(<span[^<>]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)(</span>)` "$1$2$6<a href=$4>$3</a>$1$5$6" $content -}}
|
||||
<!-- replace " " to " " and replace "\n" to "<br />" -->
|
||||
{{ $content = replaceRE ` ` " " $content | replaceRE `(<\w+) ` "$1 " | replaceRE `\n` "<br />" }}
|
||||
{{- $content = replaceRE ` ` " " $content | replaceRE `(<\w+) ` "$1 " | replaceRE `\n` "<br />" -}}
|
||||
<!-- fix "<br />" location error which is a bug of Typeit HTML parser -->
|
||||
{{ $content = replaceRE `<br /></span>` "</span><br />" $content }}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>{{ $content | safeHTML }}</div>
|
||||
{{- $content = replaceRE `<br /></span>` "</span><br />" $content -}}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>
|
||||
{{- $content | safeHTML -}}
|
||||
</div>
|
||||
<div class="highlight" id={{ $id }}></div>
|
||||
{{ else }}
|
||||
{{ $tag := .Get "tag" | default "p" }}
|
||||
{{ $content = $content | markdownify | chomp }}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>{{ $content | safeHTML }}</div>
|
||||
{{ printf "<%s id=%s></%s>" $tag $id $tag | safeHTML }}
|
||||
{{ end }}
|
||||
{{- else -}}
|
||||
{{- $tag := .Get "tag" | default "p" -}}
|
||||
{{- $content = $content | markdownify | chomp -}}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>
|
||||
{{- $content | safeHTML -}}
|
||||
</div>
|
||||
{{- printf "<%s id=%s></%s>" $tag $id $tag | safeHTML -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ $typeitMap := .Page.Scratch.Get "typeitMap" }}
|
||||
{{ $group := slice $id }}
|
||||
{{ with .Get "group" }}
|
||||
{{ if $typeitMap }}
|
||||
{{ if index $typeitMap . }}
|
||||
{{ $group = index $typeitMap . | append $id }}
|
||||
{{ end }}
|
||||
{{ $typeitMap = dict . $group | merge $typeitMap }}
|
||||
{{ else }}
|
||||
{{ $typeitMap = dict . $group }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ if $typeitMap }}
|
||||
{{ $typeitMap = dict $id $group | merge $typeitMap }}
|
||||
{{ else }}
|
||||
{{ $typeitMap = dict $id $group }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ .Page.Scratch.Set "typeitMap" $typeitMap }}
|
||||
{{- $typeitMap := .Page.Scratch.Get "typeitMap" -}}
|
||||
{{- $group := slice $id -}}
|
||||
{{- with .Get "group" -}}
|
||||
{{- if $typeitMap -}}
|
||||
{{- if index $typeitMap . -}}
|
||||
{{- $group = index $typeitMap . | append $id -}}
|
||||
{{- end -}}
|
||||
{{- $typeitMap = dict . $group | merge $typeitMap -}}
|
||||
{{- else -}}
|
||||
{{- $typeitMap = dict . $group -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- if $typeitMap -}}
|
||||
{{- $typeitMap = dict $id $group | merge $typeitMap -}}
|
||||
{{- else -}}
|
||||
{{- $typeitMap = dict $id $group -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- .Page.Scratch.Set "typeitMap" $typeitMap -}}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user