aboutsummaryrefslogtreecommitdiffhomepage
path: root/markup
diff options
context:
space:
mode:
authorJoe Mooring <[email protected]>2024-06-15 06:45:27 -0700
committerBjørn Erik Pedersen <[email protected]>2024-06-18 18:56:20 +0200
commit8efc75b73f4808b7677247e27a18f3ad72416ae4 (patch)
tree380a251679e6d7207cbaf208576423378371a014 /markup
parentad6d91cabd84aac1be6e83511a543643562cb1b2 (diff)
downloadhugo-8efc75b73f4808b7677247e27a18f3ad72416ae4.tar.gz
hugo-8efc75b73f4808b7677247e27a18f3ad72416ae4.zip
markup/goldmark: Add the Hugo Goldmark Extras "delete" extension
With Goldmark v1.7.1 and earlier, the Goldmark "strikethrough" extension was triggered by wrapping text within a pair of double-tilde characters. With Goldmark v1.7.2 and later, to provide full GFM compatibility, the Goldmark "strikethrough" extension is triggered by wrapping text within a pair of single- or double-tilde characters. This change created a conflict with the Hugo Goldmark Extras "subscript" extension. When enabling the Hugo Goldmark Extras "subscript" extension, if you want to render subscript and strikethrough text concurrently, you must: 1. Disable the Goldmark "strikethrough" extension 2. Enable the Hugo Goldmark Extras "delete" extension Closes #12597
Diffstat (limited to 'markup')
-rw-r--r--markup/goldmark/convert.go1
-rw-r--r--markup/goldmark/goldmark_config/config.go16
-rw-r--r--markup/goldmark/goldmark_integration_test.go8
3 files changed, 21 insertions, 4 deletions
diff --git a/markup/goldmark/convert.go b/markup/goldmark/convert.go
index 7c00433d5..1c0d228ed 100644
--- a/markup/goldmark/convert.go
+++ b/markup/goldmark/convert.go
@@ -116,6 +116,7 @@ func newMarkdown(pcfg converter.ProviderConfig) goldmark.Markdown {
extensions = append(extensions, extras.New(
extras.Config{
+ Delete: extras.DeleteConfig{Enable: cfg.Extensions.Extras.Delete.Enable},
Insert: extras.InsertConfig{Enable: cfg.Extensions.Extras.Insert.Enable},
Mark: extras.MarkConfig{Enable: cfg.Extensions.Extras.Mark.Enable},
Subscript: extras.SubscriptConfig{Enable: cfg.Extensions.Extras.Subscript.Enable},
diff --git a/markup/goldmark/goldmark_config/config.go b/markup/goldmark/goldmark_config/config.go
index 620475c48..c6e0bcd3d 100644
--- a/markup/goldmark/goldmark_config/config.go
+++ b/markup/goldmark/goldmark_config/config.go
@@ -50,10 +50,7 @@ var Default = Config{
EscapedSpace: false,
},
Extras: Extras{
- Superscript: Superscript{
- Enable: false,
- },
- Subscript: Subscript{
+ Delete: Delete{
Enable: false,
},
Insert: Insert{
@@ -62,6 +59,12 @@ var Default = Config{
Mark: Mark{
Enable: false,
},
+ Subscript: Subscript{
+ Enable: false,
+ },
+ Superscript: Superscript{
+ Enable: false,
+ },
},
Passthrough: Passthrough{
Enable: false,
@@ -168,12 +171,17 @@ type Typographer struct {
// Extras holds extras configuration.
// github.com/hugoio/hugo-goldmark-extensions/extras
type Extras struct {
+ Delete Delete
Insert Insert
Mark Mark
Subscript Subscript
Superscript Superscript
}
+type Delete struct {
+ Enable bool
+}
+
type Insert struct {
Enable bool
}
diff --git a/markup/goldmark/goldmark_integration_test.go b/markup/goldmark/goldmark_integration_test.go
index 82b41cc67..19338310c 100644
--- a/markup/goldmark/goldmark_integration_test.go
+++ b/markup/goldmark/goldmark_integration_test.go
@@ -751,6 +751,10 @@ func TestExtrasExtension(t *testing.T) {
files := `
-- hugo.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
+[markup.goldmark.extensions]
+strikethrough = false
+[markup.goldmark.extensions.extras.delete]
+enable = false
[markup.goldmark.extensions.extras.insert]
enable = false
[markup.goldmark.extensions.extras.mark]
@@ -765,6 +769,8 @@ enable = false
---
title: home
---
+~~delete~~
+
++insert++
==mark==
@@ -777,6 +783,7 @@ H~2~0
b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html",
+ "<p>~~delete~~</p>",
"<p>++insert++</p>",
"<p>==mark==</p>",
"<p>H~2~0</p>",
@@ -788,6 +795,7 @@ H~2~0
b = hugolib.Test(t, files)
b.AssertFileContent("public/index.html",
+ "<p><del>delete</del></p>",
"<p><ins>insert</ins></p>",
"<p><mark>mark</mark></p>",
"<p>H<sub>2</sub>0</p>",