Skip to content

Commit

Permalink
fix: remove crappy param compatibleWithLaTeX
Browse files Browse the repository at this point in the history
Fixed #50

BREAKING CHANGE: `compatibleWithLaTeX` is removed

If you have enabled this param before, you can replace this feature with HTML `<div>` or `<span>` tag, e.g.

<div>
$$
...
$$
</div>

inline math <span>$...$</span>

...which prevents LaTeX code from being processed by the Markdown renderer.

Sorry for the inconvenience *again* :(
  • Loading branch information
reuixiy committed Mar 11, 2020
1 parent 431ef63 commit dc0c4ef
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 38 deletions.
3 changes: 0 additions & 3 deletions config-examples/en/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -780,9 +780,6 @@ uglyURLs = false
# Open external links in a new tab?
hrefTargetBlank = true

# Compatibility with LaTeX?
compatibleWithLaTeX = false


######################################
# Table of Contents
Expand Down
3 changes: 0 additions & 3 deletions config-examples/zh-cn/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,6 @@ uglyURLs = false
# 在新标签页打开外链?
hrefTargetBlank = true

# 与 LaTeX 的兼容性?
compatibleWithLaTeX = false


######################################
# 文章目录
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/utils/content.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $Deliver := . -}}
{{- $raw := .RawContent -}}
{{- $raw := .Content -}}
{{- partial "utils/markdownify.html" (dict "Deliver" . "raw" $raw "isContent" true) -}}

<!-- Link Headings to TOC -->
Expand Down
41 changes: 10 additions & 31 deletions layouts/partials/utils/markdownify.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,6 @@

{{- $enableEmoji := replaceRE `enableEmoji = (.+)` `$1` (delimit (readFile "config.toml" | findRE `enableEmoji = (.+)` | uniq) " ") -}}

<!-- Emoji -->
{{- $Content := $Deliver.Scratch.Get "Content" -}}
{{- if eq $enableEmoji "true" -}}
{{- $Content := $Content | emojify -}}
{{- $Deliver.Scratch.Set "Content" $Content -}}
{{- end -}}

<!-- LaTeX -->
{{- $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<span>$$${2}$$</span>` -}}
{{- $Content := $Content | replaceRE $regexLaTeX $replacementLaTeX -}}

{{- $regexLaTeX := `\$\$((.|\s)[^\$]+)\$\$` -}}
{{- $replacementLaTeX := `<div>$$$$${1}$$$$</div>` -}}
{{- $Content := $Content | replaceRE $regexLaTeX $replacementLaTeX -}}

{{- $Deliver.Scratch.Set "Content" $Content -}}
{{- end -}}
{{- end -}}

<!-- New Markdown Syntax: Emphasis Point `..text..` -->
{{- $Content := $Deliver.Scratch.Get "Content" -}}
{{- if $Deliver.Site.Params.enableEmphasisPoint -}}
Expand All @@ -38,16 +15,18 @@
{{- $Deliver.Scratch.Set "Content" $Content -}}
{{- end -}}

<!-- Markdown -->
{{- $Content := $Deliver.Scratch.Get "Content" -}}
{{- $Content := $Content | markdownify -}}
{{- $Deliver.Scratch.Set "Content" $Content -}}

<!-- https://github.com/reuixiy/hugo-theme-meme/issues/49 -->
<!-- Markdownify -->
{{- $Content := $Deliver.Scratch.Get "Content" -}}
{{- if and (not (strings.HasPrefix $Content "<")) $isContent -}}
{{- $Content := (printf `<p>%s</p>` $Content) | safeHTML -}}
{{- if not $isContent -}}
{{- $Content := $Content | markdownify -}}
{{- $Deliver.Scratch.Set "Content" $Content -}}

<!-- Emojify -->
{{- $Content := $Deliver.Scratch.Get "Content" -}}
{{- if eq $enableEmoji "true" -}}
{{- $Content := $Content | emojify -}}
{{- $Deliver.Scratch.Set "Content" $Content -}}
{{- end -}}
{{- end -}}

<!-- External Links -->
Expand Down

0 comments on commit dc0c4ef

Please sign in to comment.