Repository: gohugoio/hugo (language: go)

Issue:
minify strips PHP tags
# Steps to Reproduce
Add following line to a template:
`{{ readFile "path/file" | safeHTML }}`

run `hugo --minify`
--> This part gets ommited, when using the `--minify` flag on hugo.

when you run just `hugo` everything is fine.

## How I came up with that:
I am including a php snippet for a contact form into a hugo template. Without the use of safeHTML` <?php` gets translated to `&lt;?php`.


Discussion / hints:
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a **bug** and you can still reproduce this error on the <code>master</code> branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a **feature request**, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

The [upstream minifier](https://github.com/tdewolff/minify) Hugo uses doesn't handle PHP tags.  See https://github.com/tdewolff/minify/issues/35#issuecomment-176094022
Are there any workaround for such problem? Looks like a blocking error for using PHP inside HUGO templates with --minify.
I found a workaround at cost of all HTML comments keeping, it's acceptable in my case.
Thanks to @satotake "Add minify config" patch 574c2959b8d3338764fa1db102a5e0fd6ed322d9!

Add next lines to your `config.toml`:
```
[minify]
  [minify.tdewolff]
    [minify.tdewolff.html]
	  keepComments = true
```
Of course you must also escape PHP-tags inside partials templates:
```
{{ safeHTML "<?php" }}
...
{{ safeHTML "?>" }}
```


Fix patch:
diff --git a/docs/data/docs.yaml b/docs/data/docs.yaml
index 2cdb0dd53c0..48a12f5225a 100644
--- a/docs/data/docs.yaml
+++ b/docs/data/docs.yaml
@@ -824,6 +824,8 @@ chroma:
   - Aliases:
     - typoscripthtmldata
     Name: TypoScriptHtmlData
+  - Aliases: null
+    Name: ucode
   - Aliases:
     - v
     - vlang
@@ -1254,6 +1256,9 @@ config:
         keepEndTags: true
         keepQuotes: false
         keepWhitespace: false
+        templateDelims:
+        - ""
+        - ""
       js:
         keepVarNames: false
         precision: 0
@@ -2741,6 +2746,21 @@ tpl:
             map[string]interface {}{
               "Hugo": "Rocks!",
             }
+      TestDeprecationErr:
+        Aliases: null
+        Args: null
+        Description: ""
+        Examples: null
+      TestDeprecationInfo:
+        Aliases: null
+        Args: null
+        Description: ""
+        Examples: null
+      TestDeprecationWarn:
+        Aliases: null
+        Args: null
+        Description: ""
+        Examples: null
       Timer:
         Aliases: null
         Args: null
@@ -4364,6 +4384,16 @@ tpl:
         - - '{{ "hello = \"Hello World\"" | resources.FromString "data/greetings.toml"
             | transform.Unmarshal }}'
           - map[hello:Hello World]
+      XMLEscape:
+        Aliases: null
+        Args:
+        - s
+        Description: |-
+          XMLEscape returns the given string, removing disallowed characters then
+          escaping the result to its XML equivalent.
+        Examples:
+        - - '{{ transform.XMLEscape "<p>abc</p>" }}'
+          - '&lt;p&gt;abc&lt;/p&gt;'
     urls:
       AbsLangURL:
         Aliases:
