summaryrefslogtreecommitdiffstats
path: root/kate/data/rpmspec.xml
blob: dc21ca3b5e075a2fe50fc78010af0ea0e706d31e (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd" [
  <!ENTITY a_valid_char_in_macro_names "A-Za-z0-9_">
]>
<language name="RPM Spec" version="1.4" kateversion="2.4" section="Other" extensions="*.spec" mimetype="" license="public domain">

  <highlighting>
    
    <contexts>
      <context attribute="Normal Text" lineEndContext="#stay" name="Normal">
        <!-- Handle tags: -->
        <RegExpr attribute="Tag" context="tag_line" String="((Name|Summary|Summary\(.*\)|Version|Epoch|Serial|Release|Group|Copyright|License|Icon|Vendor|Distribution|Packager|Url|URL|Prefix|Conflicts|Obsoletes|Provides|AutoReqProv|PreReq|Requires|Requires\(.*\)|Enhances|Suggests|Recommends|BuildArch|BuildArchitectures|BuildConflicts|BuildRequires|BuildRoot|ExclusiveArch|ExclusiveOs|ExcludeArch|ExcludeOs|Source\d*|Nosource|Patch\d*|Nopatch)[ \t]*:)" column="0" />
        <!-- Handle % -->
        <AnyChar context="handle_percent" String="%$" lookAhead="true" />
        <!-- Handle comments. "# norootforbuild" is displayed like a tag. -->
        <DetectChar context="Comment" char="#" column="0" lookAhead="true" />
      </context>
      
      <context attribute="Normal Text" lineEndContext="#stay" name="command section">
        <!-- Handle % -->
        <AnyChar context="handle_percent" String="%$" lookAhead="true" />
        <!-- Handle comments. "# norootforbuild" is displayed like a tag. -->
        <DetectChar context="Comment" char="#" column="0" lookAhead="true" />
      </context>
      
      <context attribute="Normal Text" lineEndContext="#stay" name="changelog section">
        <Detect2Chars attribute="Value" context="tag_line" char="-" char1=" " column="0" />
        <Detect2Chars attribute="Tag" context="changelog_header" char="*" char1=" " column="0" />
        <!-- Handle comments. "# norootforbuild" is displayed like a tag. -->
        <DetectChar context="Comment" char="#" column="0" lookAhead="true" />
        <!-- Handle % -->
        <AnyChar context="handle_percent" String="%$" lookAhead="true" />
      </context>
      
      <context attribute="Normal" lineEndContext="description section" name="description section start line">
        <!-- Handle % -->
        <AnyChar context="handle_percent" String="%$" lookAhead="true" />
      </context>
      
      <context attribute="Value" lineEndContext="#stay" name="description section">
        <!-- Handle % -->
        <AnyChar context="handle_percent" String="%$" lookAhead="true" />
        <!-- Handle comments. "# norootforbuild" is displayed like a tag. -->
        <DetectChar context="Comment" char="#" column="0" lookAhead="true" />
      </context>

      <context attribute="Comment" lineEndContext="#pop" name="Comment">
        <StringDetect attribute="Tag" context="every_non_whitespace_is_error" String="# norootforbuild" column="0" />
        <!-- Error on single percent ("%"), but not on double percent ("%%"): -->
        <Detect2Chars attribute="Comment" char="%" char1="%"/>
        <DetectChar attribute="Error" char="%"/>
        <!-- Alert on "TODO" -->
        <StringDetect attribute="Alert" String="TODO" insensitive="true" />
        <StringDetect attribute="Alert" String="FIXME" insensitive="true" />
      </context>
      
      <context attribute="Normal Text" lineEndContext="#pop" name="every_non_whitespace_is_error">
        <RegExpr attribute="Error" context="#stay" String="[^\s]" />
      </context>
      
      <context attribute="Value" lineEndContext="#pop" name="tag_line">
        <!-- Handle % -->
        <AnyChar context="handle_percent" String="%$" lookAhead="true" />
      </context>
      
      <context attribute="Tag" lineEndContext="#pop" name="changelog_header">
        <!-- Handle % -->
        <AnyChar context="handle_percent" String="%$" lookAhead="true" />
      </context>
      
      <context attribute="Normal Text" lineEndContext="#pop" name="parameters after keyword">
        <!-- Handle % -->
        <AnyChar context="handle_percent" String="%$" lookAhead="true" />
      </context>
      
      <!-- Expects a string starting with % or $ (otherwise, this context will fail!). -->
      <context lineEndContext="#pop" name="handle_percent">
        <Detect2Chars attribute="Escaped character" context="#pop" char="%" char1="%"/>
        <!-- Keywords: -->
        <RegExpr attribute="Keyword" context="parameters after keyword" String="%(if|ifarch|ifnarch|ifos|ifnos)(?=($| |\t))" column="0" beginRegion="if_block" />
        <RegExpr attribute="Keyword" context="every_non_whitespace_is_error" String="%else(?=($| |\t))" column="0" />
        <RegExpr attribute="Keyword" context="every_non_whitespace_is_error" String="%endif(?=($| |\t))" column="0" endRegion="if_block" />
        <RegExpr attribute="Keyword" context="parameters after keyword" String="%(define|global|undefine)(?=($| |\t))" column="0" />
        <!-- If a command section starts (=section macro at begin of the line), we switch
             to the corresponding context. There will never be a return to THIS context...: -->
        <RegExpr attribute="Section" context="Normal" String="%package(?=($| |\t))" column="0" />
        <RegExpr attribute="Section" context="description section start line" String="%description(?=($| |\t))" column="0" />
        <RegExpr attribute="Section" context="command section" String="%(prep|build|pre|preun|install|post|postun|clean|files|trigger|triggerin|triggerun|triggerpostun|verifyscript)(?=($| |\t))" column="0" />
        <RegExpr attribute="Section" context="changelog section" String="%changelog(?=($| |\t))" column="0" />
        <!-- Handle normal macros -->
        <RegExpr attribute="Error" context="#pop" String="%([\{\(][ \t]{0,}){0,1}(if|ifarch|ifnarch|ifos|ifnos|else|endif|define|global|undefine|package|description|prep|build|pre|preun|install|post|postun|clean|files|trigger|triggerin|triggerun|triggerpostun|verifyscript|changelog)(?=($|[^&a_valid_char_in_macro_names;]))" />
        <RegExpr attribute="Macro call" context="macro content in parenthesis" String="%[&a_valid_char_in_macro_names;]*\(" />
        <RegExpr attribute="Macro call" context="macro content in braces" String="(%|\$)\{" />
        <RegExpr attribute="Macro call" context="#pop" String="(%|\$)([&a_valid_char_in_macro_names;]{1,}|\*|\#)(?=($|[^&a_valid_char_in_macro_names;]))" /> <!-- ')' and '}' are only allowed as macro terminator in the lookahead because when you do something like %__make %{?jobs:-j %jobs}, then the "%jobs" is a valid macro. However, the disadvantage is that a line like "%abc} isn't marked as error. But it is to complicate to distinguish this properly. -->
        <RegExpr attribute="Error" context="#pop" String="(%|\$)([&a_valid_char_in_macro_names;]{1,}|\*|\#)" />
        <AnyChar attribute="Error" context="#pop" String="%$" /> <!-- a single % or $ is also an error -->
      </context>
      
      <context attribute="Macro call" lineEndContext="#pop#pop" name="macro content in parenthesis">
        <!-- Handle % -->
        <AnyChar context="handle_percent" String="%$" lookAhead="true" />
        <DetectChar attribute="Macro call" context="#pop#pop" char=")" />
        <AnyChar attribute="Error" context="#stay" String="({}" />
      </context>
      
      <context attribute="Macro call" lineEndContext="#pop#pop" name="macro content in braces">
        <DetectChar attribute="Macro call" context="#pop#pop" char="}" />
        <AnyChar attribute="Error" context="#stay" String="({)" />
        <!-- Handle % -->
        <AnyChar context="handle_percent" String="%$" lookAhead="true" />
      </context>

    </contexts>
    
    <itemDatas>
      <itemData name="Normal Text" defStyleNum="dsNormal"/>
      <itemData name="Keyword"  defStyleNum="dsKeyword"/>
      <itemData name="Comment"  defStyleNum="dsComment"/>
      <itemData name="Tag" defStyleNum="dsDataType"/>
      <itemData name="Value"  defStyleNum="dsDecVal"/>
      <itemData name="Error" defStyleNum="dsError"/>
      <itemData name="Macro call" defStyleNum="dsFunction"/>
      <itemData name="Section" defStyleNum="dsRegionMarker"/>
      <itemData name="Alert" defStyleNum="dsAlert"/>
      <itemData name="Escaped character" defStyleNum="dsChar"/>
    </itemDatas>
    
  </highlighting>
  
  <general>
    <keywords casesensitive="1" />
  </general>
  
</language>