Created
September 25, 2017 00:57
-
-
Save gnilchee/344c281a86f8c9f73da72192ecc57bfc to your computer and use it in GitHub Desktop.
Take multiline code in a variable and output to stdout html that has code in syntax highlighted in given format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/alecthomas/chroma/quick" | |
) | |
func main() { | |
my_code := `package main | |
import "fmt" | |
func main() { | |
fmt.Println("Hello, World!") | |
}` | |
err := quick.Highlight(os.Stdout, my_code, "go", "html", "monokai") | |
if err != nil { | |
fmt.Println("There was an issue") | |
os.Exit(1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment