l0bsterssg

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

lua.js (3015B)


      1 /*
      2 Language: Lua
      3 Description: Lua is a powerful, efficient, lightweight, embeddable scripting language.
      4 Author: Andrew Fedorov <dmmdrs@mail.ru>
      5 Category: common, scripting
      6 Website: https://www.lua.org
      7 */
      8 
      9 function lua(hljs) {
     10   var OPENING_LONG_BRACKET = '\\[=*\\[';
     11   var CLOSING_LONG_BRACKET = '\\]=*\\]';
     12   var LONG_BRACKETS = {
     13     begin: OPENING_LONG_BRACKET, end: CLOSING_LONG_BRACKET,
     14     contains: ['self']
     15   };
     16   var COMMENTS = [
     17     hljs.COMMENT('--(?!' + OPENING_LONG_BRACKET + ')', '$'),
     18     hljs.COMMENT(
     19       '--' + OPENING_LONG_BRACKET,
     20       CLOSING_LONG_BRACKET,
     21       {
     22         contains: [LONG_BRACKETS],
     23         relevance: 10
     24       }
     25     )
     26   ];
     27   return {
     28     name: 'Lua',
     29     keywords: {
     30       $pattern: hljs.UNDERSCORE_IDENT_RE,
     31       literal: "true false nil",
     32       keyword: "and break do else elseif end for goto if in local not or repeat return then until while",
     33       built_in:
     34         //Metatags and globals:
     35         '_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len ' +
     36         '__gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert ' +
     37         //Standard methods and properties:
     38         'collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring ' +
     39         'module next pairs pcall print rawequal rawget rawset require select setfenv ' +
     40         'setmetatable tonumber tostring type unpack xpcall arg self ' +
     41         //Library methods and properties (one line per library):
     42         'coroutine resume yield status wrap create running debug getupvalue ' +
     43         'debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv ' +
     44         'io lines write close flush open output type read stderr stdin input stdout popen tmpfile ' +
     45         'math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan ' +
     46         'os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall ' +
     47         'string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower ' +
     48         'table setn insert getn foreachi maxn foreach concat sort remove'
     49     },
     50     contains: COMMENTS.concat([
     51       {
     52         className: 'function',
     53         beginKeywords: 'function', end: '\\)',
     54         contains: [
     55           hljs.inherit(hljs.TITLE_MODE, {begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*'}),
     56           {
     57             className: 'params',
     58             begin: '\\(', endsWithParent: true,
     59             contains: COMMENTS
     60           }
     61         ].concat(COMMENTS)
     62       },
     63       hljs.C_NUMBER_MODE,
     64       hljs.APOS_STRING_MODE,
     65       hljs.QUOTE_STRING_MODE,
     66       {
     67         className: 'string',
     68         begin: OPENING_LONG_BRACKET, end: CLOSING_LONG_BRACKET,
     69         contains: [LONG_BRACKETS],
     70         relevance: 5
     71       }
     72     ])
     73   };
     74 }
     75 
     76 module.exports = lua;