Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-09-25 09:59:02 +0300
committerGitHub <noreply@github.com>2017-09-25 09:59:02 +0300
commitfb33d8286d78a78a74deb44355b621852a1c4033 (patch)
treea726e33fbaa0ca7a315a2e12021306fd5b27690e /tpl/transform
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/transform')
-rw-r--r--tpl/transform/transform.go3
-rw-r--r--tpl/transform/transform_test.go7
2 files changed, 8 insertions, 2 deletions
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,
}
}