mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
Update renderer to match master commit d099812
This commit is contained in:
parent
386b585a41
commit
adb7b379cb
@ -148,11 +148,14 @@ func (ren *GemtextRenderer) renderLine(line string) string {
|
|||||||
if ren.pre {
|
if ren.pre {
|
||||||
if ren.ansiEnabled {
|
if ren.ansiEnabled {
|
||||||
line = cview.TranslateANSI(line)
|
line = cview.TranslateANSI(line)
|
||||||
// The TranslateANSI function injects tags like [-:-:-]
|
// The TranslateANSI function will reset the colors when it encounters
|
||||||
// but this will reset the background to use the user's terminal color.
|
// an ANSI reset code, injecting a full reset tag: [-:-:-]
|
||||||
// These tags need to be replaced with resets that use the theme color.
|
// This uses the default foreground and background colors of the
|
||||||
line = strings.ReplaceAll(line, "[-:-:-]",
|
// application, but in this case we want it to use the preformatted text
|
||||||
fmt.Sprintf("[%s:%s:-]", config.GetColorString("preformatted_text"), config.GetColorString("bg")),
|
// color as the foreground, as we're still in a preformat block.
|
||||||
|
line = strings.ReplaceAll(
|
||||||
|
line, "[-:-:-]",
|
||||||
|
fmt.Sprintf("[%s:-:-]", config.GetColorString("preformatted_text")),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Set color at beginning and end of line to prevent background glitches
|
// Set color at beginning and end of line to prevent background glitches
|
||||||
|
@ -3,12 +3,10 @@ package render
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"code.rocketnine.space/tslocum/cview"
|
"code.rocketnine.space/tslocum/cview"
|
||||||
"github.com/makeworld-the-better-one/amfora/config"
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -166,15 +164,6 @@ func (ren *ANSIRenderer) handler() {
|
|||||||
|
|
||||||
// Shouldn't error because everything it writes to are all bytes.Buffer
|
// Shouldn't error because everything it writes to are all bytes.Buffer
|
||||||
ren.ansiWriter.Write(line) //nolint:errcheck
|
ren.ansiWriter.Write(line) //nolint:errcheck
|
||||||
|
|
||||||
// The ANSIWriter injects tags like [-:-:-]
|
|
||||||
// but this will reset the background to use the user's terminal color.
|
|
||||||
// These tags need to be replaced with resets that use the theme color.
|
|
||||||
line = bytes.ReplaceAll(
|
|
||||||
ren.buf.Bytes(),
|
|
||||||
[]byte("[-:-:-]"),
|
|
||||||
[]byte(fmt.Sprintf("[-:%s:-]", config.GetColorString("bg"))),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ren.readIn.Write(line) //nolint:errcheck
|
ren.readIn.Write(line) //nolint:errcheck
|
||||||
|
Loading…
Reference in New Issue
Block a user