Skip to content

Commit

Permalink
Release v4.0.0
Browse files Browse the repository at this point in the history
closed #26, fixed #14
  • Loading branch information
reuixiy committed Jan 8, 2020
1 parent e6c251a commit 8c3cb2b
Show file tree
Hide file tree
Showing 22 changed files with 241 additions and 102 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# [4.0.0](https://github.com/reuixiy/hugo-theme-meme/compare/v3.4.5...v4.0.0) (2020-01-08)


As I described in [#26](https://github.com/reuixiy/hugo-theme-meme/issues/26), I want to make MemE support Hugo's new default Markdown rendering engine Goldmark, and this is it. In this version, MemE will support Goldmark and *no longer support* Blackfriday.

### Notes

1. Goldmark problems, see [#43 (comment)](https://github.com/reuixiy/hugo-theme-meme/issues/43#issuecomment-571074162)

2. Compatibility with LaTeX, see [gohugoio/hugo#6544](https://github.com/gohugoio/hugo/issues/6544)

[Previously](https://github.com/reuixiy/hugo-theme-meme/issues/12), I suggested adding some backslashes to escape some characters to solve the syntax conflict between Markdown and LaTeX. Now, I think that is not the *right* way -- it's troublesome and stupid.

In v4.0.0, MemE adds a new `compatibleWithLaTeX` option as a temporary workaround. But note that it has some limitations, such as it can't exclude equations inside code block, it supports `$ ... $` and `$$ ... $$` only.

And at last, apology for my wrong suggestion, which may take some of your time to modify the equations again.

3. With Hugo brand new Markdown renderer Goldmark, [#14](https://github.com/reuixiy/hugo-theme-meme/issues/14) should be fixed.

### ATTENTION

**MemE v4.0.0 requires Hugo v0.62.2 or higher.**



## [3.4.5](https://github.com/reuixiy/hugo-theme-meme/compare/v3.3.9...v3.4.5) (2020-01-08)


Expand Down
3 changes: 3 additions & 0 deletions assets/scss/_common/indent.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
ol {
margin: ($fontSize * 1.618) 0 0;
list-style-position: outside;
p {
display: block;
}
}
}
dl {
Expand Down
56 changes: 39 additions & 17 deletions config-examples/en-us/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ enableRobotsTXT = true
# layout in MemE)
paginate = 5

# GitHub flavoured code fences
pygmentsCodefences = true
pygmentsUseClasses = true
pygmentsCodefencesGuessSyntax = true
pygmentsOptions = "linenos=table"

# URL related
disablePathToLower = false
relativeURLs = false
Expand All @@ -66,18 +60,36 @@ uglyURLs = false
[frontmatter]
lastmod = ["lastmod", ":git", ":fileModTime", ":default"]

# v0.60.0
# Markdown renderer
[markup]
defaultMarkdownHandler = "blackfriday"

# Markdown rendering engine
[blackfriday]
# Enable smart punctuation substitutions?
smartypants = true
# Open external links in a new window or tab?
hrefTargetBlank = true
# Disable some Blackfriday’s Markdown extensions
extensionsmask = ["hardLineBreak", "backslashLineBreak"]
defaultMarkdownHandler = "goldmark"
[markup.goldmark]
[markup.goldmark.extensions]
definitionList = true
footnote = true
linkify = true
strikethrough = true
table = true
taskList = true
typographer = true
[markup.goldmark.parser]
attribute = true
autoHeadingID = true
autoHeadingIDType = "github"
[markup.goldmark.renderer]
hardWraps = false
unsafe = true
xHTML = false
[markup.highlight]
codeFences = true
guessSyntax = false
lineNos = true
lineNumbersInTable = true
noClasses = false
[markup.tableOfContents]
startLevel = 2
endLevel = 6
ordered = true

# Author’s information
[author]
Expand Down Expand Up @@ -733,6 +745,16 @@ uglyURLs = false
# https://busuanzi.ibruce.info/


######################################
# Markdown Related

# Open external links in a new tab?
hrefTargetBlank = true

# Compatibility with LaTeX?
compatibleWithLaTeX = false


######################################
# Table of Contents

Expand Down
56 changes: 39 additions & 17 deletions config-examples/zh-cn/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ enableRobotsTXT = true
# 每一分页的文章数(仅对「文章摘要」首页布局有效)
paginate = 5

# 代码高亮
pygmentsCodefences = true
pygmentsUseClasses = true
pygmentsCodefencesGuessSyntax = true
pygmentsOptions = "linenos=table"

# URL 相关
disablePathToLower = false
relativeURLs = false
Expand All @@ -64,18 +58,36 @@ uglyURLs = false
[frontmatter]
lastmod = ["lastmod", ":git", ":fileModTime", ":default"]

# v0.60.0
[markup]
defaultMarkdownHandler = "blackfriday"

# Markdown 渲染器
[blackfriday]
# 是否开启智能标点符号替换
smartypants = false
# 是否在新标签页打开外链
hrefTargetBlank = true
# 屏蔽的扩展
extensionsmask = ["hardLineBreak", "backslashLineBreak"]
[markup]
defaultMarkdownHandler = "goldmark"
[markup.goldmark]
[markup.goldmark.extensions]
definitionList = true
footnote = true
linkify = true
strikethrough = true
table = true
taskList = true
typographer = false
[markup.goldmark.parser]
attribute = true
autoHeadingID = true
autoHeadingIDType = "github"
[markup.goldmark.renderer]
hardWraps = false
unsafe = true
xHTML = false
[markup.highlight]
codeFences = true
guessSyntax = false
lineNos = true
lineNumbersInTable = true
noClasses = false
[markup.tableOfContents]
startLevel = 2
endLevel = 6
ordered = true

# 作者信息
[author]
Expand Down Expand Up @@ -693,6 +705,16 @@ uglyURLs = false
# https://busuanzi.ibruce.info/


######################################
# Markdown 相关

# 在新标签页打开外链?
hrefTargetBlank = true

# 与 LaTeX 的兼容性?
compatibleWithLaTeX = false


######################################
# 文章目录

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Target":"css/meme.min.4b148ff5a3ef5b23cc4b3535a90689d12e6a69919d40258fc65e3a9c4c5697a9.css","MediaType":"text/css","Data":{"Integrity":"sha256-SxSP9aPvWyPMSzU1qQaJ0S5qaZGdQCWPxl46nExWl6k="}}
{"Target":"css/meme.min.ede3a5876aeee960ad67eb4ca39c46022b533542ba2769cedf49996a1566ff1f.css","MediaType":"text/css","Data":{"Integrity":"sha256-7eOlh2ru6WCtZ+tMo5xGAitTNUK6J2nO30mZahVm/x8="}}
5 changes: 4 additions & 1 deletion layouts/index.sectionsatom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
{{- end }}
{{- partial "components/summary.html" $page -}}
{{- $summary := .Description | default ($page.Scratch.Get "summary" | plainify | replaceRE `\n……` ``) -}}
{{ printf `<summary type="html"><![CDATA[%s]]></summary>` ($summary | markdownify | htmlUnescape) | safeHTML }}
{{- $raw := $summary -}}
{{- partial "components/markdownify.html" (dict "Deliver" $page "raw" $raw) -}}
{{- $summary := $page.Scratch.Get "Content" -}}
{{ printf `<summary type="html"><![CDATA[%s]]></summary>` ($summary | htmlUnescape) | safeHTML }}
{{ if $.Site.Params.includeContent }}
{{ printf `<content type="html"><![CDATA[%s]]></content>` .Content | safeHTML }}
{{ end }}
Expand Down
5 changes: 4 additions & 1 deletion layouts/index.sectionsrss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@
{{ else }}
{{- partial "components/summary.html" $page -}}
{{- $summary := .Description | default ($page.Scratch.Get "summary" | plainify | replaceRE `\n……` ``) -}}
{{ printf `<description><![CDATA[%s]]></description>` ($summary | markdownify | htmlUnescape) | safeHTML }}
{{- $raw := $summary -}}
{{- partial "components/markdownify.html" (dict "Deliver" $page "raw" $raw) -}}
{{- $summary := $page.Scratch.Get "Content" -}}
{{ printf `<description><![CDATA[%s]]></description>` ($summary | htmlUnescape) | safeHTML }}
{{ end }}
<!-- Sections -->
{{ if eq $.Site.Params.categoryBy "sections" }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/components/auto-detect-images.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- https://gohugo.io/functions/replacere/ -->
<!-- https://regex101.com/ -->
{{- if and .IsPage (in .Site.Params.mainSections .Section) -}}
{{- $imgs := findRE `<img src="/?([^"]+)` .Content -}}
{{- $imgs := findRE `<img src="/?([^"]+)` .Content | uniq -}}
{{- with $imgs -}}
{{- $.Scratch.Delete "imgsURL" -}}
{{- range . -}}
Expand Down
43 changes: 14 additions & 29 deletions layouts/partials/components/content.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{- $Content := .Content -}}
{{- .Scratch.Set "Content" $Content -}}
{{- $Deliver := . -}}
{{- $raw := .RawContent -}}
{{- partial "components/markdownify.html" (dict "Deliver" . "raw" $raw) -}}

<!-- Link Headings to TOC -->
{{- $Content := .Scratch.Get "Content" -}}
Expand Down Expand Up @@ -67,34 +68,25 @@
{{- if ne .Type "poetry" -}}
{{- if and .Site.Params.enableDropCap (.Params.dropCapAfterHr | default .Site.Params.enableDropCapAfterHr) -}}
{{- if .Params.deleteHrBeforeDropCap | default .Site.Params.deleteHrBeforeDropCap -}}
{{- $replacement := `$2 style="text-indent:0"$3<span class="drop-cap">$4</span>$5` -}}
{{- $replacement := `$3 style="text-indent:0"$4<span class="drop-cap">$5</span>$6` -}}
{{- $.Scratch.Set "replacement" $replacement -}}
{{- else -}}
{{- $replacement := `$1$2 style="text-indent:0"$3<span class="drop-cap">$4</span>$5` -}}
{{- $replacement := `$1$3 style="text-indent:0"$4<span class="drop-cap">$5</span>$6` -}}
{{- $.Scratch.Set "replacement" $replacement -}}
{{- end -}}
{{- $replacement := .Scratch.Get "replacement" -}}

{{- $regexPatternDropCapAfterHr := `(\n<hr />\n)(\n<p)(>)([^<])(.+(</p>|\n))` -}}
{{- $regexPatternDropCapAfterHr := `(\n(<hr />|<hr>))(\n\n?<p)(>)([^<])(.+(</p>|\n))` -}}
{{- $regexReplacementDropCapAfterHr := $replacement -}}
{{- $Content := $Content | replaceRE $regexPatternDropCapAfterHr $regexReplacementDropCapAfterHr | safeHTML -}}
{{- .Scratch.Set "Content" $Content -}}
{{- end -}}
{{- end -}}

<!-- New Markdown Syntax: Emphasis Point `..text..` -->
{{- $Content := .Scratch.Get "Content" -}}
{{- if .Site.Params.enableEmphasisPoint -}}
{{- $regexPatternEmphasisPoint := `([^\.\x60])\.\.([^\.\s\n\/\\]+)\.\.([^\.\x60])` -}}
{{- $regexReplacementEmphasisPoint := `$1<strong class="emphasis-point">$2</strong>$3` -}}
{{- $Content := $Content | replaceRE $regexPatternEmphasisPoint $regexReplacementEmphasisPoint | safeHTML -}}
{{- .Scratch.Set "Content" $Content -}}
{{- end -}}

<!-- Footnote Ref with Square Brackets `[]` -->
{{- $Content := .Scratch.Get "Content" -}}
{{- if .Site.Params.squareBrackets -}}
{{- $regexPatternFootnoteRef := `(<sup class="footnote-ref" id="fnref:\d+"><a href="#fn:\d+">)(\d+)(</a></sup>)` -}}
{{- $regexPatternFootnoteRef := `(<sup id="fnref:\d+"><a href="#fn:\d+"[^>]+>)(\d+)(</a></sup>)` -}}
{{- $regexReplacementFootnoteRef := `$1[$2]$3` -}}
{{- $Content := $Content | replaceRE $regexPatternFootnoteRef $regexReplacementFootnoteRef | safeHTML -}}
{{- .Scratch.Set "Content" $Content -}}
Expand All @@ -110,8 +102,8 @@
<!-- Delete Footnote `<hr />` -->
{{- $Content := .Scratch.Get "Content" -}}
{{- if .Site.Params.insertHrBySelf -}}
{{- $regexPatternDeleteHr := `<hr />\n(<div class="footnotes">)` -}}
{{- $regexReplacementDeleteHr := `$1` -}}
{{- $regexPatternDeleteHr := `(<hr />|<hr>)\n(<section class="footnotes" role="doc-endnotes">)` -}}
{{- $regexReplacementDeleteHr := `$2` -}}
{{- $Content := $Content | replaceRE $regexPatternDeleteHr $regexReplacementDeleteHr | safeHTML -}}
{{- .Scratch.Set "Content" $Content -}}
{{- end -}}
Expand All @@ -120,9 +112,9 @@
{{- $Content := .Scratch.Get "Content" -}}
{{- with .Site.Params.footnoteReturnLinkIcon -}}
{{- $icon := (replace (index $.Site.Data.SVG .) "icon" "icon footnote-icon") -}}
{{- $replacement := (printf `${1}%v</$3` $icon) | safeHTML -}}
{{- $replacement := (printf `${1}%s$3` $icon) | safeHTML -}}

{{- $regexPatternfootnoteReturnLinkIcon := `(href="#fnref[^>]+>)([^a]+)(.+)` -}}
{{- $regexPatternfootnoteReturnLinkIcon := `(href="#fnref[^>]+>)([^<]+)(.+)` -}}
{{- $regexReplacementfootnoteReturnLinkIcon := $replacement -}}
{{- $Content := $Content | replaceRE $regexPatternfootnoteReturnLinkIcon $regexReplacementfootnoteReturnLinkIcon | safeHTML -}}
{{- $.Scratch.Set "Content" $Content -}}
Expand All @@ -149,7 +141,7 @@
{{- $Content := .Scratch.Get "Content" -}}
{{- if and .Site.Params.enableImageHost (eq hugo.Environment "production") -}}
{{- $hostURL := .Site.Params.imageHostURL -}}
{{- $temps := findRE `<(img) src="/?([^":]+)` $Content -}}
{{- $temps := findRE `<(img) src="/?([^":]+)` $Content | uniq -}}
{{- with $temps -}}
{{- range . -}}
{{- if not (in (slice "http" "ttps") (substr . -1 4)) -}}
Expand All @@ -167,7 +159,7 @@
{{- $Content := .Scratch.Get "Content" -}}
{{- if and .Site.Params.enableVideoHost (eq hugo.Environment "production") -}}
{{- $hostURL := .Site.Params.videoHostURL -}}
{{- $temps := findRE `<(video) src="/?([^":]+)` $Content -}}
{{- $temps := findRE `<(video) src="/?([^":]+)` $Content | uniq -}}
{{- with $temps -}}
{{- range . -}}
{{- if not (in (slice "http" "ttps") (substr . -1 4)) -}}
Expand All @@ -181,18 +173,11 @@
{{- end -}}
{{- end -}}

<!-- Task List -->
{{- $Content := .Scratch.Get "Content" -}}
{{- $regexPatternTaskList := `(<ol |<ul )(class="task-list">\n<li><label>)` -}}
{{- $regexReplacementTaskList := `${1}style="list-style:none" $2` -}}
{{- $Content := $Content | replaceRE $regexPatternTaskList $regexReplacementTaskList | safeHTML -}}
{{- .Scratch.Set "Content" $Content -}}

<!-- Paragraph Indent -->
{{- $Content := .Scratch.Get "Content" -}}
{{- if ne .Type "poetry" -}}
{{- if (and .Site.Params.enableParagraphIndent .Params.indent) | default (and .Site.Params.enableParagraphIndent (eq .Site.Params.paragraphStyle "indent")) -}}
{{- $regexPatternIndent := `(<p)(>)(.+<br />)` -}}
{{- $regexPatternIndent := `(</p>\n<p)(>)(.+(<br />|<br>))` -}}
{{- $regexReplacementIndent := `$1 style="text-indent:0;padding-left:2em;margin:1em 0"$2$3` -}}
{{- $Content := $Content | replaceRE $regexPatternIndent $regexReplacementIndent | safeHTML -}}
{{- .Scratch.Set "Content" $Content -}}
Expand Down
Loading

0 comments on commit 8c3cb2b

Please sign in to comment.