CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
ini.js122 linesDownload Raw Back to languages
1/*2Language: TOML, also INI3Description: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.4Contributors: Guillaume Gomez <guillaume1.gomez@gmail.com>5Category: common, config6Website: https://github.com/toml-lang/toml7*/8 9function ini(hljs) {10  const regex = hljs.regex;11  const NUMBERS = {12    className: 'number',13    relevance: 0,14    variants: [15      { begin: /([+-]+)?[\d]+_[\d_]+/ },16      { begin: hljs.NUMBER_RE }17    ]18  };19  const COMMENTS = hljs.COMMENT();20  COMMENTS.variants = [21    {22      begin: /;/,23      end: /$/24    },25    {26      begin: /#/,27      end: /$/28    }29  ];30  const VARIABLES = {31    className: 'variable',32    variants: [33      { begin: /\$[\w\d"][\w\d_]*/ },34      { begin: /\$\{(.*?)\}/ }35    ]36  };37  const LITERALS = {38    className: 'literal',39    begin: /\bon|off|true|false|yes|no\b/40  };41  const STRINGS = {42    className: "string",43    contains: [ hljs.BACKSLASH_ESCAPE ],44    variants: [45      {46        begin: "'''",47        end: "'''",48        relevance: 1049      },50      {51        begin: '"""',52        end: '"""',53        relevance: 1054      },55      {56        begin: '"',57        end: '"'58      },59      {60        begin: "'",61        end: "'"62      }63    ]64  };65  const ARRAY = {66    begin: /\[/,67    end: /\]/,68    contains: [69      COMMENTS,70      LITERALS,71      VARIABLES,72      STRINGS,73      NUMBERS,74      'self'75    ],76    relevance: 077  };78 79  const BARE_KEY = /[A-Za-z0-9_-]+/;80  const QUOTED_KEY_DOUBLE_QUOTE = /"(\\"|[^"])*"/;81  const QUOTED_KEY_SINGLE_QUOTE = /'[^']*'/;82  const ANY_KEY = regex.either(83    BARE_KEY, QUOTED_KEY_DOUBLE_QUOTE, QUOTED_KEY_SINGLE_QUOTE84  );85  const DOTTED_KEY = regex.concat(86    ANY_KEY, '(\\s*\\.\\s*', ANY_KEY, ')*',87    regex.lookahead(/\s*=\s*[^#\s]/)88  );89 90  return {91    name: 'TOML, also INI',92    aliases: [ 'toml' ],93    case_insensitive: true,94    illegal: /\S/,95    contains: [96      COMMENTS,97      {98        className: 'section',99        begin: /\[+/,100        end: /\]+/101      },102      {103        begin: DOTTED_KEY,104        className: 'attr',105        starts: {106          end: /$/,107          contains: [108            COMMENTS,109            ARRAY,110            LITERALS,111            VARIABLES,112            STRINGS,113            NUMBERS114          ]115        }116      }117    ]118  };119}120 121export { ini as default };122 
basant307/AI_Governance_Project · CoolFace