From dc0c4ef51e1f135be9bd1534805a2e075f0697c2 Mon Sep 17 00:00:00 2001 From: reuixiy Date: Wed, 11 Mar 2020 22:50:57 +0800 Subject: [PATCH] fix: remove crappy param `compatibleWithLaTeX` Fixed #50 BREAKING CHANGE: `compatibleWithLaTeX` is removed If you have enabled this param before, you can replace this feature with HTML `
` or `` tag, e.g.
$$ ... $$
inline math $...$ ...which prevents LaTeX code from being processed by the Markdown renderer. Sorry for the inconvenience *again* :( --- config-examples/en/config.toml | 3 -- config-examples/zh-cn/config.toml | 3 -- layouts/partials/utils/content.html | 2 +- layouts/partials/utils/markdownify.html | 41 ++++++------------------- 4 files changed, 11 insertions(+), 38 deletions(-) diff --git a/config-examples/en/config.toml b/config-examples/en/config.toml index 4676c747..48f54ea3 100644 --- a/config-examples/en/config.toml +++ b/config-examples/en/config.toml @@ -780,9 +780,6 @@ uglyURLs = false # Open external links in a new tab? hrefTargetBlank = true - # Compatibility with LaTeX? - compatibleWithLaTeX = false - ###################################### # Table of Contents diff --git a/config-examples/zh-cn/config.toml b/config-examples/zh-cn/config.toml index 6001835a..6d1a9744 100644 --- a/config-examples/zh-cn/config.toml +++ b/config-examples/zh-cn/config.toml @@ -738,9 +738,6 @@ uglyURLs = false # 在新标签页打开外链? hrefTargetBlank = true - # 与 LaTeX 的兼容性? - compatibleWithLaTeX = false - ###################################### # 文章目录 diff --git a/layouts/partials/utils/content.html b/layouts/partials/utils/content.html index 29616ea7..8ff8c8d6 100644 --- a/layouts/partials/utils/content.html +++ b/layouts/partials/utils/content.html @@ -1,5 +1,5 @@ {{- $Deliver := . -}} -{{- $raw := .RawContent -}} +{{- $raw := .Content -}} {{- partial "utils/markdownify.html" (dict "Deliver" . "raw" $raw "isContent" true) -}} diff --git a/layouts/partials/utils/markdownify.html b/layouts/partials/utils/markdownify.html index c6a364a7..7c660e88 100644 --- a/layouts/partials/utils/markdownify.html +++ b/layouts/partials/utils/markdownify.html @@ -6,29 +6,6 @@ {{- $enableEmoji := replaceRE `enableEmoji = (.+)` `$1` (delimit (readFile "config.toml" | findRE `enableEmoji = (.+)` | uniq) " ") -}} - -{{- $Content := $Deliver.Scratch.Get "Content" -}} -{{- if eq $enableEmoji "true" -}} - {{- $Content := $Content | emojify -}} - {{- $Deliver.Scratch.Set "Content" $Content -}} -{{- end -}} - - -{{- $Content := $Deliver.Scratch.Get "Content" -}} -{{- if $Deliver.Site.Params.compatibleWithLaTeX -}} - {{- if or ($Deliver.Params.katex | default $Deliver.Site.Params.enableKaTeX) ($Deliver.Params.mathjax | default $Deliver.Site.Params.enableMathJax) -}} - {{- $regexLaTeX := `([^\$]|\n)\$([^\$\n]+)\$` -}} - {{- $replacementLaTeX := `$1$$${2}$$` -}} - {{- $Content := $Content | replaceRE $regexLaTeX $replacementLaTeX -}} - - {{- $regexLaTeX := `\$\$((.|\s)[^\$]+)\$\$` -}} - {{- $replacementLaTeX := `
$$$$${1}$$$$
` -}} - {{- $Content := $Content | replaceRE $regexLaTeX $replacementLaTeX -}} - - {{- $Deliver.Scratch.Set "Content" $Content -}} - {{- end -}} -{{- end -}} - {{- $Content := $Deliver.Scratch.Get "Content" -}} {{- if $Deliver.Site.Params.enableEmphasisPoint -}} @@ -38,16 +15,18 @@ {{- $Deliver.Scratch.Set "Content" $Content -}} {{- end -}} - -{{- $Content := $Deliver.Scratch.Get "Content" -}} -{{- $Content := $Content | markdownify -}} -{{- $Deliver.Scratch.Set "Content" $Content -}} - - + {{- $Content := $Deliver.Scratch.Get "Content" -}} -{{- if and (not (strings.HasPrefix $Content "<")) $isContent -}} - {{- $Content := (printf `

%s

` $Content) | safeHTML -}} +{{- if not $isContent -}} + {{- $Content := $Content | markdownify -}} {{- $Deliver.Scratch.Set "Content" $Content -}} + + + {{- $Content := $Deliver.Scratch.Get "Content" -}} + {{- if eq $enableEmoji "true" -}} + {{- $Content := $Content | emojify -}} + {{- $Deliver.Scratch.Set "Content" $Content -}} + {{- end -}} {{- end -}}