aboutsummaryrefslogtreecommitdiffstats
path: root/man.sublime-syntax
blob: e03aa83ede64754784f9050bd937c02f570ee1fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
%YAML 1.2
---
name: Man (*roff)
scope: text.man
file_extensions: \d
first_line_match: ^([.'])TH\b

variables:
  # Requests always have a period (‘.’) or an apostrophe (‘'’)
  # as the first character of the input line.
  cc: ^([.']) # cc - control character
  macro: (TH|SH|SS|TP|LP|PP|P|HP|RS|RE)\b
  numeric: '\b(-)?[0-9.]+\b'
  font_size: (SM|SB)\b
  font_alt: (BI|IB|RI|IR|BR|RB)\b
  font_style: ([BRI])

contexts:
  main:
    - match: (?={{cc}})
      push: macros

    - match: '{{cc}}(?={{font_style}})\b'
      scope: keyword.control.man
      push: font_styles
      with_prototype:
        - match: $
          pop: true

    - match: (\\f){{font_style}}
      captures:
        1: keyword.control.man
        2: constant.character.escape.man

    # Comments begin and finish at the end of the line
    - match: \\["#]
      scope: comment.man
      push:
        - meta_scope: comment.line.man
        - match: $
          pop: true


  macros:
    - match: '{{cc}}{{macro}}'
      scope: keyword.control.man
      push: macros_line
      pop: true

    - match: '{{cc}}\w+\b'
      scope: support.function.groff
      push: macros_line
      pop: true


  macros_line:
    - match: '"'
      scope: punctuation.definition.string.begin.man
      push: string

    - match: '{{numeric}}'
      scope: constant.numeric.man

    - match: \w
      scope: variable.parameter.man

    - match: $
      pop: true


  font_styles:
    - match: B
      scope: keyword.control.man
      push:
        - meta_content_scope: markup.bold.man
    - match: R
      scope: keyword.control.man
    - match: I
      scope: keyword.control.man
      push:
        - meta_content_scope: markup.italic.man


  string:
    - meta_scope: string.quoted.double.man
    - match: '"'
      scope: punctuation.definition.string.end.man
      pop: true