mirror of
https://gitea.com/gitea/tea.git
synced 2026-03-11 08:13:32 +01:00
Update to charm libraries v2 (#923)
Reviewed-on: https://gitea.com/gitea/tea/pulls/923 Reviewed-by: techknowlogick <9+techknowlogick@noreply.gitea.com> Co-authored-by: Michal Suchanek <msuchanek@suse.de> Co-committed-by: Michal Suchanek <msuchanek@suse.de>
This commit is contained in:
committed by
techknowlogick
parent
3372c9ec59
commit
c797624fcf
@@ -7,7 +7,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/charmbracelet/glamour"
|
||||
"charm.land/glamour/v2"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
@@ -15,19 +15,23 @@ import (
|
||||
// If the input could not be parsed, it is printed unformatted, the error
|
||||
// is returned anyway.
|
||||
func outputMarkdown(markdown string, baseURL string) error {
|
||||
var styleOption glamour.TermRendererOption
|
||||
var renderer *glamour.TermRenderer
|
||||
var err error
|
||||
if IsInteractive() {
|
||||
styleOption = glamour.WithAutoStyle()
|
||||
renderer, err = glamour.NewTermRenderer(
|
||||
glamour.WithBaseURL(baseURL),
|
||||
glamour.WithPreservedNewLines(),
|
||||
glamour.WithWordWrap(getWordWrap()),
|
||||
)
|
||||
} else {
|
||||
styleOption = glamour.WithStandardStyle("notty")
|
||||
renderer, err = glamour.NewTermRenderer(
|
||||
glamour.WithStandardStyle("notty"),
|
||||
glamour.WithBaseURL(baseURL),
|
||||
glamour.WithPreservedNewLines(),
|
||||
glamour.WithWordWrap(getWordWrap()),
|
||||
)
|
||||
}
|
||||
|
||||
renderer, err := glamour.NewTermRenderer(
|
||||
styleOption,
|
||||
glamour.WithBaseURL(baseURL),
|
||||
glamour.WithPreservedNewLines(),
|
||||
glamour.WithWordWrap(getWordWrap()),
|
||||
)
|
||||
if err != nil {
|
||||
fmt.Print(markdown)
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user