clx-browser

[ACTIVE] a smol browser based off of circumflex
git clone git://git.figbert.com/clx-browser.git
Log | Files | Refs | README | LICENSE

main.go (814B)


      1 package main
      2 
      3 import (
      4 	"os"
      5 	"os/exec"
      6 	"strings"
      7 
      8 	"github.com/charmbracelet/glamour"
      9 )
     10 
     11 func main() {
     12 	url := os.Args[1]
     13 
     14 	title, article := getArticle(url)
     15 
     16 	header := getReaderModeMetaBlock(title, url, 72)
     17 
     18 	renderer, err := glamour.NewTermRenderer(glamour.WithStyles(CLXStyleConfig))
     19 	if err != nil {
     20 		panic(err)
     21 	}
     22 
     23 	markdown, err := renderer.Render(article)
     24 	if err != nil {
     25 		panic(err)
     26 	}
     27 
     28 	renderedArticle := header + markdown
     29 
     30 	command := exec.Command("less",
     31 		"--RAW-CONTROL-CHARS",
     32 		"--ignore-case",
     33 		"--tilde",
     34 		"--use-color",
     35 		"-P?e"+"\u001B[48;5;237m "+"\u001B[38;5;200m"+"E"+"\u001B[38;5;214m"+"n"+"\u001B[38;5;69m"+"d "+"\033[0m",
     36 		"-DSy",
     37 		"-DP-")
     38 	command.Stdin = strings.NewReader(renderedArticle)
     39 	command.Stdout = os.Stdout
     40 
     41 	if err := command.Run(); err != nil {
     42 		panic(err)
     43 	}
     44 }