diff --git a/.circleci/config.yml b/.circleci/config.yml index d7bd8a8a..c34ef83b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: theme-path: type: string docker: - - image: cibuilds/hugo:0.64 + - image: cibuilds/hugo:0.62 working_directory: ~/LoveIt steps: - checkout @@ -15,10 +15,9 @@ jobs: - run: git submodule update --init - run: command: | - cd << parameters.example-site-path >> - pwd - HUGO_ENV=production hugo --themesDir << parameters.theme-path >> -v --minify --gc - htmlproofer public --allow-hash-href --empty-alt-ignore --disable-external + cd << parameters.example-site-path >> && pwd + HUGO_ENV=production hugo --themesDir << parameters.theme-path >> -v --gc + htmlproofer public --check-html --allow-hash-href --empty-alt-ignore --disable-external workflows: build-check-exampleSite: jobs: diff --git a/exampleSite/content/posts/markdown-syntax.md b/exampleSite/content/posts/markdown-syntax.md index 87549411..21cd2ccc 100644 --- a/exampleSite/content/posts/markdown-syntax.md +++ b/exampleSite/content/posts/markdown-syntax.md @@ -62,7 +62,7 @@ in-line changes such as annotations and abbreviations. ### Blockquote with attribution -> Don't communicate by sharing memory, share memory by communicating.

+> Don't communicate by sharing memory, share memory by communicating. > — Rob Pike[^1] [^1]: The above quote is excerpted from Rob Pike's [talk](https://www.youtube.com/watch?v=PAAkCSZUG1c) during Gopherfest, November 18, 2015. diff --git a/exampleSite/zh/content/posts/Basic-Markdown-Preview.md b/exampleSite/zh/content/posts/Basic-Markdown-Preview.md index 1fd90d26..95338752 100644 --- a/exampleSite/zh/content/posts/Basic-Markdown-Preview.md +++ b/exampleSite/zh/content/posts/Basic-Markdown-Preview.md @@ -42,7 +42,7 @@ Markdown 开始被应用于网络以外的领域,包括作者书籍、文章 我们可以把一个文档看成一系列的块,如段落、引用、列表、标题和代码块。 -有些块(如引号和列表)可以包含其它的块,即 **容器块**; +有些块(如引号和列表)可以包含其它的块,即 **容器块**; 其他的块(如标题和段落)则包含内联元素(如文本、链接、强调、图像、内联代码等),即 **叶子块**。 块的符号总是优先于内联元素的符号。例如: diff --git a/exampleSite/zh/content/posts/test.md b/exampleSite/zh/content/posts/test.md index 9e4d5cd9..f6abb40b 100644 --- a/exampleSite/zh/content/posts/test.md +++ b/exampleSite/zh/content/posts/test.md @@ -381,7 +381,6 @@ Here is a story about love... {{< /typeit >}} {{< typeit group="test" code="java" >}} -u.accepted(); // [2018/01/05](/since/) special int a = 1; {{< /typeit >}} diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index c439610d..b448d208 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -2,7 +2,7 @@ {{- partial "function/image.html" (dict "src" .Destination "alt" .Text "title" .Title ) -}} {{- with .Title | default .Text -}}
- {{- . -}} + {{- . | safeHTML -}}
{{- end -}} diff --git a/layouts/index.atom.xml b/layouts/index.atom.xml index d81c15da..6e29f962 100644 --- a/layouts/index.atom.xml +++ b/layouts/index.atom.xml @@ -4,7 +4,7 @@ {{- if not .Date.IsZero -}} - {{- .Date.Format "02-01-2006T15:04:05-07:00" | safeHTML -}} + {{- .Date.Format "02-01-2006T15:04:05-07:00" -}} {{- end -}} @@ -21,9 +21,7 @@ Hugo -- gohugo.io {{- range first 15 (where .Data.Pages "Type" "in" .Site.Params.mainSections) -}} - - {{- printf "<![CDATA[%s]]>" .Title | safeHTML -}} - + <![CDATA[{{ .Title -}}]]> {{- .Permalink -}} @@ -36,14 +34,12 @@ {{- end -}} - {{- .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML -}} + {{- .Date.Format "2006-01-02T15:04:05-07:00" -}} - {{- .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML -}} + {{- .Lastmod.Format "2006-01-02T15:04:05-07:00" -}} - - {{- printf "" .Content | safeHTML -}} - + {{- end -}} diff --git a/layouts/partials/head/seo.html b/layouts/partials/head/seo.html index 0ca51e35..f08182a1 100644 --- a/layouts/partials/head/seo.html +++ b/layouts/partials/head/seo.html @@ -76,12 +76,12 @@ "wordcount": {{ .WordCount }}, "url": "{{ .Permalink }}", {{- if not .PublishDate.IsZero -}} - "datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }}", + "datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" }}", {{- else if not .Date.IsZero -}} - "datePublished": "{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}", + "datePublished": "{{ .Date.Format "2006-01-02T15:04:05-07:00" }}", {{- end -}} {{- with .Lastmod -}} - "dateModified": "{{ .Format "2006-01-02T15:04:05-07:00" | safeHTML }}", + "dateModified": "{{ .Format "2006-01-02T15:04:05-07:00" }}", {{- end -}} {{- with .Site.Copyright -}} "license": "{{ . }}", diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 35016668..ebcaefa7 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -37,7 +37,7 @@ {{- $currentPage := . -}} {{- range .Site.Menus.main -}} - {{- .Name | safeHTML -}} + {{- .Pre | safeHTML }}{{ .Name -}} {{- end -}} diff --git a/layouts/partials/home/profile.html b/layouts/partials/home/profile.html index a0e5aaad..4b5d839c 100644 --- a/layouts/partials/home/profile.html +++ b/layouts/partials/home/profile.html @@ -16,12 +16,16 @@ {{- if $.Site.Params.home.profile.typeit -}} {{- $id := md5 . | printf "tp-%s" -}}
{{- $.Scratch.SetInMap "typeitMap" $id (slice $id) -}} {{- else -}} - {{- . | safeHTML -}} + {{- /* FIXME: https://github.com/gohugoio/hugo/issues/6882 */ -}} + {{- /* . | $.RenderString | safeHTML */ -}} + {{- . | markdownify | safeHTML -}} {{- end -}} {{- end -}} diff --git a/layouts/posts/single.html b/layouts/posts/single.html index ca81effe..f81748a6 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -47,14 +47,14 @@ {{- /* TOC */ -}} {{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}} -
+
-
+ +
+ {{- end -}} {{- /* Content */ -}} diff --git a/layouts/rss.xml b/layouts/rss.xml index c808f62e..b2aa7642 100644 --- a/layouts/rss.xml +++ b/layouts/rss.xml @@ -30,7 +30,7 @@ {{- end -}} {{- if not .Date.IsZero -}} - {{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML -}} + {{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}} {{- end -}} @@ -43,7 +43,7 @@ {{- .Permalink -}} - {{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML -}} + {{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}} {{- with .Site.Author.email -}} diff --git a/layouts/shortcodes/admonition.html b/layouts/shortcodes/admonition.html index c3803b30..613a7c9b 100644 --- a/layouts/shortcodes/admonition.html +++ b/layouts/shortcodes/admonition.html @@ -1,4 +1,5 @@ -{{- $_hugo_config := `{ "version": 1 }` -}} +{{- $inner := .Inner | .Page.RenderString -}} + {{- $iconMap := dict "note" "fas fa-pencil-alt" -}} {{- $iconMap = dict "abstract" "fas fa-list-ul" | merge $iconMap -}} {{- $iconMap = dict "info" "fas fa-info-circle" | merge $iconMap -}} @@ -22,14 +23,14 @@ {{ . }} {{- end -}} - {{- .Inner -}} + {{- $inner -}} {{- else -}}
{{- with .Get "title" -}}

