Skip to content

Commit

Permalink
Fix Manpage C highlighting regression
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-hall authored and sharkdp committed Oct 17, 2020
1 parent 3539d3e commit 575888d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
15 changes: 13 additions & 2 deletions assets/syntaxes/02_Extra/Manpage.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ contexts:
scope: entity.name.command-line-option.man
- match: '(\[)(=)'
captures:
1: punctuation.section.brackets.begin.man
2: keyword.operator.man
push: expect-parameter
push: [command-line-option-or-pipe, expect-parameter]
- match: '\['
push:
- meta_scope: entity.name.command-line-option.man
Expand All @@ -112,13 +113,23 @@ contexts:
expect-parameter:
- match: '[A-Za-z0-9-]+'
scope: variable.parameter.man
- match: (?=\s+\|)
pop: true
- match: \|
scope: keyword.operator.logical.man
- match: '\['
scope: punctuation.section.brackets.begin.man
push:
- match: '\]'
scope: punctuation.section.brackets.end.man
pop: true
- include: expect-parameter
- match: '$|(?=[],]|{{command_line_option}})'
pop: true

synopsis:
#- include: scope:source.c
- match: '^(?=\s+(?:#include|/\*))'
push: scope:source.c
- match: \[
scope: punctuation.section.brackets.begin.man
push: command-line-option-or-pipe
Expand Down
22 changes: 22 additions & 0 deletions assets/syntaxes/02_Extra/syntax_test_man.man
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,35 @@ SYNOPSIS
# ^ punctuation.section.brackets.begin
# ^^^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.section.brackets.end
[-u | --set-upstream] [-o <string> | --push-option=<string>]
# ^ punctuation.section.brackets.begin
# ^^ entity.name.command-line-option
# ^ keyword.operator.logical
# ^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.section.brackets.end
# ^^^^^^^^^^^^^ entity.name.command-line-option
[--force-with-lease[=<refname>[:<expect>]]]
# ^ punctuation.section.brackets.begin
# ^^^^^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.section.brackets.begin
# ^ keyword.operator
# ^^^^^^^ variable.parameter
# ^ punctuation.section.brackets.begin
# ^^^^^^ variable.parameter
# ^^^ punctuation.section.brackets.end

example --system [options]
# ^^^^^^^^ entity.name

COMMON OPTIONS
[--quiet] [--debug] [--help|-h] [--version] [--conf FILE]

/* According to POSIX.1-2001, POSIX.1-2008 */
# ^^ source comment.block punctuation.definition.comment
#include <sys/select.h>
# ^^^^^^^^ source meta.preprocessor.include keyword.control.import.include


DESCRIPTION
example does something useful in relation to the command line options
and configuration information in /etc/example.conf.
Expand Down
2 changes: 1 addition & 1 deletion tests/syntax-tests/highlighted/Manpage/select-2.man
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[38;2;190;132;255mSELECT[0m[38;2;249;38;114m([0m[38;2;230;219;116m2[0m[38;2;249;38;114m)[0m[38;2;248;248;242m Linux Programmer's Manual [0m[38;2;190;132;255mSELECT[0m[38;2;249;38;114m([0m[38;2;230;219;116m2[0m[38;2;249;38;114m)[0m
[38;2;190;132;255mSELECT[0m[38;2;249;38;114m([0m[38;2;230;219;116m2[0m[38;2;249;38;114m)[0m[38;2;248;248;242m [0m[38;2;253;151;31mLinux[0m[38;2;253;151;31m [0m[38;2;253;151;31mProgrammer's[0m[38;2;253;151;31m [0m[38;2;253;151;31mManual[0m[38;2;248;248;242m [0m[38;2;190;132;255mSELECT[0m[38;2;249;38;114m([0m[38;2;230;219;116m2[0m[38;2;249;38;114m)[0m

NAME
 select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - synchronous I/O multiplexing
Expand Down

0 comments on commit 575888d

Please sign in to comment.