Repository: gohugoio/hugo (language: go)

Issue:
Accommodate recent change to Goldmark's strikethrough extension
<https://github.com/yuin/goldmark/pull/455>

Prior to this change in [v1.7.2](https://github.com/yuin/goldmark/releases/tag/v1.7.2), Goldmark's strikethrough extension was triggered by wrapping text within a pair of double-tildes:

```text
~~deleted~~
```

This behavior was compatible with Hugo's [extras](https://github.com/gohugoio/hugo-goldmark-extensions?tab=readme-ov-file#extras-extension) extension, so you could use strikethrough and subscripts at the same time:

```text
~~deleted~~
H~2~O
```

Goldmark's strikethrough extension is now triggered by either single- or double-tildes:

```text
~~deleted~~
~deleted~
```

That means you can no longer use use strikethrough and subscripts at the same time.

Possible solutions:

1. Look at prioritization, though initial review by @bowman2001 was not promising
2. Implement a double-tilde strikethrough feature in the extras extension, and use this feature instead of Goldmark's strikethrough extension when subscripts are enabled (or some similar mechanism)


Regardless of the subscript conflict, the Goldmark change is a breaking change.



Discussion / hints:
About the suggested prioritization: There already was a unit test case to check the compatibility and coexistence of subscript and strike-through for an expression with mixed usage. And I just added another one with a simple strike-through. For now, they are both fine.

When I raise the priority of subscript above strike-through (locally), they both fail (as expected).
> For now, they are both fine.

Please clarify what this means.
With the current prioritization, both tests pass. 

They will fail if the priority of subscript is raised above strike-through. (Tested locally)
As far as I can see, the only option is our own strike-through implementation. I think, this extension should be able to process both kinds of usages of the `~` like Goldmark handles both types of emphasis. This would be the most efficient way.

And because you already implemented a detailed configuration structure, it would also be possible to accommodate different needs with an additional config parameter. 
This one could decide, if the new strike-through works as in the GFM spec or treats single `~` as subscripts.

The default configuration could be compatible with GFM and something like `subscript: true` could enable the current behavior when both extensions are enabled.
 
 
Putting aside the configuration settings for a moment, this is how I think it should work:

1. With a fresh Hugo install, both single- and double-tilde strikethrough should be enabled. This is consistent with the current default and provides GFM compatibility.
2. As soon as you enable subscripts, anything wrapped in single-tildes is a subscript

Assuming we have to add strikethrough to the extras extension, the default config should be:

```text
[markup.goldmark.extensions.extras.strikethrough]
enable = true
```

Which leaves us with this to figure out:

```
[markup.goldmark.extensions]
strikethrough = true/false
```

I suspect that very few users have disabled strikethrough... I can't remember seeing it. So the easiest approach would be to completely remove the Goldmark strikethrough extension/config, and note the breaking change in the release notes, applicable only  if they currently have strikethrough disabled.





I could implement a new strike-through extension which includes the subscript without the configuration switch for a start. I am currently occupied and won't be able to finish this before the middle of the next month. But this is important to me and I would be happy to contribute.

Fix patch:
diff --git a/docs/data/docs.yaml b/docs/data/docs.yaml
index 6d85042d768..476d374a1f8 100644
--- a/docs/data/docs.yaml
+++ b/docs/data/docs.yaml
@@ -1082,6 +1082,8 @@ config:
           escapedSpace: false
         definitionList: true
         extras:
+          delete:
+            enable: false
           insert:
             enable: false
           mark:
@@ -1589,8 +1591,8 @@ config:
   paginate: 0
   paginatePath: ""
   pagination:
-    defaultPageSize: 10
     disableAliases: false
+    pagerSize: 10
     path: page
   panicOnWarning: false
   params: {}
diff --git a/go.mod b/go.mod
index 928fbdecb74..87119cf9ca8 100644
--- a/go.mod
+++ b/go.mod
@@ -36,7 +36,7 @@ require (
 	github.com/gobwas/glob v0.2.3
 	github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e
 	github.com/gohugoio/httpcache v0.7.0
-	github.com/gohugoio/hugo-goldmark-extensions/extras v0.1.0
+	github.com/gohugoio/hugo-goldmark-extensions/extras v0.2.0
 	github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.2.0
 	github.com/gohugoio/locales v0.14.0
 	github.com/gohugoio/localescompressed v1.0.1
@@ -68,7 +68,7 @@ require (
 	github.com/spf13/pflag v1.0.5
 	github.com/tdewolff/minify/v2 v2.20.20
 	github.com/tdewolff/parse/v2 v2.7.13
-	github.com/yuin/goldmark v1.7.1
+	github.com/yuin/goldmark v1.7.2
 	github.com/yuin/goldmark-emoji v1.0.2
 	go.uber.org/automaxprocs v1.5.3
 	gocloud.dev v0.36.0
diff --git a/go.sum b/go.sum
index 1241068bc48..271f434c642 100644
--- a/go.sum
+++ b/go.sum
@@ -213,8 +213,8 @@ github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e h1:QArsSubW7
 github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e/go.mod h1:3Ltoo9Banwq0gOtcOwxuHG6omk+AwsQPADyw2vQYOJQ=
 github.com/gohugoio/httpcache v0.7.0 h1:ukPnn04Rgvx48JIinZvZetBfHaWE7I01JR2Q2RrQ3Vs=
 github.com/gohugoio/httpcache v0.7.0/go.mod h1:fMlPrdY/vVJhAriLZnrF5QpN3BNAcoBClgAyQd+lGFI=
-github.com/gohugoio/hugo-goldmark-extensions/extras v0.1.0 h1:YhxZNU8y2vxV6Ibr7QJzzUlpr8oHHWX/l+Q1R/a5Zao=
-github.com/gohugoio/hugo-goldmark-extensions/extras v0.1.0/go.mod h1:0cuvOnGKW7WeXA3i7qK6IS07FH1bgJ2XzOjQ7BMJYH4=
+github.com/gohugoio/hugo-goldmark-extensions/extras v0.2.0 h1:MNdY6hYCTQEekY0oAfsxWZU1CDt6iH+tMLgyMJQh/sg=
+github.com/gohugoio/hugo-goldmark-extensions/extras v0.2.0/go.mod h1:oBdBVuiZ0fv9xd8xflUgt53QxW5jOCb1S+xntcN4SKo=
 github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.2.0 h1:PCtO5l++psZf48yen2LxQ3JiOXxaRC6v0594NeHvGZg=
 github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.2.0/go.mod h1:g9CCh+Ci2IMbPUrVJuXbBTrA+rIIx5+hDQ4EXYaQDoM=
 github.com/gohugoio/locales v0.14.0 h1:Q0gpsZwfv7ATHMbcTNepFd59H7GoykzWJIxi113XGDc=
@@ -447,8 +447,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
 github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
 github.com/yuin/goldmark v1.3.7/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
-github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U=
-github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
+github.com/yuin/goldmark v1.7.2 h1:NjGd7lO7zrUn/A7eKwn5PEOt4ONYGqpxSEeZuduvgxc=
+github.com/yuin/goldmark v1.7.2/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
 github.com/yuin/goldmark-emoji v1.0.2 h1:c/RgTShNgHTtc6xdz2KKI74jJr6rWi7FPgnP9GAsO5s=
 github.com/yuin/goldmark-emoji v1.0.2/go.mod h1:RhP/RWpexdp+KHs7ghKnifRoIs/Bq4nDS7tRbCkOwKY=
 go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
diff --git a/markup/goldmark/convert.go b/markup/goldmark/convert.go
index 7c00433d51a..1c0d228edfb 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 620475c4840..c6e0bcd3d6e 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
 }


Test patch:
diff --git a/markup/goldmark/goldmark_integration_test.go b/markup/goldmark/goldmark_integration_test.go
index 82b41cc67fa..19338310c02 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>",