{{- /* 边注的渲染核心:短代码 {{< note >}} 与标题边注(front matter 的 titleNote)共用。 参数: page —— 页面(.Page / .),用于 Store 编号与 RenderString class —— "cite" 表示书目边注,一行一项;留空则按普通注释渲染 title —— 为 true 时挂在 h1 上,固定编 1 号,不占正文计数 inner —— 内容,Markdown 或裸 HTML 约束:inner 按 inline 渲染,一旦分成两段,goldmark 会产出
,
塞进 里属于非法嵌套,浏览器会提前闭合 span,
卡片宽度与高度归零、notes.js 的定位与折线随之失效。
所以内容必须写成一整段;需要分行时用
或 。
*/ -}}
{{- $page := .page -}}
{{- $class := .class | default "" -}}
{{- $inner := .inner -}}
{{- $isTitle := .title | default false -}}
{{- $n := 1 -}}
{{- if not $isTitle -}}
{{- $count := add ($page.Store.Get "noteCount" | default 0) 1 -}}
{{- $page.Store.Set "noteCount" $count -}}
{{- $n = add $count (cond (ne ($page.Params.titleNote | default "") "") 1 0) -}}
{{- end -}}
{{ $n }}{{ $n }}{{- with $inner -}}
{{- if eq $class "cite" -}}
{{- range split (trim . "\r\n") "\n" -}}
{{- $line := trim . "\r" -}}
{{- if ne (trim $line " ") "" -}}{{ $line | $page.RenderString (dict "display" "inline") }}{{- end -}}
{{- end -}}
{{- else -}}
{{- . | $page.RenderString (dict "display" "inline") -}}
{{- end -}}
{{- end -}}