on master help sign in
Highlight C code in all man pages sections
41e857eKeith Hall
assets/syntaxes/02_Extra/Manpage.sublime-syntax+5−1
@@ -83,6 +83,7 @@ contexts:
83 - match: ''
83 - match: ''
84 pop: true
84 pop: true
85 - include: function-call
85 - include: function-call
86+ - include: c-code
86
87
87 expect-command-line-option:
88 expect-command-line-option:
88 - match: '[A-Za-z0-9-]+'
89 - match: '[A-Za-z0-9-]+'
@@ -127,9 +128,12 @@ contexts:
127 - match: '$|(?=[],]|{{command_line_option}})'
128 - match: '$|(?=[],]|{{command_line_option}})'
128 pop: true
129 pop: true
129
130
130− synopsis:
131+ c-code:
131 - match: '^(?=\s+(?:#include|/\*))'
132 - match: '^(?=\s+(?:#include|/\*))'
132 push: scope:source.c
133 push: scope:source.c
134+
135+ synopsis:
136+ - include: c-code
133 - match: \[
137 - match: \[
134 scope: punctuation.section.brackets.begin.man
138 scope: punctuation.section.brackets.begin.man
135 push: command-line-option-or-pipe
139 push: command-line-option-or-pipe
assets/syntaxes/02_Extra/syntax_test_man.man+4
@@ -123,3 +123,7 @@ OPTIONS
123# ^^^ variable.parameter
123# ^^^ variable.parameter
124# ^^ - variable
124# ^^ - variable
125 output NUM (default 3) lines of copied context
125 output NUM (default 3) lines of copied context
126+
127+EXAMPLE
128+ #include <stdio.h>
129+# ^^^^^^^^ source meta.preprocessor.include keyword.control.import.include
tests/syntax-tests/highlighted/Manpage/bat-0.16.man+27−27
@@ -1,7 +1,7 @@
1−BAT(1) General Commands Manual BAT(1)
1+BAT(1) General Commands Manual BAT(1)
2
2
3NAME
3NAME
4− bat - a cat(1) clone with syntax highlighting and Git integration.
4+ bat - a cat(1) clone with syntax highlighting and Git integration.
5
5
6USAGE
6USAGE
7 bat [OPTIONS] [FILE]...
7 bat [OPTIONS] [FILE]...
@@ -28,19 +28,19 @@
28 values can be specified as either '--language value', '--lan‐
28 values can be specified as either '--language value', '--lan‐
29 guage=value', '-l value' or '-lvalue'.
29 guage=value', '-l value' or '-lvalue'.
30
30
31− -A, --show-all
31+ -A, --show-all
32
32
33 Show non-printable characters like space, tab or newline. Use
33 Show non-printable characters like space, tab or newline. Use
34 '--tabs' to control the width of the tab-placeholders.
34 '--tabs' to control the width of the tab-placeholders.
35
35
36− -p, --plain
36+ -p, --plain
37
37
38 Only show plain style, no decorations. This is an alias for
38 Only show plain style, no decorations. This is an alias for
39− '--style=plain'. When '-p' is used twice ('-pp'), it also dis‐
39+ '--style=plain'. When '-p' is used twice ('-pp'), it also dis‐
40 ables automatic paging (alias for '--style=plain
40 ables automatic paging (alias for '--style=plain
41− --pager=never').
41+ --pager=never').
42
42
43− -l, --language <language>
43+ -l, --language <language>
44
44
45 Explicitly set the language for syntax highlighting. The lan‐
45 Explicitly set the language for syntax highlighting. The lan‐
46 guage can be specified as a name (like 'C++' or 'LaTeX') or pos‐
46 guage can be specified as a name (like 'C++' or 'LaTeX') or pos‐
@@ -65,54 +65,54 @@
65 --highlight-line 40:
65 --highlight-line 40:
66 highlights lines 40 to the end of the file
66 highlights lines 40 to the end of the file
67
67
68− --tabs <T>
68+ --tabs <T>
69
69
70 Set the tab width to T spaces. Use a width of 0 to pass tabs
70 Set the tab width to T spaces. Use a width of 0 to pass tabs
71 through directly
71 through directly
72
72
73− --wrap <mode>
73+ --wrap <mode>
74
74
75 Specify the text-wrapping mode (*auto*, never, character). The
75 Specify the text-wrapping mode (*auto*, never, character). The
76 '--terminal-width' option can be used in addition to control the
76 '--terminal-width' option can be used in addition to control the
77 output width.
77 output width.
78
78
79− --terminal-width <width>
79+ --terminal-width <width>
80
80
81 Explicitly set the width of the terminal instead of determining
81 Explicitly set the width of the terminal instead of determining
82 it automatically. If prefixed with '+' or '-', the value will be
82 it automatically. If prefixed with '+' or '-', the value will be
83 treated as an offset to the actual terminal width. See also:
83 treated as an offset to the actual terminal width. See also:
84 '--wrap'.
84 '--wrap'.
85
85
86− -n, --number
86+ -n, --number
87
87
88 Only show line numbers, no other decorations. This is an alias
88 Only show line numbers, no other decorations. This is an alias
89− for '--style=numbers'
89+ for '--style=numbers'
90
90
91− --color <when>
91+ --color <when>
92
92
93 Specify when to use colored output. The automatic mode only en‐
93 Specify when to use colored output. The automatic mode only en‐
94 ables colors if an interactive terminal is detected. Possible
94 ables colors if an interactive terminal is detected. Possible
95 values: *auto*, never, always.
95 values: *auto*, never, always.
96
96
97− --italic-text <when>
97+ --italic-text <when>
98
98
99 Specify when to use ANSI sequences for italic text in the out‐
99 Specify when to use ANSI sequences for italic text in the out‐
100 put. Possible values: always, *never*.
100 put. Possible values: always, *never*.
101
101
102− --decorations <when>
102+ --decorations <when>
103
103
104 Specify when to use the decorations that have been specified via
104 Specify when to use the decorations that have been specified via
105 '--style'. The automatic mode only enables decorations if an in‐
105 '--style'. The automatic mode only enables decorations if an in‐
106 teractive terminal is detected. Possible values: *auto*, never,
106 teractive terminal is detected. Possible values: *auto*, never,
107 always.
107 always.
108
108
109− -f, --force-colorization
109+ -f, --force-colorization
110
110
111− Alias for '--decorations=always --color=always'. This is useful
111+ Alias for '--decorations=always --color=always'. This is useful
112 if the output of bat is piped to another program, but you want
112 if the output of bat is piped to another program, but you want
113 to keep the colorization/decorations.
113 to keep the colorization/decorations.
114
114
115− --paging <when>
115+ --paging <when>
116
116
117 Specify when to use the pager. To disable the pager, use '--pag‐
117 Specify when to use the pager. To disable the pager, use '--pag‐
118 ing=never' or its alias, -P. To disable the pager permanently,
118 ing=never' or its alias, -P. To disable the pager permanently,
@@ -120,7 +120,7 @@
120 used, see the '--pager' option. Possible values: *auto*, never,
120 used, see the '--pager' option. Possible values: *auto*, never,
121 always.
121 always.
122
122
123− --pager <command>
123+ --pager <command>
124
124
125 Determine which pager is used. This option will override the
125 Determine which pager is used. This option will override the
126 PAGER and BAT_PAGER environment variables. The default pager is
126 PAGER and BAT_PAGER environment variables. The default pager is
@@ -135,24 +135,24 @@
135 '*.build:Python'. To highlight files named '.myignore' with the
135 '*.build:Python'. To highlight files named '.myignore' with the
136 Git Ignore syntax, use -m '.myignore:Git Ignore'.
136 Git Ignore syntax, use -m '.myignore:Git Ignore'.
137
137
138− --theme <theme>
138+ --theme <theme>
139
139
140 Set the theme for syntax highlighting. Use '--list-themes' to
140 Set the theme for syntax highlighting. Use '--list-themes' to
141 see all available themes. To set a default theme, add the
141 see all available themes. To set a default theme, add the
142− '--theme="..."' option to the configuration file or export the
142+ '--theme="..."' option to the configuration file or export the
143 BAT_THEME environment variable (e.g.: export BAT_THEME="...").
143 BAT_THEME environment variable (e.g.: export BAT_THEME="...").
144
144
145 --list-themes
145 --list-themes
146
146
147 Display a list of supported themes for syntax highlighting.
147 Display a list of supported themes for syntax highlighting.
148
148
149− --style <style-components>
149+ --style <style-components>
150
150
151 Configure which elements (line numbers, file headers, grid bor‐
151 Configure which elements (line numbers, file headers, grid bor‐
152 ders, Git modifications, ..) to display in addition to the file
152 ders, Git modifications, ..) to display in addition to the file
153 contents. The argument is a comma-separated list of components
153 contents. The argument is a comma-separated list of components
154 to display (e.g. 'numbers,changes,grid') or a pre-defined style
154 to display (e.g. 'numbers,changes,grid') or a pre-defined style
155− ('full'). To set a default style, add the '--style=".."' option
155+ ('full'). To set a default style, add the '--style=".."' option
156 to the configuration file or export the BAT_STYLE environment
156 to the configuration file or export the BAT_STYLE environment
157 variable (e.g.: export BAT_STYLE=".."). Possible values: *auto*,
157 variable (e.g.: export BAT_STYLE=".."). Possible values: *auto*,
158 full, plain, changes, header, grid, numbers, snip.
158 full, plain, changes, header, grid, numbers, snip.
@@ -171,21 +171,21 @@
171 --line-range 40:
171 --line-range 40:
172 prints lines 40 to the end of the file
172 prints lines 40 to the end of the file
173
173
174− -L, --list-languages
174+ -L, --list-languages
175
175
176 Display a list of supported languages for syntax highlighting.
176 Display a list of supported languages for syntax highlighting.
177
177
178− -u, --unbuffered
178+ -u, --unbuffered
179
179
180 This option exists for POSIX-compliance reasons ('u' is for 'un‐
180 This option exists for POSIX-compliance reasons ('u' is for 'un‐
181 buffered'). The output is always unbuffered - this option is
181 buffered'). The output is always unbuffered - this option is
182 simply ignored.
182 simply ignored.
183
183
184− -h, --help
184+ -h, --help
185
185
186 Print this help message.
186 Print this help message.
187
187
188− -V, --version
188+ -V, --version
189
189
190 Show version information.
190 Show version information.
191
191
tests/syntax-tests/highlighted/Manpage/select-2.man+1−1
@@ -1,4 +1,4 @@
1−SELECT(2) Linux Programmer's Manual SELECT(2)
1+SELECT(2) Linux Programmer's Manual SELECT(2)
2
2
3NAME
3NAME
4 select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - synchronous I/O multiplexing
4 select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - synchronous I/O multiplexing