diff options
Diffstat (limited to 'markup/highlight/highlight.go')
-rw-r--r-- | markup/highlight/highlight.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/markup/highlight/highlight.go b/markup/highlight/highlight.go index 9e26aaf84..2bd77af0b 100644 --- a/markup/highlight/highlight.go +++ b/markup/highlight/highlight.go @@ -15,6 +15,7 @@ package highlight import ( "fmt" + gohtml "html" "io" "strings" @@ -63,7 +64,7 @@ func highlight(code, lang string, cfg Config) (string, error) { if lexer == nil { wrapper := getPreWrapper(lang) fmt.Fprint(w, wrapper.Start(true, "")) - fmt.Fprint(w, code) + fmt.Fprint(w, gohtml.EscapeString(code)) fmt.Fprint(w, wrapper.End(true)) return w.String(), nil } @@ -72,6 +73,7 @@ func highlight(code, lang string, cfg Config) (string, error) { if style == nil { style = styles.Fallback } + lexer = chroma.Coalesce(lexer) iterator, err := lexer.Tokenise(nil, code) if err != nil { |