diff options
author | Keith Hall <kingkeith+github@gmail.com> | 2020-10-19 11:24:15 +0300 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2020-10-24 12:30:25 +0200 |
commit | cfdb853ea60e8d6ff3eb56530079447777216d8b (patch) | |
tree | 60c0aa5213df0743bdf6e860d9d5e0ba9ea46287 /assets | |
parent | 41e857ea1650e216932fca057b46fed5566e26a2 (diff) |
End highlighting of C code in man pages when no longer relevant
Diffstat (limited to 'assets')
-rw-r--r-- | assets/syntaxes/02_Extra/Manpage.sublime-syntax | 21 | ||||
-rw-r--r-- | assets/syntaxes/02_Extra/syntax_test_man.man | 30 |
2 files changed, 40 insertions, 11 deletions
diff --git a/assets/syntaxes/02_Extra/Manpage.sublime-syntax b/assets/syntaxes/02_Extra/Manpage.sublime-syntax index 96d1eee8..d721259f 100644 --- a/assets/syntaxes/02_Extra/Manpage.sublime-syntax +++ b/assets/syntaxes/02_Extra/Manpage.sublime-syntax @@ -34,28 +34,30 @@ contexts: scope: markup.heading.title.man - match: \s\s pop: true - - match: '(?=\S)' + - match: '(?=\S|$)' pop: true - match: '$' - push: body + set: body body: # English, ..., ..., ..., Russian, ... - - match: '^(?:SYNOPSIS|SYNTAX|SINTASSI|SKŁADNIA|СИНТАКСИС|書式)' + - match: '^(?:SYNOPSIS|SYNTAX|SINTASSI|SK\u0141ADNIA|\u0421\u0418\u041d\u0422\u0410\u041a\u0421\u0418\u0421|\u66f8\u5f0f)' scope: markup.heading.synopsis.man embed: synopsis escape: '(?={{section_heading}})' + - match: '^(?:USAGE)' + scope: markup.heading.synopsis.man + embed: synopsis + escape: '(?={{section_heading}})' - match: '{{section_heading}}' scope: markup.heading.other.man embed: options # some man pages put command line options under the description heading escape: '(?={{section_heading}})' - - include: function-call - function-call: - match: '\b([A-Za-z0-9_\-]+)(\()([^)]*)(\))' captures: @@ -129,8 +131,12 @@ contexts: pop: true c-code: - - match: '^(?=\s+(?:#include|/\*))' - push: scope:source.c + #- match: '^(\s+)(?=#include\b|#define\b|/\*|struct\s+\w+\s*\{)' + - match: '^(?=\s+(?:#include\b|#define\b|/\*|struct\s+(\w+\s*)?\{))' + embed: scope:source.c + #embed_scope: source.c.embedded.man + #escape: ^(?!#|\1|\s*(?:$|/\*|#include\b|#define\b)) + escape: ^(?=\s*(?:\(.*\.\)\s*$|[A-Z](?![A-Z]))) synopsis: - include: c-code @@ -144,6 +150,7 @@ contexts: captures: 1: keyword.operator.logical.man #- match: (?={{command_line_option}}) + - match: \w+-\w+ - match: (?=-) push: - match: (?=\s*\|) diff --git a/assets/syntaxes/02_Extra/syntax_test_man.man b/assets/syntaxes/02_Extra/syntax_test_man.man index 286f8b37..ee8bada3 100644 --- a/assets/syntaxes/02_Extra/syntax_test_man.man +++ b/assets/syntaxes/02_Extra/syntax_test_man.man @@ -5,7 +5,7 @@ SOMETHING(8) System Manager's Manual SOMETHING(8) # ^^^^^^^ meta.preprocessor NAME -#^^^ markup.heading.title +#^^^ markup.heading.other example - do something useful SYNOPSIS @@ -45,9 +45,16 @@ SYNOPSIS [--quiet] [--debug] [--help|-h] [--version] [--conf FILE] /* According to POSIX.1-2001, POSIX.1-2008 */ -# ^^ source comment.block punctuation.definition.comment +# ^^ source.c comment.block punctuation.definition.comment #include <sys/select.h> -# ^^^^^^^^ source meta.preprocessor.include keyword.control.import.include +# ^^^^^^^^ source.c meta.preprocessor.include keyword.control.import.include + struct timeval { +# ^^^^^^ source.c storage.type + + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ + }; + DESCRIPTION @@ -126,4 +133,19 @@ OPTIONS EXAMPLE #include <stdio.h> -# ^^^^^^^^ source meta.preprocessor.include keyword.control.import.include +# ^^^^^^^^ source.c meta.preprocessor.include keyword.control.import.include + + (This is not C code.) +# ^^^^^^^^^^^^^^^^^^^^^^ - source.c + + struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ + }; +# ^ source.c punctuation.terminator + + The corresponding argument for pselect() has the following type: +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - source.c + #define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN | + EPOLLHUP | EPOLLERR) +# ^ source.c meta.preprocessor.macro meta.group punctuation.section.group.end |