mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-06 00:47:15 -04:00
Disable syntax highlighting when output is no terminal
This commit is contained in:
@@ -433,18 +433,19 @@ func (tr *TermRenderer) RenderNode(w io.Writer, node *bf.Node, entering bool) bf
|
|||||||
|
|
||||||
for _, f := range e.Fragments {
|
for _, f := range e.Fragments {
|
||||||
if node.Type == bf.CodeBlock {
|
if node.Type == bf.CodeBlock {
|
||||||
theme := "monokai"
|
theme := ""
|
||||||
if rules, ok := tr.style[f.Style]; ok {
|
if rules, ok := tr.style[f.Style]; ok {
|
||||||
if len(rules.Theme) > 0 {
|
if len(rules.Theme) > 0 {
|
||||||
theme = rules.Theme
|
theme = rules.Theme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(theme) > 0 {
|
||||||
err := quick.Highlight(w, f.Token, string(node.CodeBlockData.Info), "terminal16m", theme)
|
err := quick.Highlight(w, f.Token, string(node.CodeBlockData.Info), "terminal16m", theme)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
continue
|
continue
|
||||||
|
}
|
||||||
|
// if chroma failed, render the fragment as text below
|
||||||
}
|
}
|
||||||
// if chroma failed, render the fragment as text below
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.Token == "" {
|
if f.Token == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user