Removed dead code

This commit is contained in:
diamondburned (Forefront) 2020-06-28 16:02:28 -07:00
parent 721b9f0c40
commit 5499788460
2 changed files with 1 additions and 50 deletions

2
go.mod
View File

@ -4,7 +4,7 @@ go 1.14
replace github.com/gotk3/gotk3 => github.com/diamondburned/gotk3 v0.0.0-20200619213419-0533bcce0dd6
// replace github.com/diamondburned/cchat-discord => ../cchat-discord/
replace github.com/diamondburned/cchat-discord => ../cchat-discord/
require (
github.com/Xuanwo/go-locale v0.2.0

View File

@ -3,8 +3,6 @@ package hl
import (
"errors"
"fmt"
"html"
"io"
"strings"
"github.com/alecthomas/chroma"
@ -42,21 +40,6 @@ func Tokenize(language, source string) chroma.Iterator {
return i
}
func Render(w io.Writer, language, source string) {
if i := Tokenize(language, source); i != nil {
fmtter.Format(w, i)
} else {
// Fallback.
w.Write([]byte(source))
}
}
func RenderString(language, source string) string {
var buf strings.Builder
Render(&buf, language, source)
return buf.String()
}
func Segments(appendmap *attrmap.AppendMap, src string, seg text.Codeblocker) {
var start, end = seg.Bounds()
appendmap.Span(start, end, `font_family="monospace"`)
@ -120,38 +103,6 @@ func (f *formatter) segments(appendmap *attrmap.AppendMap, offset int, iter chro
}
}
func (f *formatter) Format(w io.Writer, iterator chroma.Iterator) {
f.reset()
for _, token := range iterator.Tokens() {
var code = strings.Replace(html.EscapeString(token.String()), "\t", " ", -1)
if attr := f.styleAttr(token.Type); attr != "" {
code = fmt.Sprintf(`<span font_family="monospace" %s>%s</span>`, attr, code)
}
w.Write([]byte(code))
}
}
func (f *formatter) shouldHighlight(highlightIndex, line int) (bool, bool) {
var next = false
for highlightIndex < len(f.highlightRanges) && line > f.highlightRanges[highlightIndex][1] {
highlightIndex++
next = true
}
if highlightIndex < len(f.highlightRanges) {
hrange := f.highlightRanges[highlightIndex]
if line >= hrange[0] && line <= hrange[1] {
return true, next
}
}
return false, next
}
func (f *formatter) styleAttr(tt chroma.TokenType) string {
if _, ok := css[tt]; !ok {
tt = tt.SubCategory()