aboutsummaryrefslogtreecommitdiffhomepage
path: root/parser
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-05-29 12:59:57 +0200
committerBjørn Erik Pedersen <[email protected]>2024-05-30 11:29:21 +0200
commit519f41dbd72d4b13208225ab5b28c6d98ecb07ba (patch)
treee1fd7fd1fff1ba6ddfe2aac4ff1616ca26dea201 /parser
parent7f3061723e3df064515fc57c183b06ed16f26b75 (diff)
downloadhugo-519f41dbd72d4b13208225ab5b28c6d98ecb07ba.tar.gz
hugo-519f41dbd72d4b13208225ab5b28c6d98ecb07ba.zip
content adapter: Fix issue with content starting out with a shortcode
Fixes #12544
Diffstat (limited to 'parser')
-rw-r--r--parser/pageparser/pagelexer.go4
-rw-r--r--parser/pageparser/pageparser.go6
2 files changed, 8 insertions, 2 deletions
diff --git a/parser/pageparser/pagelexer.go b/parser/pageparser/pagelexer.go
index 5f90e3687..e3b0f1e54 100644
--- a/parser/pageparser/pagelexer.go
+++ b/parser/pageparser/pagelexer.go
@@ -62,7 +62,9 @@ func (l *pageLexer) Input() []byte {
return l.input
}
-type Config struct{}
+type Config struct {
+ NoFrontMatter bool
+}
// note: the input position here is normally 0 (start), but
// can be set if position of first shortcode is known
diff --git a/parser/pageparser/pageparser.go b/parser/pageparser/pageparser.go
index 9e8b6d803..988a80c83 100644
--- a/parser/pageparser/pageparser.go
+++ b/parser/pageparser/pageparser.go
@@ -36,7 +36,11 @@ var _ Result = (*pageLexer)(nil)
// ParseBytes parses the page in b according to the given Config.
func ParseBytes(b []byte, cfg Config) (Items, error) {
- l, err := parseBytes(b, cfg, lexIntroSection)
+ startLexer := lexIntroSection
+ if cfg.NoFrontMatter {
+ startLexer = lexMainSection
+ }
+ l, err := parseBytes(b, cfg, startLexer)
if err != nil {
return nil, err
}