mirror of
https://github.com/rwinkhart/go-highlite.git
synced 2026-09-01 14:47:13 -04:00
Add badges to readme
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
# Highlight
|
||||
[](https://goreportcard.com/report/github.com/zyedidia/highlight)
|
||||
[](http://godoc.org/github.com/zyedidia/highlight)
|
||||
[](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.
|
||||
|
||||
@@ -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
@@ -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++ {
|
||||
|
||||
Reference in New Issue
Block a user