Commit Graph
28 Commits
Author SHA1 Message Date
Jesse Portnoy 524a51e3ce Fixes based on various linter suggestions 2023-08-03 16:13:18 +01:00
Jesse Portnoy 137b073d05 - Add du lexer
- Print problematic YAML filename when error is detected
2023-07-19 22:46:52 +01:00
Jesse Portnoy 99c6e6f45d Skip parsing of empty files 2023-07-19 17:49:47 +01:00
Jesse Portnoy b5d8dddab5 gofmt 2023-07-18 19:30:52 +01:00
Jesse Portnoy 449702f27b - Support df command
- Return warnings array from ParseSyntaxFiles() in addition to potential
  error. Not being able to parse the dir is a fatal error but if a
random file cannot be read, it should be considered a warning.
2023-07-18 18:46:01 +01:00
Jesse Portnoy eb804a2dd6 following gofmt -s 2023-07-17 14:26:19 +01:00
Jesse Portnoy 8969d1f05a . 2023-07-16 17:03:21 +01:00
Jesse Portnoy 8e81b0cb4d Fixes. 2023-07-16 17:01:33 +01:00
Jesse Portnoy 5d44bdc87e Merge branch 'protect-against-a-case-where-rules-are-nil' 2023-07-16 16:38:25 +01:00
Jesse Portnoy 0606b69176 Helper method to parse syntax files 2023-07-16 16:26:54 +01:00
Jesse Portnoy b5b98d2281 In highlightEmptyRegion(), if no rules are defined, return
immediately.

The following snippet will trigger SIGSEGV otherwise:
```go
    syntaxFile, _ := ioutil.ReadFile("/non/existing/path"  + "yml.yaml")
    syntaxDef, err := highlight.ParseDef(syntaxFile)
    if err != nil {
        return err
    }
    h := highlight.NewHighlighter(syntaxDef)
    matches := h.HighlightString(string(codeBlock.Literal))
```

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x574656]

goroutine 1 [running]:
github.com/zyedidia/highlight.(*Highlighter).highlightEmptyRegion(0xc000129b98, 0xc0000db980?, 0x0, 0x1, 0x0?, {0xc0001880b0, 0x2a, 0x2c}, 0x0)
	/home/jesse/go/pkg/mod/github.com/zyedidia/highlight@v0.0.0-20200217010119-291680feaca1/highlighter.go:215 +0x96
github.com/zyedidia/highlight.(*Highlighter).HighlightString(0xc000129b98, {0xc0000db980?, 0x2b?})
	/home/jesse/go/pkg/mod/github.com/zyedidia/highlight@v0.0.0-20200217010119-291680feaca1/highlighter.go:278 +0x130
```
2023-07-16 02:17:04 +01:00
Zachary Yedidia c6faee5e6c Fix region highlighting and skipping
Ref #8
2017-03-30 10:33:52 -04:00
Zachary Yedidia 98b6b4f75e Add support for skipping 2017-03-27 20:47:03 -04:00
Zachary Yedidia 7c0a62e2a4 Improve unicode support 2017-03-27 19:31:14 -04:00
Zachary Yedidia 760b4668b3 Add badges to readme 2017-03-26 20:16:26 -04:00
Zachary Yedidia cb792c0985 Make some types private 2017-03-26 20:09:06 -04:00
Zachary Yedidia 084c2be66c Many optimizations and new syntax files 2017-03-26 19:14:03 -04:00
Zachary Yedidia 56f3992cdb Fix bug with regions 2017-03-16 13:15:05 -04:00
Zachary Yedidia a0ff047911 Minor fixes 2017-02-19 11:35:23 -05:00
Zachary Yedidia 8ad8b71842 Set matches in the input 2017-02-19 11:16:18 -05:00
Zachary Yedidia 6dfc8e081f Improve api 2017-02-18 21:29:17 -05:00
Zachary Yedidia e690c2cd5e Fix highlighting for regions starting in regions 2017-02-18 09:57:16 -05:00
Zachary Yedidia b604855378 Fix bugs in syntax files
Fix various bugs in syntax files.
Add c++ syntax file.
Only save last line's endstate in highlight function.
2017-02-18 09:45:07 -05:00
Zachary Yedidia 52b1507a36 Start optimizations with ReHighlight and add python files 2017-02-16 18:09:02 -05:00
Zachary Yedidia 3b1e96fcda Start optimizations 2017-02-13 16:24:27 -05:00
Zachary Yedidia b45dc4a3b8 Formatting improvements 2017-02-13 16:15:08 -05:00
Zachary Yedidia 2d6c6001b0 Fix region overwriting in combine line match 2017-02-12 13:44:04 -05:00
Zachary Yedidia 5a939241ee Initial commit 2017-02-12 11:21:27 -05:00