Skip to content

Commit

Permalink
Add support for comments after section headers (closes sharkdp#1259)
Browse files Browse the repository at this point in the history
There's no canonical definition of what's the INI syntax, but Python's `ConfigParser` supports comments after section headers:

```ini
[section] ; comment
```
  • Loading branch information
YtvwlD authored and sharkdp committed Oct 6, 2020
1 parent aa205c6 commit 5e0b7f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The following files have been manually modified after converting from a `.tmLang

* `Apache.sublime_syntax`=> removed `.conf` and `.CONF` file types.
* `Dart.sublime-syntax` => removed `#regex.dart` include.
* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types.
* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types and support for comments after section headers
* `Org mode.sublime-syntax` => removed `task` file type.
* `SML.sublime_syntax` => removed `ml` file type.

Expand Down
3 changes: 2 additions & 1 deletion assets/syntaxes/02_Extra/INI.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ contexts:
scope: comment.line.semicolon.ini
captures:
1: punctuation.definition.comment.ini
- match: '^\s*(\[)(.*?)(\])'
- match: '^\s*(\[)(.*?)(\])\s*(;.*)?$\n?'
scope: meta.tag.section.ini
captures:
1: punctuation.definition.section.ini
2: entity.section.ini
3: punctuation.definition.section.ini
4: comment.definition.section.ini
- match: '^(\s*(["'']?)(.+?)(\2)\s*(=))?\s*((["'']?)(.*?)(\7))\s*(;.*)?$\n?'
scope: meta.declaration.ini
captures:
Expand Down

0 comments on commit 5e0b7f0

Please sign in to comment.