Add badges to readme

This commit is contained in:
Zachary Yedidia
2017-03-26 20:16:26 -04:00
parent 1a97fc1b03
commit 760b4668b3
3 changed files with 10 additions and 4 deletions
+3
View File
@@ -1,4 +1,7 @@
# Highlight
[![Go Report Card](https://goreportcard.com/badge/github.com/zyedidia/highlight)](https://goreportcard.com/report/github.com/zyedidia/highlight)
[![GoDoc](https://godoc.org/github.com/zyedidia/highlight?status.svg)](http://godoc.org/github.com/zyedidia/highlight)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/zyedidia/highlight/blob/master/LICENSE)
This is a package for syntax highlighting a large number of different languages. To see the list of
languages currently supported, see the [`syntax_files`](./syntax_files) directory.
+3
View File
@@ -1,5 +1,8 @@
package highlight
// DetectFiletype will use the list of syntax definitions provided and the filename and first line of the file
// to determine the filetype of the file
// It will return the corresponding syntax definition for the filetype
func DetectFiletype(defs []*Def, filename string, firstLine []byte) *Def {
for _, d := range defs {
if d.ftdetect[0].MatchString(filename) {
+4 -4
View File
@@ -35,13 +35,13 @@ type LineStates interface {
// A Highlighter contains the information needed to highlight a string
type Highlighter struct {
lastRegion *region
def *Def
Def *Def
}
// NewHighlighter returns a new highlighter from the given syntax definition
func NewHighlighter(def *Def) *Highlighter {
h := new(Highlighter)
h.def = def
h.Def = def
return h
}
@@ -178,7 +178,7 @@ func (h *Highlighter) highlightEmptyRegion(highlights LineMatch, start int, canM
firstLoc := []int{len(line), 0}
var firstRegion *region
for _, r := range h.def.rules.regions {
for _, r := range h.Def.rules.regions {
loc := findIndex(r.start, line, start == 0, canMatchEnd)
if loc != nil {
if loc[0] < firstLoc[0] {
@@ -205,7 +205,7 @@ func (h *Highlighter) highlightEmptyRegion(highlights LineMatch, start int, canM
}
fullHighlights := make([]Group, len(line))
for _, p := range h.def.rules.patterns {
for _, p := range h.Def.rules.patterns {
matches := findAllIndex(p.regex, line, start == 0, canMatchEnd)
for _, m := range matches {
for i := m[0]; i < m[1]; i++ {