diff options
| author | tjp <tjp@ctrl-c.club> | 2024-01-17 08:55:42 -0700 |
|---|---|---|
| committer | tjp <tjp@ctrl-c.club> | 2024-01-17 08:55:42 -0700 |
| commit | dd2a06c1e1391fe6242015330b7c61fa37fd67cc (patch) | |
| tree | 8b07e964f40f70de898046e5435c8932768f2b21 /handlers.go | |
| parent | dfebc9013b5414e9a3c5f940704e831c31ce35d2 (diff) | |
start of a bubbletea TUI
Diffstat (limited to 'handlers.go')
| -rw-r--r-- | handlers.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/handlers.go b/handlers.go index 64ea5c0..599d53b 100644 --- a/handlers.go +++ b/handlers.go @@ -137,10 +137,10 @@ const ( promptStyle = "\x1b[38;5;39m" quoteStyle = "\x1b[38;5;208m\x1b[3m" rawStyle = "\x1b[38;5;249m" - h1Style = "\x1b[38;5;154m\x1b[1m\x1b[4m" - h2Style = "\x1b[38;5;50m\x1b[4m" - h3Style = "\x1b[38;5;6m\x1b[4m" - listStyle = "\x1b[38;5;3m" + h1Style = "\x1b[38;5;154m\x1b[1m\x1b[4m" + h2Style = "\x1b[38;5;50m\x1b[4m" + h3Style = "\x1b[38;5;6m\x1b[4m" + listStyle = "\x1b[38;5;3m" ) func parseGemtextDoc(body []byte, softWrap int) (string, []Link, error) { @@ -189,7 +189,7 @@ func parseGemtextDoc(body []byte, softWrap int) (string, []Link, error) { i += 1 case gemtext.LineTypeQuote: q := item.(gemtext.QuoteLine) - for _, line := range fold(q.Body(), softWrap - 1) { + for _, line := range fold(q.Body(), softWrap-1) { line = strings.TrimSpace(line) if _, err := b.WriteString(textpad + "> " + quoteStyle + line + ansiClear + "\n"); err != nil { return "", nil, err @@ -219,15 +219,16 @@ func parseGemtextDoc(body []byte, softWrap int) (string, []Link, error) { case 3: color = h3Style } - + for _, line := range fold(item.String(), softWrap) { + line = strings.TrimRight(line, "\r\n") if _, err := b.WriteString(textpad + color + line + ansiClear + "\n"); err != nil { return "", nil, err } } case gemtext.LineTypeListItem: li := item.(gemtext.ListItemLine) - for i, line := range fold(li.Body(), softWrap - 2) { + for i, line := range fold(li.Body(), softWrap-2) { lpad := " " if i == 0 { lpad = "* " |
