From d7faef9d8d65413f974211c6abc9ca2103f6c188 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Sun, 26 Mar 2017 19:26:24 -0400 Subject: [PATCH] Update readme --- README.md | 52 +++++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 5bdefbb..971b3d1 100644 --- a/README.md +++ b/README.md @@ -33,20 +33,18 @@ import ( func main() { // Here is the go code we will highlight - inputString := ` -package main + inputString := `package main import "fmt" // A hello world program func main() { fmt.Println("Hello world") -} -` +}` // Load the go syntax file // 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` syntaxDef, err := highlight.ParseDef(syntaxFile) @@ -71,36 +69,32 @@ func main() { // Check if the group changed at the current position if group, ok := matches[lineN][colN]; ok { // Check the group name and set the color accordingly (the colors chosen are arbitrary) - if group == highlight.Groups["statement"] { - color.Set(color.FgGreen) - } else if group == highlight.Groups["identifier"] { - color.Set(color.FgBlue) - } else if group == highlight.Groups["preproc"] { - color.Set(color.FgHiRed) - } else if group == highlight.Groups["special"] { - color.Set(color.FgRed) - } else if group == highlight.Groups["constant.string"] { - color.Set(color.FgCyan) - } else if group == highlight.Groups["constant"] { - color.Set(color.FgCyan) - } else if group == highlight.Groups["constant.specialChar"] { - color.Set(color.FgHiMagenta) - } else if group == highlight.Groups["type"] { - color.Set(color.FgYellow) - } else if group == highlight.Groups["constant.number"] { - color.Set(color.FgCyan) - } else if group == highlight.Groups["comment"] { - color.Set(color.FgHiGreen) - } else { - color.Unset() - } + if group == highlight.Groups["statement"] { + color.Set(color.FgGreen) + } else if group == highlight.Groups["preproc"] { + color.Set(color.FgHiRed) + } else if group == highlight.Groups["special"] { + color.Set(color.FgBlue) + } else if group == highlight.Groups["constant.string"] { + color.Set(color.FgCyan) + } else if group == highlight.Groups["constant.specialChar"] { + color.Set(color.FgHiMagenta) + } else if group == highlight.Groups["type"] { + color.Set(color.FgYellow) + } else if group == highlight.Groups["constant.number"] { + color.Set(color.FgCyan) + } else if group == highlight.Groups["comment"] { + color.Set(color.FgHiGreen) + } else { + color.Unset() + } } // Print the character fmt.Print(string(c)) } // This is at a newline, but highlighting might have been turned off at the very end of the line so we should check that. if group, ok := matches[lineN][len(l)]; ok { - if group == highlight.Groups["default"] || group == highlight.Groups[""] { + if group == highlight.Groups["default"] || group == highlight.Groups[""] { color.Unset() } }