Beispiel #1
0
func convert(filename string, w io.Writer, lexer, theme, format string) error {
	f, err := os.Open(filename)
	if err != nil {
		return err
	}
	defer f.Close()
	if lexer == "" {
		lexer = filename
	}
	return beni.Highlight(f, w, lexer, theme, format)
}
Beispiel #2
0
func convertStdIn(o CLOptions) {
	lexer := o.Lexer
	theme := o.Theme
	format := o.Formatter

	if lexer == "" {
		lexer = "Go"
	}

	if theme == "" {
		theme = "base16"
	}

	if format == "" {
		format = "Terminal256"
	}

	stdin := bufio.NewReader(os.Stdin)
	stdout := bufio.NewWriter(os.Stdout)
	defer stdout.Flush()

	beni.Highlight(stdin, stdout, lexer, theme, format)
	return
}