fix(srcatch): fix srcatch bugs
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
{{- $scratch := .Page.Scratch.Get "scratch" -}}
|
||||
|
||||
{{- /* shuffle md5 as id */ -}}
|
||||
{{- $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "echarts-%s" -}}
|
||||
<div class="echarts" id="{{ $id }}"></div>
|
||||
{{- $scratch.SetInMap "echartsMap" $id (printf "{%s}" .Inner) -}}
|
||||
6
layouts/shortcodes/echarts.html
Normal file
6
layouts/shortcodes/echarts.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{{- $scratch := .Page.Scratch.Get "scratch" -}}
|
||||
|
||||
{{- $content := .Inner | transform.Unmarshal | jsonify -}}
|
||||
{{- $id := partial "function/id.html" (dict "content" $content "scratch" $scratch) -}}
|
||||
<div class="echarts" id="{{ $id }}"></div>
|
||||
{{- slice $id | $scratch.Add "echartsArr" -}}
|
||||
@@ -1,6 +1,5 @@
|
||||
{{- $scratch := .Page.Scratch.Get "scratch" -}}
|
||||
|
||||
{{- /* shuffle md5 as id */ -}}
|
||||
{{- $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "mermaid-%s" -}}
|
||||
{{- $id := partial "function/id.html" (dict "content" (trim .Inner "\n") "scratch" $scratch) -}}
|
||||
<div class="mermaid" id="{{ $id }}"></div>
|
||||
{{- $scratch.SetInMap "mermaidMap" $id (trim .Inner "\n") -}}
|
||||
{{- slice $id | $scratch.Add "mermaidArr" -}}
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
{{- $scratch := .Page.Scratch.Get "scratch" -}}
|
||||
|
||||
{{- /* only the trailing newline is retained */ -}}
|
||||
{{- $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner | .Page.RenderString -}}
|
||||
{{- /* shuffle md5 as id */ -}}
|
||||
{{- $id := delimit (split (md5 $content) "" | shuffle) "" | printf "typeit-%s" -}}
|
||||
{{- $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner | .Page.RenderString | chomp -}}
|
||||
{{- $id := partial "function/id.html" (dict "content" $content "scratch" $scratch) -}}
|
||||
|
||||
<div class={{ .Get "class" | default "typeit" }}>
|
||||
{{- /* raw html content */ -}}
|
||||
{{- if .Get "raw" -}}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>
|
||||
{{- $content | safeHTML -}}
|
||||
</div>
|
||||
<div id={{ $id }}></div>
|
||||
{{- else if .Get "code" -}}
|
||||
{{- /* highlight code content without line number */ -}}
|
||||
@@ -23,16 +19,9 @@
|
||||
{{- $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>
|
||||
<div class="highlight" id={{ $id }}></div>
|
||||
{{- else -}}
|
||||
{{- $tag := .Get "tag" | default "p" -}}
|
||||
{{- $content = $content | chomp -}}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>
|
||||
{{- $content | safeHTML -}}
|
||||
</div>
|
||||
{{- printf "<%s id=%s></%s>" $tag $id $tag | safeHTML -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user