Compare commits

...

2 Commits

Author SHA1 Message Date
Bjørn Erik Pedersen 75f383065f Fix server refresh on 404 template changes
Fixes #13209
2025-01-01 17:24:30 +01:00
Joe Mooring 2db43f841c markup/highlight: Remove noHl option
Closes #9885
2024-12-31 15:46:46 +01:00
5 changed files with 34 additions and 9 deletions
+31
View File
@@ -14,6 +14,7 @@
package hugolib
import (
"fmt"
"testing"
)
@@ -82,3 +83,33 @@ Page not found
Base:
Page not found`)
}
func Test404EditTemplate(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
baseURL = "http://example.com/"
disableLiveReload = true
[internal]
fastRenderMode = true
-- layouts/_default/baseof.html --
Base: {{ block "main" . }}{{ end }}
-- layouts/404.html --
{{ define "main" }}
Not found.
{{ end }}
`
b := TestRunning(t, files)
b.AssertFileContent("public/404.html", `Not found.`)
b.EditFiles("layouts/404.html", `Not found. Updated.`).Build()
fmt.Println("Rebuilding")
b.BuildPartial("/does-not-exist")
b.AssertFileContent("public/404.html", `Not found. Updated.`)
}
+2 -1
View File
@@ -1274,7 +1274,7 @@ func (h *HugoSites) resolveAndResetDependententPageOutputs(ctx context.Context,
po.renderState = 0
po.p.resourcesPublishInit = &sync.Once{}
if r == identity.FinderFoundOneOfMany {
if r == identity.FinderFoundOneOfMany || po.f.Name == output.HTTPStatusHTMLFormat.Name {
// Will force a re-render even in fast render mode.
po.renderOnce = false
}
@@ -1310,6 +1310,7 @@ func (h *HugoSites) resolveAndResetDependententPageOutputs(ctx context.Context,
if !po.isRendered() {
continue
}
for _, id := range changes {
checkedCounter.Add(1)
if r := depsFinder.Contains(id, po.dependencyManagerOutput, 50); r > identity.FinderFoundOneOfManyRepetition {
-6
View File
@@ -33,7 +33,6 @@ const (
lineNosKey = "linenos"
hlLinesKey = "hl_lines"
linosStartKey = "linenostart"
noHlKey = "nohl"
)
var DefaultConfig = Config{
@@ -60,9 +59,6 @@ type Config struct {
// Use inline CSS styles.
NoClasses bool
// No highlighting.
NoHl bool
// When set, line numbers will be printed.
LineNos bool
LineNumbersInTable bool
@@ -234,8 +230,6 @@ func normalizeHighlightOptions(m map[string]any) {
for k, v := range m {
switch k {
case noHlKey:
m[noHlKey] = cast.ToBool(v)
case lineNosKey:
if v == "table" || v == "inline" {
m["lineNumbersInTable"] = v == "table"
+1 -1
View File
@@ -168,7 +168,7 @@ func highlight(fw hugio.FlexiWriter, code, lang string, attributes []attributes.
lexer = chromalexers.Get(lang)
}
if lexer == nil && (cfg.GuessSyntax && !cfg.NoHl) {
if lexer == nil && cfg.GuessSyntax {
lexer = lexers.Analyse(code)
if lexer == nil {
lexer = lexers.Fallback
-1
View File
@@ -36,7 +36,6 @@ var chromaHighlightProcessingAttributes = map[string]bool{
"lineNoStart": true,
"lineNumbersInTable": true,
"noClasses": true,
"nohl": true,
"style": true,
"tabWidth": true,
}