diff --git a/go.mod b/go.mod
index e299c500743..a672b5faa37 100644
--- a/go.mod
+++ b/go.mod
@@ -61,8 +61,8 @@ require (
 	github.com/spf13/cobra v1.8.0
 	github.com/spf13/fsync v0.9.0
 	github.com/spf13/pflag v1.0.5
-	github.com/tdewolff/minify/v2 v2.20.7
-	github.com/tdewolff/parse/v2 v2.7.5
+	github.com/tdewolff/minify/v2 v2.20.8
+	github.com/tdewolff/parse/v2 v2.7.6
 	github.com/yuin/goldmark v1.6.0
 	github.com/yuin/goldmark-emoji v1.0.2
 	go.uber.org/atomic v1.11.0
diff --git a/go.sum b/go.sum
index 0442c40f811..5d89faf97e1 100644
--- a/go.sum
+++ b/go.sum
@@ -130,8 +130,6 @@ github.com/bep/godartsass/v2 v2.0.0 h1:Ruht+BpBWkpmW+yAM2dkp7RSSeN0VLaTobyW0CiSP
 github.com/bep/godartsass/v2 v2.0.0/go.mod h1:AcP8QgC+OwOXEq6im0WgDRYK7scDsmZCEW62o1prQLo=
 github.com/bep/golibsass v1.1.1 h1:xkaet75ygImMYjM+FnHIT3xJn7H0xBA9UxSOJjk8Khw=
 github.com/bep/golibsass v1.1.1/go.mod h1:DL87K8Un/+pWUS75ggYv41bliGiolxzDKWJAq3eJ1MA=
-github.com/bep/gowebp v0.2.0 h1:ZVfK8i9PpZqKHEmthQSt3qCnnHycbLzBPEsVtk2ch2Q=
-github.com/bep/gowebp v0.2.0/go.mod h1:ZhFodwdiFp8ehGJpF4LdPl6unxZm9lLFjxD3z2h2AgI=
 github.com/bep/gowebp v0.3.0 h1:MhmMrcf88pUY7/PsEhMgEP0T6fDUnRTMpN8OclDrbrY=
 github.com/bep/gowebp v0.3.0/go.mod h1:ZhFodwdiFp8ehGJpF4LdPl6unxZm9lLFjxD3z2h2AgI=
 github.com/bep/helpers v0.4.0 h1:ab9veaAiWY4ST48Oxp5usaqivDmYdB744fz+tcZ3Ifs=
@@ -425,10 +423,10 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
 github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
 github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
 github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
-github.com/tdewolff/minify/v2 v2.20.7 h1:NUkuzJ9dvQUNJjSdmmrfELa/ZpnMdyMR/ZKU2bw7N/E=
-github.com/tdewolff/minify/v2 v2.20.7/go.mod h1:bj2NpP3zoUhsPzE4oM4JYwuUyVCU/uMaCYZ6/riEjIo=
-github.com/tdewolff/parse/v2 v2.7.5 h1:RdcN3Ja6zAMSvnxxO047xRoWexX3RrXKi3H6EQHzXto=
-github.com/tdewolff/parse/v2 v2.7.5/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
+github.com/tdewolff/minify/v2 v2.20.8 h1:OqDc95F0OK239T7P5g5oL5XthQtOtKbhbhM9GKc2W9g=
+github.com/tdewolff/minify/v2 v2.20.8/go.mod h1:hZnNtFqXVQ5QIAR05tdgvS7h6E80jyRwHSGVmM4jbzQ=
+github.com/tdewolff/parse/v2 v2.7.6 h1:PGZH2b/itDSye9RatReRn4GBhsT+KFEMtAMjHRuY1h8=
+github.com/tdewolff/parse/v2 v2.7.6/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
 github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52 h1:gAQliwn+zJrkjAHVcBEYW/RFvd2St4yYimisvozAYlA=
 github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
 github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=


Test patch:
diff --git a/markup/goldmark/integration_test.go b/markup/goldmark/integration_test.go
index fdcbf497530..a2bf1637489 100644
--- a/markup/goldmark/integration_test.go
+++ b/markup/goldmark/integration_test.go
@@ -689,3 +689,25 @@ title: "p1"
 
 	b.AssertFileContentExact("public/p1/index.html", "<p>:x:</p>")
 }
+
+// Issue #5748
+func TestGoldmarkTemplateDelims(t *testing.T) {
+	t.Parallel()
+
+	files := `
+-- config.toml --
+[minify]
+  minifyOutput = true
+[minify.tdewolff.html]
+  templateDelims = ["<?php","?>"]
+-- layouts/index.html --
+<div class="foo">
+{{ safeHTML "<?php" }}
+echo "hello";
+{{ safeHTML "?>" }}
+</div>
+`
+
+	b := hugolib.Test(t, files)
+	b.AssertFileContent("public/index.html", "<div class=foo><?php\necho \"hello\";\n?>\n</div>")
+}