colorcode

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2022 License: MIT Imports: 6 Imported by: 0

README

colorcode

go.dev reference

import (
    cc "bitbucket.org/ai69/colorcode"
)

Documentation

Overview

Package colorcode is a simple wrapper around the alecthomas/chroma package.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Colorize

func Colorize(lexerName, content string) string

Colorize returns a highlighted string for given language and code.

func PrettyJSON

func PrettyJSON(data interface{})

PrettyJSON outputs a pretty-printed JSON string with syntax highlighting.

Example

PrettyJSON illustrates the use of PrettyJSON with immediate data structure.

package main

import (
	"bitbucket.org/ai69/colorcode"
)

func main() {
	type dataSchema struct {
		A string
		B []int
		C map[string]int
		D map[string]interface{}
		E bool
		F float64
		h string
	}
	a := dataSchema{
		A: "hello",
		B: []int{1, 2, 3},
		C: map[string]int{"a": 1, "b": 2},
		D: map[string]interface{}{"a": 1, "b": "<b>Aloha!</b>", "c": []int{1, 2, 3, 4, 5}},
		E: true,
		F: 3.1415926,
		h: "hidden",
	}
	colorcode.PrettyJSON(&a)
}
Output:

func SetTheme

func SetTheme(theme string) error

SetTheme sets the global theme for the colorized output. See Reference: https://xyproto.github.io/splash/docs/

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL