mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-22 08:04:18 +02:00
Disable syntax highlighting when output is no terminal
This commit is contained in:
parent
959958d280
commit
501f4e3b6a
1 changed files with 7 additions and 6 deletions
13
gold.go
13
gold.go
|
|
@ -433,18 +433,19 @@ func (tr *TermRenderer) RenderNode(w io.Writer, node *bf.Node, entering bool) bf
|
|||
|
||||
for _, f := range e.Fragments {
|
||||
if node.Type == bf.CodeBlock {
|
||||
theme := "monokai"
|
||||
theme := ""
|
||||
if rules, ok := tr.style[f.Style]; ok {
|
||||
if len(rules.Theme) > 0 {
|
||||
theme = rules.Theme
|
||||
}
|
||||
}
|
||||
|
||||
err := quick.Highlight(w, f.Token, string(node.CodeBlockData.Info), "terminal16m", theme)
|
||||
if err == nil {
|
||||
continue
|
||||
if len(theme) > 0 {
|
||||
err := quick.Highlight(w, f.Token, string(node.CodeBlockData.Info), "terminal16m", theme)
|
||||
if err == nil {
|
||||
continue
|
||||
}
|
||||
// if chroma failed, render the fragment as text below
|
||||
}
|
||||
// if chroma failed, render the fragment as text below
|
||||
}
|
||||
|
||||
if f.Token == "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue