mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parent
507f4e356b
commit
4583b41305
2 changed files with 26 additions and 1 deletions
|
@ -16,6 +16,7 @@ package transform_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
"github.com/gohugoio/hugo/hugolib"
|
||||
)
|
||||
|
||||
|
@ -85,3 +86,24 @@ a **b** c
|
|||
<description><p>a <strong>b</strong> c</p></description>
|
||||
`)
|
||||
}
|
||||
|
||||
// Issue #9642
|
||||
func TestHighlightError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
|
||||
-- layouts/index.html --
|
||||
{{ highlight "a" "b" 0 }}
|
||||
`
|
||||
b := hugolib.NewIntegrationTestBuilder(
|
||||
hugolib.IntegrationTestConfig{
|
||||
T: t,
|
||||
TxtarString: files,
|
||||
},
|
||||
)
|
||||
|
||||
_, err := b.BuildE()
|
||||
b.Assert(err.Error(), qt.Contains, "error calling highlight: invalid Highlight option: 0")
|
||||
}
|
||||
|
|
|
@ -79,7 +79,10 @@ func (ns *Namespace) Highlight(s any, lang string, opts ...any) (template.HTML,
|
|||
}
|
||||
|
||||
hl := ns.deps.ContentSpec.Converters.GetHighlighter()
|
||||
highlighted, _ := hl.Highlight(ss, lang, optsv)
|
||||
highlighted, err := hl.Highlight(ss, lang, optsv)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return template.HTML(highlighted), nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue