push
github
0 of 25 new or added lines in 1 file covered. (0.0%)
1156 of 1470 relevant lines covered (78.64%)
290.27 hits per line
1 |
package main
|
|
2 |
|
|
3 |
import (
|
|
4 |
"embed"
|
|
5 |
"fmt"
|
|
6 |
"log"
|
|
7 |
"os"
|
|
8 |
|
|
9 |
"github.com/charmbracelet/glamour"
|
|
10 |
"github.com/muesli/termenv"
|
|
11 |
) |
|
12 |
|
|
13 |
//go:embed artichokes.md
|
|
14 |
var f embed.FS
|
|
15 |
|
|
NEW
|
func main() {
|
× |
NEW
|
// Provide a style by name (optional)
|
× |
NEW
|
var style string |
× |
NEW
|
if len(os.Args) < 2 { |
× |
NEW
|
// check env, if unset then use default style
|
× |
NEW
|
style = os.Getenv("GLAMOUR_STYLE")
|
× |
NEW
|
} else {
|
× |
NEW
|
style = os.Args[1]
|
× |
NEW
|
} |
× |
25 |
|
|
26 |
// Let's learn a 'lil something about artichokes...
|
|
NEW
|
b, err := f.ReadFile("artichokes.md")
|
× |
NEW
|
if err != nil { |
× |
NEW
|
log.Fatal(err) |
× |
NEW
|
} |
× |
31 |
|
|
NEW
|
r, err := glamour.NewTermRenderer( |
× |
NEW
|
glamour.WithStandardStyle(style), |
× |
NEW
|
glamour.WithColorProfile(termenv.TrueColor), |
× |
NEW
|
) |
× |
NEW
|
if err != nil { |
× |
NEW
|
log.Fatal(err) |
× |
NEW
|
} |
× |
NEW
|
md, err := r.RenderBytes(b) |
× |
NEW
|
if err != nil { |
× |
NEW
|
log.Fatal(err) |
× |
NEW
|
} |
× |
43 |
|
|
NEW
|
fmt.Fprintf(os.Stdout, "%s\n", md)
|
× |
45 |
} |