mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
Fix handling of HTML files without front matter
This means that any HTML file inside /content will be treated as a regular file. If you want it processes with shortcodes and a layout, add front matter. The defintion of an HTML file here is: * File with extension .htm or .html * With first non-whitespace character "<" that isn't a HTML comment. This is in line with the documentation. Fixes #7030 Fixes #7028 See #6789
This commit is contained in:
@@ -15,6 +15,7 @@ package files
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
@@ -30,6 +31,17 @@ func TestIsContentFile(t *testing.T) {
|
||||
c.Assert(IsContentExt("json"), qt.Equals, false)
|
||||
}
|
||||
|
||||
func TestIsHTMLContent(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
c.Assert(isHTMLContent(strings.NewReader(" <html>")), qt.Equals, true)
|
||||
c.Assert(isHTMLContent(strings.NewReader(" <!--\n---")), qt.Equals, false)
|
||||
c.Assert(isHTMLContent(strings.NewReader(" <!--")), qt.Equals, true)
|
||||
c.Assert(isHTMLContent(strings.NewReader(" ---<")), qt.Equals, false)
|
||||
c.Assert(isHTMLContent(strings.NewReader(" foo <")), qt.Equals, false)
|
||||
|
||||
}
|
||||
|
||||
func TestComponentFolders(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
|
Reference in New Issue
Block a user