Skip to content

Commit

Permalink
feat: add support for maths passthrough render hook
Browse files Browse the repository at this point in the history
  • Loading branch information
HEIGE-PCloud committed Sep 23, 2024
1 parent 1b90bd5 commit 8473345
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion exampleSite/config/_default/markup.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# 是否在文档中直接使用 HTML 标签
unsafe = true
[goldmark.extensions.passthrough]
enable = true
enable = false
[goldmark.extensions.passthrough.delimiters]
block = [['\[', '\]'], ['$$', '$$']]
inline = [['\(', '\)']]
Expand Down
8 changes: 8 additions & 0 deletions layouts/_default/_markup/render-passthrough.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- .Page.Scratch.SetInMap "this" "math" true -}}
{{- if eq .Type "block" -}}
{{- $opts := dict "displayMode" true "output" "html" -}}
{{- transform.ToMath .Inner $opts -}}
{{- else -}}
{{- $opts := dict "displayMode" false "output" "html" -}}
{{- transform.ToMath .Inner $opts -}}
{{- end -}}
4 changes: 4 additions & 0 deletions layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
{{- end -}}

{{- /* KaTeX */ -}}
{{- if (.Scratch.Get "this").math -}}
{{- $source := $cdn.katexCSS | default "lib/katex/katex.min.css" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}}
{{- end -}}
{{- $math := $params.math -}}
{{- if eq $math true -}}
{{- $math = .Site.Params.page.math | default dict -}}
Expand Down
14 changes: 1 addition & 13 deletions layouts/partials/init.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
{{- .Scratch.Set "version" "0.4.0" -}}

{{- /* DoIt theme version detection */ -}}
{{/* {{- $VERSION := "0.3.X" -}}
{{- if eq .Site .Sites.First -}}
{{- if not .Site.Params.version -}}
{{- errorf "Configuration Error 配置文件错误\n\nYou haven't configured the DoIt version param correctly yet. See https://hugodoit.pages.dev/theme-documentation-basics/#basic-configuration\n你还没有正确配置 DoIt 的版本参数. 参考 https://hugodoit.pages.dev/zh-cn/theme-documentation-basics/#basic-configuration\n\n" -}}
{{- else if ne .Site.Params.version $VERSION -}}
{{- errorf (printf "Compatibility Error 兼容性错误\n\n%v -> %v:\nYou have an incompatible update. See https://github.com/HEIGE-PCloud/DoIt/releases\n你进行了一次不兼容的更新. 参考 https://github.com/HEIGE-PCloud/DoIt/releases\n\n" .Site.Params.version $VERSION) -}}
{{- end -}}
{{- end -}} */}}
{{/* temporarily disabling the version check, 0.3.X does not really contain a breaking change */}}
{{/* TODO: properly restore DoIt using semiVer */}}

{{- /* Check Hugo version */ -}}
{{- $OLDEST_SUPPORTED_HUGO_VERSION := "0.134.0" -}}
{{- if lt hugo.Version $OLDEST_SUPPORTED_HUGO_VERSION -}}
Expand Down Expand Up @@ -49,7 +37,7 @@
{{- else if eq .Params.comment false -}}
{{- .Scratch.Set "comment" dict -}}
{{- end -}}
{{- else if eq .Site .Sites.First -}}
{{- else if eq .Site .Sites.Default -}}
{{- warnf "\n\nCurrent environment is \"development\". The \"comment system\", \"PWA\", \"CDN\" and \"fingerprint\" will be disabled.\n当前运行环境是 \"development\". \"评论系统\", \"PWA\", \"CDN\" 和 \"fingerprint\" 不会启用.\n\n" -}}
{{- end -}}

Expand Down

0 comments on commit 8473345

Please sign in to comment.