Skip to content

Commit

Permalink
Keyman: Regexp optimisation + don't use captures if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Oct 22, 2017
1 parent 12684c0 commit 9726087
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions components/prism-keyman.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Prism.languages.keyman = {
'comment': /\bc\s.*/i,
'function': /\[\s*((CTRL|SHIFT|ALT|LCTRL|RCTRL|LALT|RALT|CAPS|NCAPS)\s+)*([TKU]_[a-z0-9_?]+|".+?"|'.+?')\s*\]/i, // virtual key
'string': /("|')((?!\1).)*\1/,
'function': /\[\s*(?:(?:CTRL|SHIFT|ALT|LCTRL|RCTRL|LALT|RALT|CAPS|NCAPS)\s+)*(?:[TKU]_[\w?]+|".+?"|'.+?')\s*\]/i, // virtual key
'string': /("|').*?\1/,
'bold': [ // header statements, system stores and variable system stores
/&(baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embedjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i,
/\b(bitmap|bitmaps|caps on only|caps always off|shift frees caps|copyright|hotkey|language|layout|message|name|version)\b/i
/&(?:baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embedjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i,
/\b(?:bitmap|bitmaps|caps on only|caps always off|shift frees caps|copyright|hotkey|language|layout|message|name|version)\b/i
],
'keyword': /\b(any|baselayout|beep|call|context|deadkey|dk|if|index|layer|notany|nul|outs|platform|return|reset|save|set|store|use)\b/i, // rule keywords
'atrule': /\b(ansi|begin|unicode|group|using keys|match|nomatch)\b/i, // structural keywords
'number': /\b(U\+[\dA-F]+|d\d+|x[\da-f]+|\d+)\b/i, // U+####, x###, d### characters and numbers
'keyword': /\b(?:any|baselayout|beep|call|context|deadkey|dk|if|index|layer|notany|nul|outs|platform|return|reset|save|set|store|use)\b/i, // rule keywords
'atrule': /\b(?:ansi|begin|unicode|group|using keys|match|nomatch)\b/i, // structural keywords
'number': /\b(?:U\+[\dA-F]+|d\d+|x[\da-f]+|\d+)\b/i, // U+####, x###, d### characters and numbers
'operator': /[+>\\,()]/,
'tag': /\$(keyman|kmfl|weaver|keymanweb|keymanonly):/i // prefixes
'tag': /\$(?:keyman|kmfl|weaver|keymanweb|keymanonly):/i // prefixes
};
2 changes: 1 addition & 1 deletion components/prism-keyman.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9726087

Please sign in to comment.