• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mindersec / minder / 15981216547

30 Jun 2025 06:52PM UTC coverage: 57.393% (+0.02%) from 57.377%
15981216547

Pull #5702

github

web-flow
Merge b1a7618c3 into 9b4f171a0
Pull Request #5702: Add templates for REST and YQ eval

57 of 78 new or added lines in 7 files covered. (73.08%)

21 existing lines in 3 files now uncovered.

18593 of 32396 relevant lines covered (57.39%)

37.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.54
/internal/util/cli/markdown.go
1
// SPDX-FileCopyrightText: Copyright 2024 The Minder Authors
2
// SPDX-License-Identifier: Apache-2.0
3

4
package cli
5

6
import (
7
        "os"
8

9
        "github.com/charmbracelet/glamour"
10
        "github.com/charmbracelet/glamour/styles"
11
        "github.com/muesli/termenv"
12
        "golang.org/x/term"
13
)
14

15
// RenderMarkdown renders the given string as markdown.
16
func RenderMarkdown(payload string, opts ...glamour.TermRendererOption) string {
7✔
17
        style := styles.NoTTYStyleConfig
7✔
18
        if term.IsTerminal(int(os.Stdout.Fd())) {
7✔
19
                if termenv.HasDarkBackground() {
×
UNCOV
20
                        style = styles.DarkStyleConfig
×
UNCOV
21
                } else {
×
UNCOV
22
                        style = styles.LightStyleConfig
×
UNCOV
23
                }
×
24
        }
25
        // Remove extra margins from rendering, we can add them in the table
26
        // if we want.
27
        style.Document.Margin = nil
7✔
28
        style.Document.BlockPrefix = ""
7✔
29
        style.Document.BlockSuffix = ""
7✔
30

7✔
31
        allOpts := []glamour.TermRendererOption{
7✔
32
                glamour.WithStyles(style),
7✔
33
                glamour.WithEmoji(),
7✔
34
        }
7✔
35
        allOpts = append(allOpts, opts...)
7✔
36

7✔
37
        r, err := glamour.NewTermRenderer(
7✔
38
                allOpts...,
7✔
39
        )
7✔
40
        // We can't really fail here, but in case we just return the
7✔
41
        // payload as-is.
7✔
42
        if err != nil {
7✔
UNCOV
43
                return payload
×
UNCOV
44
        }
×
45
        rendered, err := r.Render(payload)
7✔
46
        // We don't want to fail rendering when input is not valid
7✔
47
        // markdown, and we just output it as-is instead.
7✔
48
        if err != nil {
7✔
UNCOV
49
                return payload
×
UNCOV
50
        }
×
51
        return rendered
7✔
52
}
53

54
// WidthFraction sets the width of the markdown text to the fraction
55
// of the terminal width (0.0 to 1.0).
UNCOV
56
func WidthFraction(fraction float64) glamour.TermRendererOption {
×
UNCOV
57
        w, _, err := term.GetSize(int(os.Stdout.Fd()))
×
UNCOV
58
        if err != nil || w == 0 {
×
UNCOV
59
                w = 80 // Default width if we can't determine terminal size
×
UNCOV
60
        }
×
UNCOV
61
        return glamour.WithWordWrap(int(float64(w) * fraction))
×
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc