mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
@@ -15,7 +15,6 @@ package helpers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"html"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/config"
|
"github.com/gohugoio/hugo/config"
|
||||||
@@ -36,7 +35,7 @@ type HugoHTMLRenderer struct {
|
|||||||
func (r *HugoHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) {
|
func (r *HugoHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) {
|
||||||
if r.Cfg.GetBool("pygmentsCodeFences") && (lang != "" || r.Cfg.GetBool("pygmentsCodeFencesGuessSyntax")) {
|
if r.Cfg.GetBool("pygmentsCodeFences") && (lang != "" || r.Cfg.GetBool("pygmentsCodeFencesGuessSyntax")) {
|
||||||
opts := r.Cfg.GetString("pygmentsOptions")
|
opts := r.Cfg.GetString("pygmentsOptions")
|
||||||
str := strings.Trim(html.UnescapeString(string(text)), "\n\r")
|
str := strings.Trim(string(text), "\n\r")
|
||||||
highlighted, _ := r.cs.Highlight(str, lang, opts)
|
highlighted, _ := r.cs.Highlight(str, lang, opts)
|
||||||
out.WriteString(highlighted)
|
out.WriteString(highlighted)
|
||||||
} else {
|
} else {
|
||||||
@@ -100,7 +99,7 @@ type HugoMmarkHTMLRenderer struct {
|
|||||||
// Pygments is used if it is setup to handle code fences.
|
// Pygments is used if it is setup to handle code fences.
|
||||||
func (r *HugoMmarkHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string, caption []byte, subfigure bool, callouts bool) {
|
func (r *HugoMmarkHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string, caption []byte, subfigure bool, callouts bool) {
|
||||||
if r.Cfg.GetBool("pygmentsCodeFences") && (lang != "" || r.Cfg.GetBool("pygmentsCodeFencesGuessSyntax")) {
|
if r.Cfg.GetBool("pygmentsCodeFences") && (lang != "" || r.Cfg.GetBool("pygmentsCodeFencesGuessSyntax")) {
|
||||||
str := strings.Trim(html.UnescapeString(string(text)), "\n\r")
|
str := strings.Trim(string(text), "\n\r")
|
||||||
highlighted, _ := r.cs.Highlight(str, lang, "")
|
highlighted, _ := r.cs.Highlight(str, lang, "")
|
||||||
out.WriteString(highlighted)
|
out.WriteString(highlighted)
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user