{{ . }}

{{- end -}} - {{- .Inner -}} + {{- $inner -}}
{{- end -}} {{- else -}} @@ -41,14 +42,14 @@ {{ . }} {{- end -}} - {{- .Inner -}} + {{- $inner -}} {{- else -}}
{{- with .Get 1 -}}

{{ . }}

{{- end -}} - {{- .Inner -}} + {{- $inner -}}
{{- end -}} {{- end -}} diff --git a/layouts/shortcodes/align.html b/layouts/shortcodes/align.html index 9ddb5998..8ef2b2c3 100644 --- a/layouts/shortcodes/align.html +++ b/layouts/shortcodes/align.html @@ -1,5 +1,4 @@ -{{ $_hugo_config := `{ "version": 1 }` -}} - +{{- /* [left, center, right] */ -}}
- {{- .Inner -}} + {{- .Inner | .Page.RenderString -}}
diff --git a/layouts/shortcodes/float.html b/layouts/shortcodes/float.html index da4ad058..0845ba62 100644 --- a/layouts/shortcodes/float.html +++ b/layouts/shortcodes/float.html @@ -1,5 +1,4 @@ -{{ $_hugo_config := `{ "version": 1 }` -}} - +{{- /* [left, right] */ -}}
- {{- .Inner -}} + {{- .Inner | .Page.RenderString -}}
diff --git a/layouts/shortcodes/mermaid.html b/layouts/shortcodes/mermaid.html index 13ea7a3f..f513850b 100644 --- a/layouts/shortcodes/mermaid.html +++ b/layouts/shortcodes/mermaid.html @@ -1,4 +1,4 @@ - +{{- /* shuffle md5 as id */ -}} {{- $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "mermaid-%s" -}}
{{- .Page.Scratch.SetInMap "mermaidMap" $id (trim .Inner "\n") -}} diff --git a/layouts/shortcodes/typeit.html b/layouts/shortcodes/typeit.html index 9e55c44d..95c2ac11 100644 --- a/layouts/shortcodes/typeit.html +++ b/layouts/shortcodes/typeit.html @@ -1,25 +1,25 @@ - -{{- $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner -}} - +{{- /* only the trailing newline is retained */ -}} +{{- $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner | .Page.RenderString -}} +{{- /* shuffle md5 as id */ -}} {{- $id := delimit (split (md5 $content) "" | shuffle) "" | printf "typeit-%s" -}}
- + {{- /* raw html content */ -}} {{- if .Get "raw" -}}
{{- else if .Get "code" -}} - + {{- /* highlight code content without line number */ -}} {{- $content = highlight $content (.Get "code") "linenos=false" -}} - + {{- /* delete outer label */ -}} {{- $content = replaceRE `
]*>(?s)(.*)
` "$1" $content -}} - + {{- /* parsing markdown links */ -}} {{- $content = replaceRE `(]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)()` "$1$2$6
$3$1$5$6" $content -}} - + {{- /* replace " " to " " and replace "\n" to "
" */ -}} {{- $content = replaceRE ` ` " " $content | replaceRE `(<\w+) ` "$1 " | replaceRE `\n` "
" -}} - + {{- /* fix "
" location error which is a bug of Typeit HTML parser */ -}} {{- $content = replaceRE `
` "
" $content -}}