HEX
Server: LiteSpeed
System: Linux s3604.bom1.stableserver.net 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User: dmstechonline (1480)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/dmstechonline/whatsapp.dmstech.online/node_modules/highlight.js/lib/languages/leaf.js
/*
Language: Leaf
Description: A Swift-based templating language created for the Vapor project.
Website: https://docs.vapor.codes/leaf/overview
Category: template
*/

function leaf(hljs) {
  const IDENT = /([A-Za-z_][A-Za-z_0-9]*)?/;
  const LITERALS = [
    'true',
    'false',
    'in'
  ];
  const PARAMS = {
    scope: 'params',
    begin: /\(/,
    end: /\)(?=\:?)/,
    endsParent: true,
    relevance: 7,
    contains: [
      {
        scope: 'string',
        begin: '"',
        end: '"'
      },
      {
        scope: 'keyword',
        match: LITERALS.join("|"),
      },
      {
        scope: 'variable',
        match: /[A-Za-z_][A-Za-z_0-9]*/
      },
      {
        scope: 'operator',
        match: /\+|\-|\*|\/|\%|\=\=|\=|\!|\>|\<|\&\&|\|\|/
      }
    ]
  };
  const INSIDE_DISPATCH = {
    match: [
      IDENT,
      /(?=\()/,
    ],
    scope: {
      1: "keyword"
    },
    contains: [ PARAMS ]
  };
  PARAMS.contains.unshift(INSIDE_DISPATCH);
  return {
    name: 'Leaf',
    contains: [
      // #ident():
      {
        match: [
          /#+/,
          IDENT,
          /(?=\()/,
        ],
        scope: {
          1: "punctuation",
          2: "keyword"
        },
        // will start up after the ending `)` match from line ~44
        // just to grab the trailing `:` if we can match it
        starts: {
          contains: [
            {
              match: /\:/,
              scope: "punctuation"
            }
          ]
        },
        contains: [
          PARAMS
        ],
      },
      // #ident or #ident:
      {
        match: [
          /#+/,
          IDENT,
          /:?/,
        ],
        scope: {
          1: "punctuation",
          2: "keyword",
          3: "punctuation"
        }
      },
    ]
  };
}

module.exports = leaf;