markdown: Pass emoji codes to yuin/goldmark-emoji

Removes emoji code conversion from the page and shortcode parsers. Emoji
codes in markdown are now passed to Goldmark, where the goldmark-emoji
extension converts them to decimal numeric character references.

This disables emoji rendering for the alternate content formats: html,
asciidoc, org, pandoc, and rst.

Fixes #7332
Fixes #11587
Closes #11598
This commit is contained in:
Joe Mooring
2023-10-24 03:04:13 -07:00
committed by GitHub
parent de4e466036
commit 272484f8bf
16 changed files with 151 additions and 312 deletions

View File

@@ -894,13 +894,13 @@ summary: Summary (zh)
b.Build(BuildCfg{})
b.AssertFileContent("public/index.html", `<html>
<body>
<h2>Translations</h2>
<ul>
<li>Title: Title (zh), Summary (zh)</li>
<li>Content: <p>这是一些内容</p>
</li>
@@ -911,7 +911,7 @@ summary: Summary (zh)
<li>Truncated: false</li>
<li>FuzzyWordCount: 100</li>
<li>ReadingTime: 1</li>
<li>Len: 26</li>
<li>Len: 26</li>
</ul>
@@ -921,7 +921,7 @@ summary: Summary (zh)
b.AssertFileContent("public/metadata.html", `<h2>Translations metadata</h2>
<ul>
<li>Title: Title (zh), Summary (zh)</li>
<li>Content: <p>这是一些内容</p>
</li>
@@ -932,13 +932,13 @@ summary: Summary (zh)
<li>Truncated: false</li>
<li>FuzzyWordCount: 100</li>
<li>ReadingTime: 1</li>
<li>Len: 26</li>
<li>Len: 26</li>
</ul>`)
b.AssertFileContent("public/zh_cn/index.html", `<html>
<body>
<h2>Translations</h2>
<ul>
@@ -953,7 +953,7 @@ summary: Summary (zh)
<li>Truncated: false</li>
<li>FuzzyWordCount: 100</li>
<li>ReadingTime: 1</li>
<li>Len: 29</li>
<li>Len: 29</li>
</ul>
@@ -963,7 +963,7 @@ summary: Summary (zh)
b.AssertFileContent("public/zh_cn/metadata.html", `<h2>Translations metadata</h2>
<ul>
<li>Title: Title (en), Summary (en)</li>
<li>Content: <p>Here is some content.</p>
</li>
@@ -974,7 +974,7 @@ summary: Summary (zh)
<li>Truncated: false</li>
<li>FuzzyWordCount: 100</li>
<li>ReadingTime: 1</li>
<li>Len: 29</li>
<li>Len: 29</li>
</ul>`)
}
@@ -1234,60 +1234,6 @@ func TestChompBOM(t *testing.T) {
checkPageTitle(t, p, "Simple")
}
func TestPageWithEmoji(t *testing.T) {
for _, enableEmoji := range []bool{true, false} {
v := config.New()
v.Set("enableEmoji", enableEmoji)
b := newTestSitesBuilder(t).WithViper(v)
b.WithContent("page-emoji.md", `---
title: "Hugo Smile"
---
This is a :smile:.
<!--more-->
Another :smile: This is :not: :an: :emoji:.
O :christmas_tree:
Write me an :e-mail: or :email:?
Too many colons: :: ::: :::: :?: :!: :.:
If you dislike this video, you can hit that :-1: button :stuck_out_tongue_winking_eye:,
but if you like it, hit :+1: and get subscribed!
`)
b.CreateSites().Build(BuildCfg{})
if enableEmoji {
b.AssertFileContent("public/page-emoji/index.html",
"This is a 😄",
"Another 😄",
"This is :not: :an: :emoji:.",
"O 🎄",
"Write me an 📧 or ✉️?",
"Too many colons: :: ::: :::: :?: :!: :.:",
"you can hit that 👎 button 😜,",
"hit 👍 and get subscribed!",
)
} else {
b.AssertFileContent("public/page-emoji/index.html",
"This is a :smile:",
"Another :smile:",
"This is :not: :an: :emoji:.",
"O :christmas_tree:",
"Write me an :e-mail: or :email:?",
"Too many colons: :: ::: :::: :?: :!: :.:",
"you can hit that :-1: button :stuck_out_tongue_winking_eye:,",
"hit :+1: and get subscribed!",
)
}
}
}
func TestPageHTMLContent(t *testing.T) {
b := newTestSitesBuilder(t)
b.WithSimpleConfigFile()
@@ -1333,7 +1279,7 @@ func TestPageManualSummary(t *testing.T) {
title: "Hugo"
---
This is a {{< sc >}}.
<!--more-->
<!--more-->
Content.
`)
@@ -1342,7 +1288,7 @@ Content.
title: "Hugo"
---
{{< sc >}}
<!--more-->
<!--more-->
{{< sc >}}
`)
@@ -1363,7 +1309,7 @@ Summary<!--more-->{{< sc >}}
#+DESCRIPTION: D1
This is a {{< sc >}}.
# more
Content.
Content.
`)
b.WithContent("page-org-variant1.org", `#+TITLE: T1
@@ -1371,7 +1317,7 @@ Summary.
# more
Content.
Content.
`)
b.WithTemplatesAdded("layouts/shortcodes/sc.html", "a shortcode")
@@ -1665,7 +1611,7 @@ SUMMARY:{{ .Summary }}:{{ len .Summary }}:END
b := newTestSitesBuilder(t)
b.WithSimpleConfigFile().WithTemplatesAdded(single...).WithContent("p1.md", fmt.Sprintf(`---
title: p1
title: p1
---
%s