mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-02 09:58:29 +02:00
markdown: dont emit ansi sequences when not emitting to tty (#491)
Allows generating a plain text version of an issue (i.e. without colors and other terminal formatting) when storing stdout in a file. ``` tea issue --comments 1 > issue1.txt ``` `IsInteractive()` had to be moved to avoid a recursive import chain. --- In the future, it would be nice to also respect the `--output` flag. This flag is currently designed for tabular output, but we could add more supported values like `markdown` `ansi`, `plain` to it Co-authored-by: Norwin <git@nroo.de> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/491 Reviewed-by: 6543 <6543@obermui.de> Reviewed-by: delvh <dev.lh@web.de>
This commit is contained in:
@ -16,8 +16,15 @@ 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
|
||||
if IsInteractive() {
|
||||
styleOption = glamour.WithAutoStyle()
|
||||
} else {
|
||||
styleOption = glamour.WithStandardStyle("notty")
|
||||
}
|
||||
|
||||
renderer, err := glamour.NewTermRenderer(
|
||||
glamour.WithAutoStyle(),
|
||||
styleOption,
|
||||
glamour.WithBaseURL(baseURL),
|
||||
glamour.WithPreservedNewLines(),
|
||||
glamour.WithWordWrap(getWordWrap()),
|
||||
|
Reference in New Issue
Block a user