Repository: gohugoio/hugo (language: go)

Issue:
Goldmark regression: HTML comments in markdown are not rendered as HTML comments
Reference: <https://discourse.gohugo.io/t/inline-html-comments-not-being-recognized-in-markdown-files/37598>

config

```toml
[markup.goldmark.renderer]
unsafe = true
```

markdown

```html
a <!-- b --> c
```

result

```html
<p>a &lt;!-- b --&gt; c</p>
```
Upstream: <https://github.com/yuin/goldmark/issues/285>
markup/goldmark: Revert from 1.4.8 to 1.4.7
Fixes #9650

I think this is serious enough to downgrade. PR includes test to make sure this doesn't happen again.

Or we can wait a day to see if it gets fixed upstream.


Discussion / hints:
Ramifications...

v0.93.2

![image](https://user-images.githubusercontent.com/335669/157767078-1f89e586-0291-4152-b40c-3f78d444213c.png)


v0.93.3

![image](https://user-images.githubusercontent.com/335669/157767019-192f75c2-cd0c-4269-9fe8-14e44c5d78c6.png)

Thanks, I will do a release with a fix for this one way or the other some time later today.
https://github.com/yuin/goldmark/releases/tag/v1.4.9

10 minutes old.

Fix patch:
diff --git a/go.mod b/go.mod
index bab239dd253..cacafa240cd 100644
--- a/go.mod
+++ b/go.mod
@@ -58,7 +58,7 @@ require (
 	github.com/spf13/jwalterweatherman v1.1.0
 	github.com/spf13/pflag v1.0.5
 	github.com/tdewolff/minify/v2 v2.10.0
-	github.com/yuin/goldmark v1.4.8
+	github.com/yuin/goldmark v1.4.9
 	go.uber.org/atomic v1.9.0
 	gocloud.dev v0.20.0
 	golang.org/x/image v0.0.0-20211028202545-6944b10bf410
diff --git a/go.sum b/go.sum
index 6a14eb2a9f5..93c1565bf87 100644
--- a/go.sum
+++ b/go.sum
@@ -577,8 +577,12 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
 github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
 github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+github.com/yuin/goldmark v1.4.7 h1:KHHlQL4EKBZ43vpA1KBEQHfodk4JeIgeb0xJLg7rvDI=
+github.com/yuin/goldmark v1.4.7/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg=
 github.com/yuin/goldmark v1.4.8 h1:zHPiabbIRssZOI0MAzJDHsyvG4MXCGqVaMOwR+HeoQQ=
 github.com/yuin/goldmark v1.4.8/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg=
+github.com/yuin/goldmark v1.4.9 h1:RmdXMGe/HwhQEWIjFAu8fjjvkxJ0tDRVbWGrsPNrclw=
+github.com/yuin/goldmark v1.4.9/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg=
 go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
 go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
 go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs=


Test patch:
diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go
index b7b43624f37..1bfa194bdc9 100644
--- a/hugolib/integrationtest_builder.go
+++ b/hugolib/integrationtest_builder.go
@@ -133,6 +133,14 @@ func (s *IntegrationTestBuilder) AssertFileContent(filename string, matches ...s
 	}
 }
 
+func (s *IntegrationTestBuilder) AssertFileContentExact(filename string, matches ...string) {
+	s.Helper()
+	content := s.FileContent(filename)
+	for _, m := range matches {
+		s.Assert(content, qt.Contains, m, qt.Commentf(m))
+	}
+}
+
 func (s *IntegrationTestBuilder) AssertDestinationExists(filename string, b bool) {
 	checker := qt.IsTrue
 	if !b {
diff --git a/markup/goldmark/integration_test.go b/markup/goldmark/integration_test.go
index cab85cfdd4c..064ffb85d1a 100644
--- a/markup/goldmark/integration_test.go
+++ b/markup/goldmark/integration_test.go
@@ -535,3 +535,33 @@ Link https procol: https://www.example.org
 
 	}
 }
+
+// Issue 9650
+func TestRenderingOfHtmlComments(t *testing.T) {
+	t.Parallel()
+
+	files := `
+-- config.toml --
+[markup.goldmark.renderer]
+unsafe = true
+-- content/p1.md --
+---
+title: "p1"
+---
+a <!-- b --> c
+
+-- layouts/_default/single.html --
+{{ .Content }}
+`
+
+	b := hugolib.NewIntegrationTestBuilder(
+		hugolib.IntegrationTestConfig{
+			T:           t,
+			TxtarString: files,
+		},
+	).Build()
+
+	b.AssertFileContentExact("public/p1/index.html",
+		"<p>a <!-- b --> c</p>",
+	)
+}