mirror of
https://github.com/rwinkhart/go-highlite.git
synced 2026-08-28 04:46:30 -04:00
- Revised code example
- Added new lexers and revised existing
This commit is contained in:
@@ -27,6 +27,7 @@ func main() {
|
||||
syn_dir = gopath + "/src/github.com/jessp01/highlight/syntax_files"
|
||||
}
|
||||
|
||||
syn_dir = os.Getenv("SYNDIR")
|
||||
var defs []*highlight.Def
|
||||
err := highlight.ParseSyntaxFiles (syn_dir, &defs)
|
||||
if err != nil {
|
||||
|
||||
+3
-3
@@ -9,9 +9,9 @@ func DetectFiletype(defs []*Def, filename string, firstLine []byte) *Def {
|
||||
return d
|
||||
}
|
||||
if len(d.ftdetect) > 1 {
|
||||
if d.ftdetect[1].MatchString(string(firstLine)) {
|
||||
return d
|
||||
}
|
||||
if d.ftdetect[1].MatchString(string(firstLine)) {
|
||||
return d
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
filetype: apacheconf
|
||||
|
||||
detect:
|
||||
filename: "httpd\\.conf|mime\\.types|vhosts\\.d\\\\*|\\.htaccess"
|
||||
filename: "httpd\\.conf|apache.*\\.conf|mime\\.types|vhosts\\.d\\\\*|\\.htaccess"
|
||||
|
||||
rules:
|
||||
- identifier: "(AcceptMutex|AcceptPathInfo|AccessFileName|Action|AddAlt|AddAltByEncoding|AddAltByType|AddCharset|AddDefaultCharset|AddDescription|AddEncoding)"
|
||||
|
||||
@@ -2,9 +2,11 @@ filetype: c
|
||||
|
||||
detect:
|
||||
filename: "(\\.(c|C)$|\\.(h|H)$|\\.ii?$|\\.(def)$)"
|
||||
header: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
|
||||
|
||||
rules:
|
||||
- identifier: "\\b[A-Z_][0-9A-Z_]+\\b"
|
||||
- statement: "([a-zA-Z][a-zA-Z0-9_]*)[[:space:]]*\\("
|
||||
- type: "\\b(float|double|char|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\\b"
|
||||
- type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b"
|
||||
- type.extended: "\\b(bool)\\b"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
filetype: diff
|
||||
|
||||
detect:
|
||||
filename: "\\.diff$"
|
||||
header: "^((---.*)|(\\+\\+\\+.*))"
|
||||
|
||||
rules:
|
||||
- statement: "(^\\+\\+\\+.*)"
|
||||
- statement: "(^---.*)"
|
||||
- type: "(^@@.*)"
|
||||
- constant.number: "(^\\+.*)"
|
||||
- preproc: "(^-.*)"
|
||||
@@ -0,0 +1,18 @@
|
||||
filetype: dpkg
|
||||
|
||||
detect:
|
||||
filename: "\\.dpkg$"
|
||||
header: "(^[D|+].*)"
|
||||
|
||||
rules:
|
||||
- constant.number: "(^[D|+].*)"
|
||||
- preproc: "[0-9]+,?[0-9]*"
|
||||
- preproc: "\\\\."
|
||||
- preproc: "^(un.*)"
|
||||
- constant: "^(ii.*)"
|
||||
- comment: "^(rc.*)"
|
||||
- type: "(i386|i486|i586|i686|amd64|\\<none\\>|athlon|ia64|alpha|alphaev5|alphaev56|alphapca56|alphaev6|alphaev67|sparc|sparcv9|sparc64armv3l|armv4b|armv4lm|ips|mipsel|ppc|iseries|ppcpseries|ppc64|m68k|m68kmint|Sgi|rs6000|i370|s390x|s390|noarch)"
|
||||
- comment: "(^|[[:space:]])#([^{].*)?$"
|
||||
- preproc: "[[:space:]]+$"
|
||||
- indent-char: " + +| + +"
|
||||
- statement: "[[:space:]]([0-9~:.]{2,}[-+:.0-9a-z~]+)[[:space:]]"
|
||||
@@ -1,7 +1,8 @@
|
||||
filetype: php
|
||||
|
||||
detect:
|
||||
filename: "\\.php[2345s~]?$"
|
||||
filename: "\\.php[2345s~]|\\.inc[2345s~]$"
|
||||
header: "^(<\\?php)"
|
||||
|
||||
rules:
|
||||
- symbol.operator: "<|>"
|
||||
|
||||
@@ -2,6 +2,7 @@ filetype: pc
|
||||
|
||||
detect:
|
||||
filename: "\\.pc$"
|
||||
header: "^(prefix|exec_prefix|libdir|includedir)="
|
||||
|
||||
rules:
|
||||
- preproc: "^(Name|Description|URL|Version|Conflicts|Cflags):"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
filetype: serverlog
|
||||
|
||||
detect:
|
||||
filename: "httpd.*\\.log||vhosts\\\\.*\\.log|apache.*\\.log|nginx.*\\.log"
|
||||
|
||||
rules:
|
||||
- constant.number: "(\\[[^]]+\\])"
|
||||
- preproc: "([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})"
|
||||
- preproc: "\\\\."
|
||||
- preproc: "(\\[(error|warning|info|warn)\\])"
|
||||
- constant.specialChar: "((GET|POST|HEAD)\\ [^\\ ]+)"
|
||||
- comment: "(referer\\: .*)"
|
||||
- statement: "[[:space:]]([0-9~:.]{2,}[-+:.0-9a-z~]+)[[:space:]]"
|
||||
- type: "(Mozilla|Chrome|Safari|AppleWebKit|Linux x86_64|Gecko|Windows|Mac)"
|
||||
|
||||
Reference in New Issue
Block a user