Enable custom color themes with the GLAMOUR_STYLE environment variable
This commit is contained in:
parent
78124a9716
commit
90f04d4864
3 changed files with 14 additions and 15 deletions
|
|
@ -23,18 +23,18 @@ func OpenInBrowser(url string) error {
|
|||
}
|
||||
|
||||
func RenderMarkdown(text string) (string, error) {
|
||||
style := "notty"
|
||||
// TODO: make color an input parameter
|
||||
if isColorEnabled() {
|
||||
style = "auto"
|
||||
}
|
||||
|
||||
// Glamour rendering preserves carriage return characters in code blocks, but
|
||||
// we need to ensure that no such characters are present in the output.
|
||||
text = strings.ReplaceAll(text, "\r\n", "\n")
|
||||
|
||||
renderStyle := glamour.WithStandardStyle("notty")
|
||||
// TODO: make color an input parameter
|
||||
if isColorEnabled() {
|
||||
renderStyle = glamour.WithEnvironmentConfig()
|
||||
}
|
||||
|
||||
tr, err := glamour.NewTermRenderer(
|
||||
glamour.WithStandardStyle(style),
|
||||
renderStyle,
|
||||
// glamour.WithBaseURL(""), // TODO: make configurable
|
||||
// glamour.WithWordWrap(80), // TODO: make configurable
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue