l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

autohotkey.js (2142B)


      1 /*
      2 Language: AutoHotkey
      3 Author: Seongwon Lee <dlimpid@gmail.com>
      4 Description: AutoHotkey language definition
      5 Category: scripting
      6 */
      7 
      8 /** @type LanguageFn */
      9 function autohotkey(hljs) {
     10   var BACKTICK_ESCAPE = {
     11     begin: '`[\\s\\S]'
     12   };
     13 
     14   return {
     15     name: 'AutoHotkey',
     16     case_insensitive: true,
     17     aliases: ['ahk'],
     18     keywords: {
     19       keyword: 'Break Continue Critical Exit ExitApp Gosub Goto New OnExit Pause return SetBatchLines SetTimer Suspend Thread Throw Until ahk_id ahk_class ahk_pid ahk_exe ahk_group',
     20       literal: 'true false NOT AND OR',
     21       built_in: 'ComSpec Clipboard ClipboardAll ErrorLevel',
     22     },
     23     contains: [
     24       BACKTICK_ESCAPE,
     25       hljs.inherit(hljs.QUOTE_STRING_MODE, {contains: [BACKTICK_ESCAPE]}),
     26       hljs.COMMENT(';', '$', {relevance: 0}),
     27       hljs.C_BLOCK_COMMENT_MODE,
     28       {
     29         className: 'number',
     30         begin: hljs.NUMBER_RE,
     31         relevance: 0
     32       },
     33       {
     34         className: 'variable', //subst would be the most accurate however fails the point of highlighting. variable is comparably the most accurate that actually has some effect
     35         begin: '%[a-zA-Z0-9#_$@]+%'
     36       },
     37       {
     38         className: 'built_in',
     39         begin: '^\\s*\\w+\\s*(,|%)'
     40         //I don't really know if this is totally relevant
     41       },
     42       {
     43         className: 'title', //symbol would be most accurate however is highlighted just like built_in and that makes up a lot of AutoHotkey code
     44 		                        //meaning that it would fail to highlight anything
     45         variants: [
     46           {begin: '^[^\\n";]+::(?!=)'},
     47           {begin: '^[^\\n";]+:(?!=)', relevance: 0} // zero relevance as it catches a lot of things
     48                                                     // followed by a single ':' in many languages
     49         ]
     50       },
     51       {
     52         className: 'meta',
     53         begin: '^\\s*#\\w+', end:'$',
     54         relevance: 0
     55       },
     56 	    {
     57         className: 'built_in',
     58         begin: 'A_[a-zA-Z0-9]+'
     59       },
     60       {
     61         // consecutive commas, not for highlighting but just for relevance
     62         begin: ',\\s*,'
     63       }
     64     ]
     65   }
     66 }
     67 
     68 module.exports = autohotkey;