on master help sign in
Add first version of 'man page' syntax, closes #523
commit4ba45e2ba24b84dceeed0da05b371c00638bd931 authorsharkdp <davidpeter@web.de> dateSat 31 Aug 2019, 14:32 (7 years ago) parent7076ae5
2 files changed+55
README.md+11 assets/syntaxes/Manpage.sublime-syntax+44
README.md+11
@@ -132,6 +132,17 @@ bat main.cpp | xclip
132132```
133133`bat` will detect that the output is being redirected and print the plain file contents.
134134
135+#### `man`
136+
137+`bat` can be used as a pager for `man`. It can be used like this:
138+```
139+export MANPAGER="sh -c 'col -b | bat -l man -p'"
140+
141+man 2 select
142+```
143+
144+The [Manpage syntax](assets/syntaxes/Manpage.sublime-syntax) is developed in this repository and still needs some work.
145+
135146## Installation
136147
137148### On Ubuntu
assets/syntaxes/Manpage.sublime-syntaxnew file+44
@@ -0,0 +1,44 @@
1+%YAML 1.2
2+---
3+# http://www.sublimetext.com/docs/3/syntax.html
4+name: Manpage
5+file_extensions:
6+ - man
7+scope: source.man
8+
9+variables:
10+ section_heading: '^\S.*$'
11+
12+contexts:
13+ main:
14+ - match: ^
15+ push: first_line
16+
17+ first_line:
18+ - match: '([A-Z0-9]+)(\()([^)]+)(\))'
19+ captures:
20+ 1: meta.preprocessor
21+ 2: keyword.operator
22+ 3: string.quoted.other
23+ 4: keyword.operator
24+
25+ - match: '$'
26+ push: body
27+
28+ body:
29+ - match: '^(SYNOPSIS|SYNTAX|SINTASSI|SKŁADNIA|СИНТАКСИС|書式)'
30+ push: Packages/C/C.sublime-syntax
31+ scope: markup.heading
32+ with_prototype:
33+ - match: '(?={{section_heading}})'
34+ pop: true
35+
36+ - match: '^\S.*$'
37+ scope: markup.heading
38+
39+ - match: '\b([a-z0-9_]+)(\()([^)]*)(\))'
40+ captures:
41+ 1: entity.name.function
42+ 2: keyword.operator
43+ 3: constant.numeric
44+ 4: keyword.operator