mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Fix some RenderShortcodes error cases
This issue fixes two cases where `{{__hugo_ctx` artifacts were left in the rendered output: 1. Inclusion when `.RenderShortcodes` is wrapped in HTML. 2. Inclusion of Markdown file without a trailing newline in some cases. Closes #12854 Updates #12998
This commit is contained in:
@@ -16,7 +16,9 @@ package hugolib
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
@@ -358,7 +360,22 @@ func (p *pageState) Site() page.Site {
|
||||
}
|
||||
|
||||
func (p *pageState) String() string {
|
||||
return fmt.Sprintf("Page(%s)", p.Path())
|
||||
var sb strings.Builder
|
||||
if p.File() != nil {
|
||||
// The forward slashes even on Windows is motivated by
|
||||
// getting stable tests.
|
||||
// This information is meant for getting positional information in logs,
|
||||
// so the direction of the slashes should not matter.
|
||||
sb.WriteString(filepath.ToSlash(p.File().Filename()))
|
||||
if p.File().IsContentAdapter() {
|
||||
// Also include the path.
|
||||
sb.WriteString(":")
|
||||
sb.WriteString(p.Path())
|
||||
}
|
||||
} else {
|
||||
sb.WriteString(p.Path())
|
||||
}
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
// IsTranslated returns whether this content file is translated to
|
||||
|
Reference in New Issue
Block a user