I have updated and checked the syntax highlighting of AppArmor with various improvements.
Changes in AppArmor:
- AppArmor 2.13: adds "if exists" in Include rules. Ex: #include if exists <path>. Previously, the text after "include" was highlighted as "Error", that is corrected.
- Fix: allow spaces in relative paths, in Include rules.
- Fix escape characters: add decimals (\dNNN) and only valid octales are highlighted (the maximum value is \400). Any character is also highlighted as escape (literal characters). Before, only special characters are highlighted.
- Improves the detection of paths that start with a variable. For example, when writing a variable and then a non-ASCII character, it is highlighted as path (Ex: @{VAR}ñpath*).
- Improve variable assignment lines:
- Add line continuation escape.
- Allow assignment (= or +=) in a new line.
- Removes unnecessary rules in _variable_assignment_line_content context. Now the entire line is highlighted as path.
- Improve the highlighting of Hats/Sub-profiles (name//HAT). Add hats in quoted paths and transition profile names (before it was only highlighted in paths). The itemData "SubProfile" changes to "SubProfile/Hat".
- Improve comments: underlines URLs and e-mails.
- Add extensions snap.*, snap-update-ns.* & snap-confine.* (these are the prefixes of the AppArmor profiles for the Snap packages. Some are located in "/var/lib/snapd/apparmor").
- Add some filesystems, new abstractions and "xattrs" flag (keywords).
- Add paths that start with namespaces: :namespace:/path.
- Fixes globbing brackets in quoted text. Now the bracket content allows spaces and line breaks.
- Fix the escape of "/" in profile name and transition profile name (before, it is highlighted as path).
- Simplifies the closing of rules (comma of end of rules).
- The code to detect variables & booleans is simplified.
- Fix booleans: true & false keywords are insensitive; booleans will not be highlighted within rules.
- The operators "in" & "to" are put in a different context (_operators_keywords). Now these are only highlighted within the AppArmor-rules.
- Removes unnecessary RegExpr rules in the path detection. Now only the "/" character marks the beginning of a path.
- The special character "^" is only highlighted at the beginning of the square bracket. Ex: [^ ...]
- Improves the highlighting of numerical units in rlimit rules (a word boundary is added at the beginning if there is no number before).
- Unnecessary attributes are deleted in ItemData's (Ex: underline=0, italic=0)
- Some itemData have bad names ("Globbing Char 1", "Globbing Char 2", "Globbing Char 3"), so these change their name.
- Globbing brackets change in style, from "dsSpecialString" to "dsVerbatimString", since in the "Normal" scheme the red color is more discreet than the orange color.
- Removes unnecessary insensitive attributes in some rules.
In the file I also made some minor modifications to order the code and it is less chaotic, since the file is very large.
I have tested the file enough and I can say that it works well.
Any inconvenience (such as adding extensions) do not hesitate to notify!