mirror of
https://github.com/dillonzq/LoveIt.git
synced 2024-11-21 22:36:16 +01:00
fix(check): fix some html check bugs
This commit is contained in:
parent
d8681cd489
commit
4b3addf634
20 changed files with 53 additions and 67 deletions
|
@ -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:
|
||||
|
|
|
@ -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.</p>
|
||||
> Don't communicate by sharing memory, share memory by communicating.
|
||||
> — <cite>Rob Pike[^1]</cite>
|
||||
|
||||
[^1]: The above quote is excerpted from Rob Pike's [talk](https://www.youtube.com/watch?v=PAAkCSZUG1c) during Gopherfest, November 18, 2015.
|
||||
|
|
|
@ -42,7 +42,7 @@ Markdown 开始被应用于网络以外的领域,包括作者书籍、文章
|
|||
|
||||
我们可以把一个文档看成一系列的块,如段落、引用、列表、标题和代码块。
|
||||
|
||||
有些块(如引号和列表)可以包含其它的块,即 **容器块**;
|
||||
有些块(如引号和列表)可以包含其它的块,即 **容器块**;
|
||||
其他的块(如标题和段落)则包含内联元素(如文本、链接、强调、图像、内联代码等),即 **叶子块**。
|
||||
|
||||
块的符号总是优先于内联元素的符号。例如:
|
||||
|
|
|
@ -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 >}}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{{- partial "function/image.html" (dict "src" .Destination "alt" .Text "title" .Title ) -}}
|
||||
{{- with .Title | default .Text -}}
|
||||
<figcaption class="image-caption">
|
||||
{{- . -}}
|
||||
{{- . | safeHTML -}}
|
||||
</figcaption>
|
||||
{{- end -}}
|
||||
</figure>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<link href="{{ .Permalink }}"/>
|
||||
{{- if not .Date.IsZero -}}
|
||||
<updated>
|
||||
{{- .Date.Format "02-01-2006T15:04:05-07:00" | safeHTML -}}
|
||||
{{- .Date.Format "02-01-2006T15:04:05-07:00" -}}
|
||||
</updated>
|
||||
{{- end -}}
|
||||
<id>
|
||||
|
@ -21,9 +21,7 @@
|
|||
<generator>Hugo -- gohugo.io</generator>
|
||||
{{- range first 15 (where .Data.Pages "Type" "in" .Site.Params.mainSections) -}}
|
||||
<entry>
|
||||
<title type="html">
|
||||
{{- printf "<![CDATA[%s]]>" .Title | safeHTML -}}
|
||||
</title>
|
||||
<title type="html"><![CDATA[{{ .Title -}}]]></title>
|
||||
<link href="{{ .Permalink }}"/>
|
||||
<id>
|
||||
{{- .Permalink -}}
|
||||
|
@ -36,14 +34,12 @@
|
|||
</author>
|
||||
{{- end -}}
|
||||
<published>
|
||||
{{- .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML -}}
|
||||
{{- .Date.Format "2006-01-02T15:04:05-07:00" -}}
|
||||
</published>
|
||||
<updated>
|
||||
{{- .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML -}}
|
||||
{{- .Lastmod.Format "2006-01-02T15:04:05-07:00" -}}
|
||||
</updated>
|
||||
<content type="html">
|
||||
{{- printf "<![CDATA[%s]]>" .Content | safeHTML -}}
|
||||
</content>
|
||||
<content type="html"><![CDATA[{{- .Content -}}]]></content>
|
||||
</entry>
|
||||
{{- end -}}
|
||||
</feed>
|
||||
|
|
|
@ -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": "{{ . }}",
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
{{- $currentPage := . -}}
|
||||
{{- range .Site.Menus.main -}}
|
||||
<a class="menu-item" href="{{ .URL | absLangURL }}" title="{{ .Title }}">
|
||||
{{- .Name | safeHTML -}}
|
||||
{{- .Pre | safeHTML }}{{ .Name -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
<a href="javascript:void(0);" class="theme-switch" title="{{ T "switchTheme" }}">
|
||||
|
|
|
@ -16,12 +16,16 @@
|
|||
{{- if $.Site.Params.home.profile.typeit -}}
|
||||
{{- $id := md5 . | printf "tp-%s" -}}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>
|
||||
{{- . | safeHTML -}}
|
||||
{{- /* FIXME: https://github.com/gohugoio/hugo/issues/6882 */ -}}
|
||||
{{- /* . | $.RenderString | safeHTML */ -}}
|
||||
{{- . | markdownify | safeHTML -}}
|
||||
</div>
|
||||
<div id={{ $id }} class="typeit"></div>
|
||||
{{- $.Scratch.SetInMap "typeitMap" $id (slice $id) -}}
|
||||
{{- else -}}
|
||||
{{- . | safeHTML -}}
|
||||
{{- /* FIXME: https://github.com/gohugoio/hugo/issues/6882 */ -}}
|
||||
{{- /* . | $.RenderString | safeHTML */ -}}
|
||||
{{- . | markdownify | safeHTML -}}
|
||||
{{- end -}}
|
||||
</h2>
|
||||
{{- end -}}
|
||||
|
|
|
@ -47,14 +47,14 @@
|
|||
|
||||
{{- /* TOC */ -}}
|
||||
{{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
|
||||
<div class="post-toc" id="post-toc">
|
||||
<aside class="post-toc" id="post-toc">
|
||||
<h2 class="post-toc-title">{{ T "toc" }}</h2>
|
||||
{{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }}
|
||||
<div class="post-toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}">
|
||||
{{- .TableOfContents -}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="post-toc-mobile" id="post-toc-mobile">
|
||||
</aside>
|
||||
<aside class="post-toc-mobile" id="post-toc-mobile">
|
||||
<details>
|
||||
<summary>
|
||||
<div class="post-toc-title">
|
||||
|
@ -68,7 +68,7 @@
|
|||
{{- $toc | safeHTML -}}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</aside>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Content */ -}}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
{{- end -}}
|
||||
{{- if not .Date.IsZero -}}
|
||||
<lastBuildDate>
|
||||
{{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML -}}
|
||||
{{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}}
|
||||
</lastBuildDate>
|
||||
{{- end -}}
|
||||
<atom:link href="{{.Permalink}}" rel="self" type="application/rss+xml" />
|
||||
|
@ -43,7 +43,7 @@
|
|||
{{- .Permalink -}}
|
||||
</link>
|
||||
<pubDate>
|
||||
{{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML -}}
|
||||
{{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}}
|
||||
</pubDate>
|
||||
{{- with .Site.Author.email -}}
|
||||
<author>
|
||||
|
|
|
@ -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 @@
|
|||
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}<i class="details {{ $iconDetails }}"></i>
|
||||
</summary>
|
||||
{{- end -}}
|
||||
{{- .Inner -}}
|
||||
{{- $inner -}}
|
||||
</details>
|
||||
{{- else -}}
|
||||
<div class="admonition {{ $type }}">
|
||||
{{- with .Get "title" -}}
|
||||
<p class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}</p>
|
||||
{{- end -}}
|
||||
{{- .Inner -}}
|
||||
{{- $inner -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
|
@ -41,14 +42,14 @@
|
|||
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}<i class="details {{ $iconDetails }}"></i>
|
||||
</summary>
|
||||
{{- end -}}
|
||||
{{- .Inner -}}
|
||||
{{- $inner -}}
|
||||
</details>
|
||||
{{- else -}}
|
||||
<div class="admonition {{ $type }}">
|
||||
{{- with .Get 1 -}}
|
||||
<p class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}</p>
|
||||
{{- end -}}
|
||||
{{- .Inner -}}
|
||||
{{- $inner -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{{ $_hugo_config := `{ "version": 1 }` -}}
|
||||
<!-- [left, center, right] -->
|
||||
{{- /* [left, center, right] */ -}}
|
||||
<div class={{ .Get 0 | printf "align-%s" }}>
|
||||
{{- .Inner -}}
|
||||
{{- .Inner | .Page.RenderString -}}
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{{ $_hugo_config := `{ "version": 1 }` -}}
|
||||
<!-- [left, right] -->
|
||||
{{- /* [left, right] */ -}}
|
||||
<div class={{ .Get 0 | printf "float-%s" }}>
|
||||
{{- .Inner -}}
|
||||
{{- .Inner | .Page.RenderString -}}
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!-- shuffle md5 as id -->
|
||||
{{- /* shuffle md5 as id */ -}}
|
||||
{{- $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "mermaid-%s" -}}
|
||||
<div class="mermaid" id="{{ $id }}"></div>
|
||||
{{- .Page.Scratch.SetInMap "mermaidMap" $id (trim .Inner "\n") -}}
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
<!-- only the trailing newline is retained -->
|
||||
{{- $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner -}}
|
||||
<!-- shuffle md5 as id -->
|
||||
{{- /* 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" -}}
|
||||
|
||||
<div class={{ .Get "class" | default "typeit" }}>
|
||||
<!-- raw html content -->
|
||||
{{- /* raw html content */ -}}
|
||||
{{- if .Get "raw" -}}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>
|
||||
{{- $content | safeHTML -}}
|
||||
</div>
|
||||
<div id={{ $id }}></div>
|
||||
{{- else if .Get "code" -}}
|
||||
<!-- highlight code content without line number -->
|
||||
{{- /* highlight code content without line number */ -}}
|
||||
{{- $content = highlight $content (.Get "code") "linenos=false" -}}
|
||||
<!-- delete outer label -->
|
||||
{{- /* delete outer label */ -}}
|
||||
{{- $content = replaceRE `<div class="highlight"><pre class="chroma"><code[^<>]*>(?s)(.*)</code></pre></div>` "$1" $content -}}
|
||||
<!-- parsing markdown links -->
|
||||
{{- /* parsing markdown links */ -}}
|
||||
{{- $content = replaceRE `(<span[^<>]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)(</span>)` "$1$2$6<a href=$4>$3</a>$1$5$6" $content -}}
|
||||
<!-- replace " " to " " and replace "\n" to "<br />" -->
|
||||
{{- /* replace " " to " " and replace "\n" to "<br />" */ -}}
|
||||
{{- $content = replaceRE ` ` " " $content | replaceRE `(<\w+) ` "$1 " | replaceRE `\n` "<br />" -}}
|
||||
<!-- fix "<br />" location error which is a bug of Typeit HTML parser -->
|
||||
{{- /* fix "<br />" location error which is a bug of Typeit HTML parser */ -}}
|
||||
{{- $content = replaceRE `<br /></span>` "</span><br />" $content -}}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>
|
||||
{{- $content | safeHTML -}}
|
||||
|
@ -27,7 +27,7 @@
|
|||
<div class="highlight" id={{ $id }}></div>
|
||||
{{- else -}}
|
||||
{{- $tag := .Get "tag" | default "p" -}}
|
||||
{{- $content = $content | markdownify | chomp -}}
|
||||
{{- $content = $content | chomp -}}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>
|
||||
{{- $content | safeHTML -}}
|
||||
</div>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</loc>
|
||||
{{- if not .Lastmod.IsZero -}}
|
||||
<lastmod>
|
||||
{{- safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) -}}
|
||||
{{- .Lastmod.Format "2006-01-02T15:04:05-07:00" -}}
|
||||
</lastmod>
|
||||
{{- end -}}
|
||||
{{- with .Sitemap.ChangeFreq -}}
|
||||
|
|
|
@ -84,16 +84,6 @@
|
|||
this.util.forEach(toc.querySelectorAll('a:first-child'), (link) => {
|
||||
link.classList.add('toc-link');
|
||||
});
|
||||
|
||||
// when headings do not start with `h1`
|
||||
const oldTocList = toc.children[0];
|
||||
let newTocList = oldTocList;
|
||||
let temp;
|
||||
while (newTocList.children.length === 1
|
||||
&& (temp = newTocList.children[0].children[0]).tagName === 'UL') {
|
||||
newTocList = temp;
|
||||
}
|
||||
if (newTocList !== oldTocList) toc.replaceChild(newTocList, oldTocList);
|
||||
}
|
||||
|
||||
_initTocState(tocContainer) {
|
||||
|
@ -157,7 +147,7 @@
|
|||
initToc() {
|
||||
const tocContainer = document.getElementById('post-toc');
|
||||
if (tocContainer !== null) {
|
||||
const toc = document.getElementById('TableOfContents');
|
||||
const toc = tocContainer.getElementById('TableOfContents');
|
||||
if (toc === null) {
|
||||
tocContainer.parentElement.removeChild(tocContainer);
|
||||
} else {
|
||||
|
|
3
static/js/theme.min.js
vendored
3
static/js/theme.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue