mirror of
https://github.com/rwinkhart/go-highlite.git
synced 2026-09-05 16:37:20 -04:00
Update readme
This commit is contained in:
@@ -33,20 +33,18 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Here is the go code we will highlight
|
// Here is the go code we will highlight
|
||||||
inputString := `
|
inputString := `package main
|
||||||
package main
|
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
// A hello world program
|
// A hello world program
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Println("Hello world")
|
fmt.Println("Hello world")
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
// Load the go syntax file
|
// Load the go syntax file
|
||||||
// Make sure that the syntax_files directory is in the current directory
|
// Make sure that the syntax_files directory is in the current directory
|
||||||
syntaxFile, _ := ioutil.ReadFile("syntax_files/go.yaml")
|
syntaxFile, _ := ioutil.ReadFile("highlight/syntax_files/go.yaml")
|
||||||
|
|
||||||
// Parse it into a `*highlight.Def`
|
// Parse it into a `*highlight.Def`
|
||||||
syntaxDef, err := highlight.ParseDef(syntaxFile)
|
syntaxDef, err := highlight.ParseDef(syntaxFile)
|
||||||
@@ -73,16 +71,12 @@ func main() {
|
|||||||
// Check the group name and set the color accordingly (the colors chosen are arbitrary)
|
// Check the group name and set the color accordingly (the colors chosen are arbitrary)
|
||||||
if group == highlight.Groups["statement"] {
|
if group == highlight.Groups["statement"] {
|
||||||
color.Set(color.FgGreen)
|
color.Set(color.FgGreen)
|
||||||
} else if group == highlight.Groups["identifier"] {
|
|
||||||
color.Set(color.FgBlue)
|
|
||||||
} else if group == highlight.Groups["preproc"] {
|
} else if group == highlight.Groups["preproc"] {
|
||||||
color.Set(color.FgHiRed)
|
color.Set(color.FgHiRed)
|
||||||
} else if group == highlight.Groups["special"] {
|
} else if group == highlight.Groups["special"] {
|
||||||
color.Set(color.FgRed)
|
color.Set(color.FgBlue)
|
||||||
} else if group == highlight.Groups["constant.string"] {
|
} else if group == highlight.Groups["constant.string"] {
|
||||||
color.Set(color.FgCyan)
|
color.Set(color.FgCyan)
|
||||||
} else if group == highlight.Groups["constant"] {
|
|
||||||
color.Set(color.FgCyan)
|
|
||||||
} else if group == highlight.Groups["constant.specialChar"] {
|
} else if group == highlight.Groups["constant.specialChar"] {
|
||||||
color.Set(color.FgHiMagenta)
|
color.Set(color.FgHiMagenta)
|
||||||
} else if group == highlight.Groups["type"] {
|
} else if group == highlight.Groups["type"] {
|
||||||
|
|||||||
Reference in New Issue
Block a user