aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeuerfuchs <git@feuerfuchs.dev>2020-01-18 11:12:14 +0100
committerFeuerfuchs <git@feuerfuchs.dev>2020-01-18 11:12:14 +0100
commit8879a6bd7c82d7cdb61ee8a293ee26490ed53e4e (patch)
tree15fc9dec744aeb9906f6ad5d949bcb7b83313c95
parentAdd more box characters to fonts (diff)
downloadgopherproxy-8879a6bd7c82d7cdb61ee8a293ee26490ed53e4e.tar.gz
gopherproxy-8879a6bd7c82d7cdb61ee8a293ee26490ed53e4e.tar.bz2
gopherproxy-8879a6bd7c82d7cdb61ee8a293ee26490ed53e4e.zip
Remove ANSI SGR sequences from Gemini docs
-rw-r--r--gopherproxy/gopherproxy.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/gopherproxy/gopherproxy.go b/gopherproxy/gopherproxy.go
index 4a7d972..453ee9c 100644
--- a/gopherproxy/gopherproxy.go
+++ b/gopherproxy/gopherproxy.go
@@ -29,6 +29,10 @@ import (
29 "github.com/temoto/robotstxt" 29 "github.com/temoto/robotstxt"
30) 30)
31 31
32var (
33 TermEscapeSGRPattern = regexp.MustCompile("\\[\\d+(;\\d+)*m")
34)
35
32const ( 36const (
33 ITEM_TYPE_GEMINI_LINE = "" 37 ITEM_TYPE_GEMINI_LINE = ""
34 ITEM_TYPE_GEMINI_LINK = " =>" 38 ITEM_TYPE_GEMINI_LINK = " =>"
@@ -177,6 +181,7 @@ func parseGeminiDocument(body *bytes.Buffer, uri string, hostport string) (items
177 181
178 for scanner.Scan() { 182 for scanner.Scan() {
179 line := strings.Trim(scanner.Text(), "\r\n") 183 line := strings.Trim(scanner.Text(), "\r\n")
184 line = TermEscapeSGRPattern.ReplaceAllString(line, "")
180 185
181 item := Item{ 186 item := Item{
182 Type: ITEM_TYPE_GEMINI_LINE, 187 Type: ITEM_TYPE_GEMINI_LINE,