source: node_modules/refractor/lang/jq.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 2.0 KB
Line 
1'use strict'
2
3module.exports = jq
4jq.displayName = 'jq'
5jq.aliases = []
6function jq(Prism) {
7 ;(function (Prism) {
8 var interpolation = /\\\((?:[^()]|\([^()]*\))*\)/.source
9 var string = RegExp(
10 /(^|[^\\])"(?:[^"\r\n\\]|\\[^\r\n(]|__)*"/.source.replace(
11 /__/g,
12 function () {
13 return interpolation
14 }
15 )
16 )
17 var stringInterpolation = {
18 interpolation: {
19 pattern: RegExp(/((?:^|[^\\])(?:\\{2})*)/.source + interpolation),
20 lookbehind: true,
21 inside: {
22 content: {
23 pattern: /^(\\\()[\s\S]+(?=\)$)/,
24 lookbehind: true,
25 inside: null // see below
26 },
27 punctuation: /^\\\(|\)$/
28 }
29 }
30 }
31 var jq = (Prism.languages.jq = {
32 comment: /#.*/,
33 property: {
34 pattern: RegExp(string.source + /(?=\s*:(?!:))/.source),
35 lookbehind: true,
36 greedy: true,
37 inside: stringInterpolation
38 },
39 string: {
40 pattern: string,
41 lookbehind: true,
42 greedy: true,
43 inside: stringInterpolation
44 },
45 function: {
46 pattern: /(\bdef\s+)[a-z_]\w+/i,
47 lookbehind: true
48 },
49 variable: /\B\$\w+/,
50 'property-literal': {
51 pattern: /\b[a-z_]\w*(?=\s*:(?!:))/i,
52 alias: 'property'
53 },
54 keyword:
55 /\b(?:as|break|catch|def|elif|else|end|foreach|if|import|include|label|module|modulemeta|null|reduce|then|try|while)\b/,
56 boolean: /\b(?:false|true)\b/,
57 number: /(?:\b\d+\.|\B\.)?\b\d+(?:[eE][+-]?\d+)?\b/,
58 operator: [
59 {
60 pattern: /\|=?/,
61 alias: 'pipe'
62 },
63 /\.\.|[!=<>]?=|\?\/\/|\/\/=?|[-+*/%]=?|[<>?]|\b(?:and|not|or)\b/
64 ],
65 'c-style-function': {
66 pattern: /\b[a-z_]\w*(?=\s*\()/i,
67 alias: 'function'
68 },
69 punctuation: /::|[()\[\]{},:;]|\.(?=\s*[\[\w$])/,
70 dot: {
71 pattern: /\./,
72 alias: 'important'
73 }
74 })
75 stringInterpolation.interpolation.inside.content.inside = jq
76 })(Prism)
77}
Note: See TracBrowser for help on using the repository browser.