summaryrefslogtreecommitdiffstats
path: root/tpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-09-25 08:59:02 +0200
committerGitHub <noreply@github.com>2017-09-25 08:59:02 +0200
commitfb33d8286d78a78a74deb44355b621852a1c4033 (patch)
treea726e33fbaa0ca7a315a2e12021306fd5b27690e /tpl
parent81ed564793609a32be20a569cc15da2cc02dd734 (diff)
Use Chroma as new default syntax highlighter
If you want to use Pygments, set `pygmentsUseClassic=true` in your site config. Fixes #3888
Diffstat (limited to 'tpl')
-rw-r--r--tpl/collections/collections_test.go6
-rw-r--r--tpl/data/resources_test.go6
-rw-r--r--tpl/transform/transform.go3
-rw-r--r--tpl/transform/transform_test.go7
4 files changed, 18 insertions, 4 deletions
diff --git a/tpl/collections/collections_test.go b/tpl/collections/collections_test.go
index c82d3c3bb..f35e29459 100644
--- a/tpl/collections/collections_test.go
+++ b/tpl/collections/collections_test.go
@@ -776,10 +776,14 @@ type TstX struct {
func newDeps(cfg config.Provider) *deps.Deps {
l := helpers.NewLanguage("en", cfg)
l.Set("i18nDir", "i18n")
+ cs, err := helpers.NewContentSpec(l)
+ if err != nil {
+ panic(err)
+ }
return &deps.Deps{
Cfg: cfg,
Fs: hugofs.NewMem(l),
- ContentSpec: helpers.NewContentSpec(l),
+ ContentSpec: cs,
Log: jww.NewNotepad(jww.LevelError, jww.LevelError, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime),
}
}
diff --git a/tpl/data/resources_test.go b/tpl/data/resources_test.go
index de83f771d..f0b027955 100644
--- a/tpl/data/resources_test.go
+++ b/tpl/data/resources_test.go
@@ -166,9 +166,13 @@ func TestScpGetRemoteParallel(t *testing.T) {
func newDeps(cfg config.Provider) *deps.Deps {
l := helpers.NewLanguage("en", cfg)
l.Set("i18nDir", "i18n")
+ cs, err := helpers.NewContentSpec(l)
+ if err != nil {
+ panic(err)
+ }
return &deps.Deps{
Cfg: cfg,
Fs: hugofs.NewMem(l),
- ContentSpec: helpers.NewContentSpec(l),
+ ContentSpec: cs,
}
}
diff --git a/tpl/transform/transform.go b/tpl/transform/transform.go
index 8d404f5a7..f1ffa77ae 100644
--- a/tpl/transform/transform.go
+++ b/tpl/transform/transform.go
@@ -55,7 +55,8 @@ func (ns *Namespace) Highlight(s interface{}, lang, opts string) (template.HTML,
return "", err
}
- return template.HTML(helpers.Highlight(ns.deps.Cfg, html.UnescapeString(ss), lang, opts)), nil
+ highlighted, _ := ns.deps.ContentSpec.Highlight(html.UnescapeString(ss), lang, opts)
+ return template.HTML(highlighted), nil
}
// HTMLEscape returns a copy of s with reserved HTML characters escaped.
diff --git a/tpl/transform/transform_test.go b/tpl/transform/transform_test.go
index 5fb80c236..429b206fd 100644
--- a/tpl/transform/transform_test.go
+++ b/tpl/transform/transform_test.go
@@ -226,9 +226,14 @@ func TestPlainify(t *testing.T) {
func newDeps(cfg config.Provider) *deps.Deps {
l := helpers.NewLanguage("en", cfg)
l.Set("i18nDir", "i18n")
+ cs, err := helpers.NewContentSpec(l)
+ if err != nil {
+ panic(err)
+ }
+
return &deps.Deps{
Cfg: cfg,
Fs: hugofs.NewMem(l),
- ContentSpec: helpers.NewContentSpec(l),
+ ContentSpec: cs,
}
}