Added support for MongoDB syntax (#2518)

This commit is contained in:
Dmitry Eroshenko 2020-08-14 00:00:21 +07:00 committed by GitHub
parent 2da2beba24
commit 004eaa749d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 2495 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -704,6 +704,11 @@
"title": "Mizar",
"owner": "Golmote"
},
"mongodb": {
"title": "MongoDB",
"owner": "airs0urce",
"require": "javascript"
},
"monkey": {
"title": "Monkey",
"owner": "Golmote"

View File

@ -0,0 +1,96 @@
(function (Prism) {
var operators = [
// query and projection
'$eq', '$gt', '$gte', '$in', '$lt', '$lte', '$ne', '$nin', '$and', '$not', '$nor', '$or',
'$exists', '$type', '$expr', '$jsonSchema', '$mod', '$regex', '$text', '$where', '$geoIntersects',
'$geoWithin', '$near', '$nearSphere', '$all', '$elemMatch', '$size', '$bitsAllClear', '$bitsAllSet',
'$bitsAnyClear', '$bitsAnySet', '$comment', '$elemMatch', '$meta', '$slice',
// update
'$currentDate', '$inc', '$min', '$max', '$mul', '$rename', '$set', '$setOnInsert', '$unset',
'$addToSet', '$pop', '$pull', '$push', '$pullAll', '$each', '$position', '$slice', '$sort', '$bit',
// aggregation pipeline stages
'$addFields', '$bucket', '$bucketAuto', '$collStats', '$count', '$currentOp', '$facet', '$geoNear',
'$graphLookup', '$group','$indexStats', '$limit', '$listLocalSessions', '$listSessions', '$lookup',
'$match', '$merge', '$out', '$planCacheStats', '$project', '$redact', '$replaceRoot', '$replaceWith',
'$sample', '$set', '$skip', '$sort', '$sortByCount', '$unionWith', '$unset', '$unwind',
// aggregation pipeline operators
'$abs', '$accumulator', '$acos', '$acosh', '$add', '$addToSet', '$allElementsTrue', '$and',
'$anyElementTrue', '$arrayElemAt', '$arrayToObject', '$asin', '$asinh', '$atan', '$atan2',
'$atanh', '$avg', '$binarySize', '$bsonSize', '$ceil', '$cmp', '$concat', '$concatArrays', '$cond',
'$convert', '$cos', '$dateFromParts', '$dateToParts', '$dateFromString', '$dateToString', '$dayOfMonth',
'$dayOfWeek', '$dayOfYear', '$degreesToRadians', '$divide', '$eq', '$exp', '$filter', '$first',
'$floor', '$function', '$gt', '$gte', '$hour', '$ifNull', '$in', '$indexOfArray', '$indexOfBytes',
'$indexOfCP', '$isArray', '$isNumber', '$isoDayOfWeek', '$isoWeek', '$isoWeekYear', '$last',
'$last', '$let', '$literal', '$ln', '$log', '$log10', '$lt', '$lte', '$ltrim', '$map', '$max',
'$mergeObjects', '$meta', '$min', '$millisecond', '$minute', '$mod', '$month', '$multiply', '$ne',
'$not', '$objectToArray', '$or', '$pow', '$push', '$radiansToDegrees', '$range', '$reduce',
'$regexFind', '$regexFindAll', '$regexMatch', '$replaceOne', '$replaceAll', '$reverseArray', '$round',
'$rtrim', '$second', '$setDifference', '$setEquals', '$setIntersection', '$setIsSubset', '$setUnion',
'$size', '$sin', '$slice', '$split', '$sqrt', '$stdDevPop', '$stdDevSamp', '$strcasecmp', '$strLenBytes',
'$strLenCP', '$substr', '$substrBytes', '$substrCP', '$subtract', '$sum', '$switch', '$tan',
'$toBool', '$toDate', '$toDecimal', '$toDouble', '$toInt', '$toLong', '$toObjectId', '$toString',
'$toLower', '$toUpper', '$trim', '$trunc', '$type', '$week', '$year', '$zip',
// aggregation pipeline query modifiers
'$comment', '$explain', '$hint', '$max', '$maxTimeMS', '$min', '$orderby', '$query',
'$returnKey', '$showDiskLoc', '$natural',
];
var builtinFunctions = [
'ObjectId',
'Code',
'BinData',
'DBRef',
'Timestamp',
'NumberLong',
'NumberDecimal',
'MaxKey',
'MinKey',
'RegExp',
'ISODate',
'UUID',
];
operators = operators.map(function(operator) {
return operator.replace('$', '\\$');
});
var operatorsSource = '(?:' + operators.join('|') + ')\\b';
Prism.languages.mongodb = Prism.languages.extend('javascript', {});
Prism.languages.insertBefore('mongodb', 'string', {
'property': {
pattern: /(?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)(?=\s*:)/,
greedy: true,
inside: {
'keyword': RegExp('^([\'"])?' + operatorsSource + '(?:\\1)?$')
}
}
});
Prism.languages.mongodb.string.inside = {
url: {
// url pattern
pattern: /https?:\/\/[-\w@:%.+~#=]{1,256}\.[a-z0-9()]{1,6}\b[-\w()@:%+.~#?&/=]*/i,
greedy: true
},
entity: {
// ipv4
pattern: /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/,
greedy: true
}
};
Prism.languages.insertBefore('mongodb', 'constant', {
'builtin': {
pattern: RegExp('\\b(?:' + builtinFunctions.join('|') + ')\\b'),
alias: 'keyword'
}
});
}(Prism));

1
components/prism-mongodb.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function($){var e=["$eq","$gt","$gte","$in","$lt","$lte","$ne","$nin","$and","$not","$nor","$or","$exists","$type","$expr","$jsonSchema","$mod","$regex","$text","$where","$geoIntersects","$geoWithin","$near","$nearSphere","$all","$elemMatch","$size","$bitsAllClear","$bitsAllSet","$bitsAnyClear","$bitsAnySet","$comment","$elemMatch","$meta","$slice","$currentDate","$inc","$min","$max","$mul","$rename","$set","$setOnInsert","$unset","$addToSet","$pop","$pull","$push","$pullAll","$each","$position","$slice","$sort","$bit","$addFields","$bucket","$bucketAuto","$collStats","$count","$currentOp","$facet","$geoNear","$graphLookup","$group","$indexStats","$limit","$listLocalSessions","$listSessions","$lookup","$match","$merge","$out","$planCacheStats","$project","$redact","$replaceRoot","$replaceWith","$sample","$set","$skip","$sort","$sortByCount","$unionWith","$unset","$unwind","$abs","$accumulator","$acos","$acosh","$add","$addToSet","$allElementsTrue","$and","$anyElementTrue","$arrayElemAt","$arrayToObject","$asin","$asinh","$atan","$atan2","$atanh","$avg","$binarySize","$bsonSize","$ceil","$cmp","$concat","$concatArrays","$cond","$convert","$cos","$dateFromParts","$dateToParts","$dateFromString","$dateToString","$dayOfMonth","$dayOfWeek","$dayOfYear","$degreesToRadians","$divide","$eq","$exp","$filter","$first","$floor","$function","$gt","$gte","$hour","$ifNull","$in","$indexOfArray","$indexOfBytes","$indexOfCP","$isArray","$isNumber","$isoDayOfWeek","$isoWeek","$isoWeekYear","$last","$last","$let","$literal","$ln","$log","$log10","$lt","$lte","$ltrim","$map","$max","$mergeObjects","$meta","$min","$millisecond","$minute","$mod","$month","$multiply","$ne","$not","$objectToArray","$or","$pow","$push","$radiansToDegrees","$range","$reduce","$regexFind","$regexFindAll","$regexMatch","$replaceOne","$replaceAll","$reverseArray","$round","$rtrim","$second","$setDifference","$setEquals","$setIntersection","$setIsSubset","$setUnion","$size","$sin","$slice","$split","$sqrt","$stdDevPop","$stdDevSamp","$strcasecmp","$strLenBytes","$strLenCP","$substr","$substrBytes","$substrCP","$subtract","$sum","$switch","$tan","$toBool","$toDate","$toDecimal","$toDouble","$toInt","$toLong","$toObjectId","$toString","$toLower","$toUpper","$trim","$trunc","$type","$week","$year","$zip","$comment","$explain","$hint","$max","$maxTimeMS","$min","$orderby","$query","$returnKey","$showDiskLoc","$natural"],t="(?:"+(e=e.map(function($){return $.replace("$","\\$")})).join("|")+")\\b";$.languages.mongodb=$.languages.extend("javascript",{}),$.languages.insertBefore("mongodb","string",{property:{pattern:/(?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)(?=\s*:)/,greedy:!0,inside:{keyword:RegExp("^(['\"])?"+t+"(?:\\1)?$")}}}),$.languages.mongodb.string.inside={url:{pattern:/https?:\/\/[-\w@:%.+~#=]{1,256}\.[a-z0-9()]{1,6}\b[-\w()@:%+.~#?&/=]*/i,greedy:!0},entity:{pattern:/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/,greedy:!0}},$.languages.insertBefore("mongodb","constant",{builtin:{pattern:RegExp("\\b(?:"+["ObjectId","Code","BinData","DBRef","Timestamp","NumberLong","NumberDecimal","MaxKey","MinKey","RegExp","ISODate","UUID"].join("|")+")\\b"),alias:"keyword"}})}(Prism);

View File

@ -0,0 +1,59 @@
<h2>Document</h2>
<pre><code>
{
'_id': ObjectId('5ec72ffe00316be87cab3927'),
'code': Code('function () { return 22; }'),
'binary': BinData(1, '232sa3d323sd232a32sda3s2d3a2s1d23s21d3sa'),
'dbref': DBRef('namespace', ObjectId('5ec72f4200316be87cab3926'), 'db'),
'timestamp': Timestamp(0, 0),
'long': NumberLong(9223372036854775807),
'decimal': NumberDecimal('1000.55'),
'integer': 100,
'maxkey': MaxKey(),
'minkey': MinKey(),
'isodate': ISODate('2012-01-01T00:00:00.000Z'),
'regexp': RegExp('prism(js)?', 'i'),
'string': 'Hello World',
'numberArray': [1, 2, 3],
'stringArray': ['1','2','3'],
'randomKey': null,
'object': { 'a': 1, 'b': 2 },
'max_key2': MaxKey(),
'number': 1234,
'invalid-key': 123,
noQuotesKey: 'value',
}
</code></pre>
<h2>Query</h2>
<pre><code>
db.users.find({
_id: { $nin: ObjectId('5ec72ffe00316be87cab3927') },
age: { $gte: 18, $lte: 99 },
field: { $exists: true }
})
</code></pre>
<h2>Update</h2>
<pre><code>
db.users.updateOne(
{
_id: ObjectId('5ec72ffe00316be87cab3927')
},
{
$set: { age: 30 },
$inc: { updateCount: 1 },
$push: { updateDates: new Date() }
}
)
</code></pre>
<h2>Aggregate</h2>
<pre><code>
db.orders.aggregate([
{ $sort : { age : -1 } },
{ $project : { age : 1, status : 1, name : 1 } },
{ $limit: 5 }
])
</code></pre>

View File

@ -76,6 +76,7 @@
"lilypond": "scheme",
"markdown": "markup",
"markup-templating": "markup",
"mongodb": "javascript",
"n4js": "javascript",
"nginx": "clike",
"objectivec": "c",

View File

@ -1 +1 @@
!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.createElement){var n={javascript:"clike",actionscript:"javascript",arduino:"cpp",aspnet:["markup","csharp"],bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",django:"markup-templating",ejs:["javascript","markup-templating"],etlua:["lua","markup-templating"],erb:["ruby","markup-templating"],fsharp:"clike","firestore-security-rules":"clike",flow:"javascript",ftl:"markup-templating",gml:"clike",glsl:"c",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup-templating",haxe:"clike",hlsl:"c",java:"clike",javadoc:["markup","java","javadoclike"],jolie:"clike",jsdoc:["javascript","javadoclike","typescript"],"js-extras":"javascript",json5:"json",jsonp:"json","js-templates":"javascript",kotlin:"clike",latte:["clike","markup-templating","php"],less:"css",lilypond:"scheme",markdown:"markup","markup-templating":"markup",n4js:"javascript",nginx:"clike",objectivec:"c",opencl:"c",parser:"markup",php:["clike","markup-templating"],phpdoc:["php","javadoclike"],"php-extras":"php",plsql:"sql",processing:"clike",protobuf:"clike",pug:["markup","javascript"],purebasic:"clike",qml:"javascript",qore:"clike",racket:"scheme",jsx:["markup","javascript"],tsx:["jsx","typescript"],reason:"clike",ruby:"clike",sass:"css",scss:"css",scala:"java","shell-session":"bash",smarty:"markup-templating",solidity:"clike",soy:"markup-templating",sparql:"turtle",sqf:"clike",swift:"clike","t4-cs":["t4-templating","csharp"],"t4-vb":["t4-templating","vbnet"],tap:"yaml",tt2:["clike","markup-templating"],textile:"markup",twig:"markup",typescript:"javascript",vala:"clike",vbnet:"basic",velocity:"markup",wiki:"markup",xeora:"markup","xml-doc":"markup",xquery:"markup"},l={html:"markup",xml:"markup",svg:"markup",mathml:"markup",ssml:"markup",atom:"markup",rss:"markup",js:"javascript",g4:"antlr4",adoc:"asciidoc",shell:"bash",shortcode:"bbcode",rbnf:"bnf",cs:"csharp",dotnet:"csharp",coffee:"coffeescript",conc:"concurnas",jinja2:"django","dns-zone":"dns-zone-file",dockerfile:"docker",eta:"ejs",xlsx:"excel-formula",xls:"excel-formula",gamemakerlanguage:"gml",hs:"haskell",gitignore:"ignore",hgignore:"ignore",npmignore:"ignore",webmanifest:"json",kt:"kotlin",kts:"kotlin",tex:"latex",context:"latex",ly:"lilypond",emacs:"lisp",elisp:"lisp","emacs-lisp":"lisp",md:"markdown",moon:"moonscript",n4jsd:"n4js",nani:"naniscript",objc:"objectivec",objectpascal:"pascal",px:"pcaxis",pcode:"peoplecode",pq:"powerquery",mscript:"powerquery",pbfasm:"purebasic",py:"python",rkt:"racket",rpy:"renpy",robot:"robotframework",rb:"ruby",sol:"solidity",sln:"solution-file",rq:"sparql",t4:"t4-cs",trig:"turtle",ts:"typescript",tsconfig:"typoscript",uscript:"unrealscript",uc:"unrealscript",vb:"visual-basic",vba:"visual-basic",xeoracube:"xeora",yml:"yaml"},p={},e="components/",a=Prism.util.currentScript();if(a){var r=/\bplugins\/autoloader\/prism-autoloader\.(?:min\.)js(?:\?[^\r\n/]*)?$/i,t=/(^|\/)[\w-]+\.(?:min\.)js(?:\?[^\r\n/]*)?$/i,i=a.getAttribute("data-autoloader-path");if(null!=i)e=i.trim().replace(/\/?$/,"/");else{var s=a.src;r.test(s)?e=s.replace(r,"components/"):t.test(s)&&(e=s.replace(t,"$1components/"))}}var o=Prism.plugins.autoloader={languages_path:e,use_minified:!0,loadLanguages:m};Prism.hooks.add("complete",function(e){var a=e.element,r=e.language;if(a&&r&&"none"!==r){var t=function(e){var a=(e.getAttribute("data-dependencies")||"").trim();if(!a){var r=e.parentElement;r&&"pre"===r.tagName.toLowerCase()&&(a=(r.getAttribute("data-dependencies")||"").trim())}return a?a.split(/\s*,\s*/g):[]}(a);t.push(r),t.every(u)||m(t,function(){Prism.highlightElement(a)})}})}function u(e){if(0<=e.indexOf("!"))return!1;if((e=l[e]||e)in Prism.languages)return!0;var a=p[e];return a&&!a.error&&!1===a.loading}function m(e,a,r){"string"==typeof e&&(e=[e]);var t=e.length,i=0,s=!1;function c(){s||++i===t&&a&&a(e)}0!==t?e.forEach(function(e){!function(a,r,t){var i=0<=a.indexOf("!");function e(){var e=p[a];e||(e=p[a]={callbacks:[]}),e.callbacks.push({success:r,error:t}),!i&&u(a)?k(a,"success"):!i&&e.error?k(a,"error"):!i&&e.loading||(e.loading=!0,e.error=!1,function(e,a,r){var t=document.createElement("script");t.src=e,t.async=!0,t.onload=function(){document.body.removeChild(t),a&&a()},t.onerror=function(){document.body.removeChild(t),r&&r()},document.body.appendChild(t)}(function(e){return o.languages_path+"prism-"+e+(o.use_minified?".min":"")+".js"}(a),function(){e.loading=!1,k(a,"success")},function(){e.loading=!1,e.error=!0,k(a,"error")}))}a=a.replace("!",""),a=l[a]||a;var s=n[a];s&&s.length?m(s,e,t):e()}(e,c,function(){s||(s=!0,r&&r(e))})}):a&&setTimeout(a,0)}function k(e,a){if(p[e]){for(var r=p[e].callbacks,t=0,i=r.length;t<i;t++){var s=r[t][a];s&&setTimeout(s,0)}r.length=0}}}();
!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.createElement){var n={javascript:"clike",actionscript:"javascript",arduino:"cpp",aspnet:["markup","csharp"],bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",django:"markup-templating",ejs:["javascript","markup-templating"],etlua:["lua","markup-templating"],erb:["ruby","markup-templating"],fsharp:"clike","firestore-security-rules":"clike",flow:"javascript",ftl:"markup-templating",gml:"clike",glsl:"c",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup-templating",haxe:"clike",hlsl:"c",java:"clike",javadoc:["markup","java","javadoclike"],jolie:"clike",jsdoc:["javascript","javadoclike","typescript"],"js-extras":"javascript",json5:"json",jsonp:"json","js-templates":"javascript",kotlin:"clike",latte:["clike","markup-templating","php"],less:"css",lilypond:"scheme",markdown:"markup","markup-templating":"markup",mongodb:"javascript",n4js:"javascript",nginx:"clike",objectivec:"c",opencl:"c",parser:"markup",php:["clike","markup-templating"],phpdoc:["php","javadoclike"],"php-extras":"php",plsql:"sql",processing:"clike",protobuf:"clike",pug:["markup","javascript"],purebasic:"clike",qml:"javascript",qore:"clike",racket:"scheme",jsx:["markup","javascript"],tsx:["jsx","typescript"],reason:"clike",ruby:"clike",sass:"css",scss:"css",scala:"java","shell-session":"bash",smarty:"markup-templating",solidity:"clike",soy:"markup-templating",sparql:"turtle",sqf:"clike",swift:"clike","t4-cs":["t4-templating","csharp"],"t4-vb":["t4-templating","vbnet"],tap:"yaml",tt2:["clike","markup-templating"],textile:"markup",twig:"markup",typescript:"javascript",vala:"clike",vbnet:"basic",velocity:"markup",wiki:"markup",xeora:"markup","xml-doc":"markup",xquery:"markup"},l={html:"markup",xml:"markup",svg:"markup",mathml:"markup",ssml:"markup",atom:"markup",rss:"markup",js:"javascript",g4:"antlr4",adoc:"asciidoc",shell:"bash",shortcode:"bbcode",rbnf:"bnf",cs:"csharp",dotnet:"csharp",coffee:"coffeescript",conc:"concurnas",jinja2:"django","dns-zone":"dns-zone-file",dockerfile:"docker",eta:"ejs",xlsx:"excel-formula",xls:"excel-formula",gamemakerlanguage:"gml",hs:"haskell",gitignore:"ignore",hgignore:"ignore",npmignore:"ignore",webmanifest:"json",kt:"kotlin",kts:"kotlin",tex:"latex",context:"latex",ly:"lilypond",emacs:"lisp",elisp:"lisp","emacs-lisp":"lisp",md:"markdown",moon:"moonscript",n4jsd:"n4js",nani:"naniscript",objc:"objectivec",objectpascal:"pascal",px:"pcaxis",pcode:"peoplecode",pq:"powerquery",mscript:"powerquery",pbfasm:"purebasic",py:"python",rkt:"racket",rpy:"renpy",robot:"robotframework",rb:"ruby",sol:"solidity",sln:"solution-file",rq:"sparql",t4:"t4-cs",trig:"turtle",ts:"typescript",tsconfig:"typoscript",uscript:"unrealscript",uc:"unrealscript",vb:"visual-basic",vba:"visual-basic",xeoracube:"xeora",yml:"yaml"},p={},e="components/",a=Prism.util.currentScript();if(a){var r=/\bplugins\/autoloader\/prism-autoloader\.(?:min\.)js(?:\?[^\r\n/]*)?$/i,t=/(^|\/)[\w-]+\.(?:min\.)js(?:\?[^\r\n/]*)?$/i,i=a.getAttribute("data-autoloader-path");if(null!=i)e=i.trim().replace(/\/?$/,"/");else{var s=a.src;r.test(s)?e=s.replace(r,"components/"):t.test(s)&&(e=s.replace(t,"$1components/"))}}var o=Prism.plugins.autoloader={languages_path:e,use_minified:!0,loadLanguages:m};Prism.hooks.add("complete",function(e){var a=e.element,r=e.language;if(a&&r&&"none"!==r){var t=function(e){var a=(e.getAttribute("data-dependencies")||"").trim();if(!a){var r=e.parentElement;r&&"pre"===r.tagName.toLowerCase()&&(a=(r.getAttribute("data-dependencies")||"").trim())}return a?a.split(/\s*,\s*/g):[]}(a);t.push(r),t.every(u)||m(t,function(){Prism.highlightElement(a)})}})}function u(e){if(0<=e.indexOf("!"))return!1;if((e=l[e]||e)in Prism.languages)return!0;var a=p[e];return a&&!a.error&&!1===a.loading}function m(e,a,r){"string"==typeof e&&(e=[e]);var t=e.length,i=0,s=!1;function c(){s||++i===t&&a&&a(e)}0!==t?e.forEach(function(e){!function(a,r,t){var i=0<=a.indexOf("!");function e(){var e=p[a];e||(e=p[a]={callbacks:[]}),e.callbacks.push({success:r,error:t}),!i&&u(a)?k(a,"success"):!i&&e.error?k(a,"error"):!i&&e.loading||(e.loading=!0,e.error=!1,function(e,a,r){var t=document.createElement("script");t.src=e,t.async=!0,t.onload=function(){document.body.removeChild(t),a&&a()},t.onerror=function(){document.body.removeChild(t),r&&r()},document.body.appendChild(t)}(function(e){return o.languages_path+"prism-"+e+(o.use_minified?".min":"")+".js"}(a),function(){e.loading=!1,k(a,"success")},function(){e.loading=!1,e.error=!0,k(a,"error")}))}a=a.replace("!",""),a=l[a]||a;var s=n[a];s&&s.length?m(s,e,t):e()}(e,c,function(){s||(s=!0,r&&r(e))})}):a&&setTimeout(a,0)}function k(e,a){if(p[e]){for(var r=p[e].callbacks,t=0,i=r.length;t<i;t++){var s=r[t][a];s&&setTimeout(s,0)}r.length=0}}}();

View File

@ -114,6 +114,7 @@
"markup-templating": "Markup templating",
"matlab": "MATLAB",
"mel": "MEL",
"mongodb": "MongoDB",
"moon": "MoonScript",
"n1ql": "N1QL",
"n4js": "N4JS",

View File

@ -1 +1 @@
!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var r={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",ssml:"SSML",rss:"RSS",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"ABNF",al:"AL",antlr4:"ANTLR4",g4:"ANTLR4",apacheconf:"Apache Configuration",apl:"APL",aql:"AQL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",aspnet:"ASP.NET (C#)",asm6502:"6502 Assembly",autohotkey:"AutoHotkey",autoit:"AutoIt",basic:"BASIC",bbcode:"BBcode",bnf:"BNF",rbnf:"RBNF",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",cmake:"CMake",coffee:"CoffeeScript",conc:"Concurnas",csp:"Content-Security-Policy","css-extras":"CSS Extras",dax:"DAX",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"EBNF",editorconfig:"EditorConfig",ejs:"EJS",etlua:"Embedded Lua templating",erb:"ERB","excel-formula":"Excel Formula",xlsx:"Excel Formula",xls:"Excel Formula",fsharp:"F#","firestore-security-rules":"Firestore security rules",ftl:"FreeMarker Template Language",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",hlsl:"HLSL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",ignore:".ignore",gitignore:".gitignore",hgignore:".hgignore",npmignore:".npmignore",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras",json:"JSON",webmanifest:"Web App Manifest",json5:"JSON5",jsonp:"JSONP",jsstacktrace:"JS stack trace","js-templates":"JS Templates",kts:"Kotlin Script",kt:"Kotlin",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",llvm:"LLVM IR",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",moon:"MoonScript",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",naniscript:"Naninovel Script",nani:"Naninovel Script",nasm:"NASM",neon:"NEON",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",objc:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",peoplecode:"PeopleCode",pcode:"PeopleCode",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powerquery:"PowerQuery",pq:"PowerQuery",mscript:"PowerQuery",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",purebasic:"PureBasic",pbfasm:"PureBasic",py:"Python",q:"Q (kdb+ database)",qml:"QML",rkt:"Racket",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rpy:"Ren'py",rest:"reST (reStructuredText)",robotframework:"Robot Framework",robot:"Robot Framework",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",solidity:"Solidity (Ethereum)",sol:"Solidity (Ethereum)","solution-file":"Solution file",sln:"Solution file",soy:"Soy (Closure Template)",sparql:"SPARQL",rq:"SPARQL","splunk-spl":"Splunk SPL",sqf:"SQF: Status Quo Function (Arma 3)",sql:"SQL",iecst:"Structured Text (IEC 61131-3)","t4-templating":"T4 templating","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)",tap:"TAP",tt2:"Template Toolkit 2",toml:"TOML",trig:"TriG",ts:"TypeScript",tsconfig:"TSConfig",uscript:"UnrealScript",uc:"UnrealScript",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vba:"VBA",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube","xml-doc":"XML doc (.net)",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML",yang:"YANG"};Prism.plugins.toolbar.registerButton("show-language",function(e){var a=e.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var t,o=a.getAttribute("data-language")||r[e.language]||((t=e.language)?(t.substring(0,1).toUpperCase()+t.substring(1)).replace(/s(?=cript)/,"S"):t);if(o){var s=document.createElement("span");return s.textContent=o,s}}})}else console.warn("Show Languages plugin loaded before Toolbar plugin.")}();
!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var r={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",ssml:"SSML",rss:"RSS",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"ABNF",al:"AL",antlr4:"ANTLR4",g4:"ANTLR4",apacheconf:"Apache Configuration",apl:"APL",aql:"AQL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",aspnet:"ASP.NET (C#)",asm6502:"6502 Assembly",autohotkey:"AutoHotkey",autoit:"AutoIt",basic:"BASIC",bbcode:"BBcode",bnf:"BNF",rbnf:"RBNF",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",cmake:"CMake",coffee:"CoffeeScript",conc:"Concurnas",csp:"Content-Security-Policy","css-extras":"CSS Extras",dax:"DAX",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"EBNF",editorconfig:"EditorConfig",ejs:"EJS",etlua:"Embedded Lua templating",erb:"ERB","excel-formula":"Excel Formula",xlsx:"Excel Formula",xls:"Excel Formula",fsharp:"F#","firestore-security-rules":"Firestore security rules",ftl:"FreeMarker Template Language",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",hlsl:"HLSL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",ignore:".ignore",gitignore:".gitignore",hgignore:".hgignore",npmignore:".npmignore",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras",json:"JSON",webmanifest:"Web App Manifest",json5:"JSON5",jsonp:"JSONP",jsstacktrace:"JS stack trace","js-templates":"JS Templates",kts:"Kotlin Script",kt:"Kotlin",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",llvm:"LLVM IR",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",mongodb:"MongoDB",moon:"MoonScript",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",naniscript:"Naninovel Script",nani:"Naninovel Script",nasm:"NASM",neon:"NEON",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",objc:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",peoplecode:"PeopleCode",pcode:"PeopleCode",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powerquery:"PowerQuery",pq:"PowerQuery",mscript:"PowerQuery",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",purebasic:"PureBasic",pbfasm:"PureBasic",py:"Python",q:"Q (kdb+ database)",qml:"QML",rkt:"Racket",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rpy:"Ren'py",rest:"reST (reStructuredText)",robotframework:"Robot Framework",robot:"Robot Framework",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",solidity:"Solidity (Ethereum)",sol:"Solidity (Ethereum)","solution-file":"Solution file",sln:"Solution file",soy:"Soy (Closure Template)",sparql:"SPARQL",rq:"SPARQL","splunk-spl":"Splunk SPL",sqf:"SQF: Status Quo Function (Arma 3)",sql:"SQL",iecst:"Structured Text (IEC 61131-3)","t4-templating":"T4 templating","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)",tap:"TAP",tt2:"Template Toolkit 2",toml:"TOML",trig:"TriG",ts:"TypeScript",tsconfig:"TSConfig",uscript:"UnrealScript",uc:"UnrealScript",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vba:"VBA",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube","xml-doc":"XML doc (.net)",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML",yang:"YANG"};Prism.plugins.toolbar.registerButton("show-language",function(e){var a=e.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var t,o=a.getAttribute("data-language")||r[e.language]||((t=e.language)?(t.substring(0,1).toUpperCase()+t.substring(1)).replace(/s(?=cript)/,"S"):t);if(o){var s=document.createElement("span");return s.textContent=o,s}}})}else console.warn("Show Languages plugin loaded before Toolbar plugin.")}();

View File

@ -0,0 +1,260 @@
{
'_id': ObjectId('5ec72ffe00316be87cab3927'),
'code': Code('function () { return 22; }'),
'binary': BinData(1, '232sa3d323sd232a32sda3s2d3a2s1d23s21d3sa'),
'dbref': DBRef('namespace', ObjectId('5ec72f4200316be87cab3926'), 'db'),
'timestamp': Timestamp(0, 0),
'long': NumberLong(9223372036854775807),
'decimal': NumberDecimal('1000.55'),
'integer': 100,
'maxkey': MaxKey(),
'minkey': MinKey(),
'isodate': ISODate('2012-01-01T00:00:00.000Z'),
'regexp': RegExp('prism(js)?', 'i'),
'string': 'Hello World',
'numberArray': [1, 2, 3],
'stringArray': ['1','2','3'],
'randomKey': null,
'object': { 'a': 1, 'b': 2 },
'max_key2': MaxKey(),
'number': 1234,
'invalid-key': 123,
noQuotesKey: 'value',
}
----------------------------------------------------
[
["punctuation", "{"],
["property", [
"'_id'"
]],
["operator", ":"],
["builtin", "ObjectId"],
["punctuation", "("],
["string", [
"'5ec72ffe00316be87cab3927'"
]],
["punctuation", ")"],
["punctuation", ","],
["property", [
"'code'"
]],
["operator", ":"],
["builtin", "Code"],
["punctuation", "("],
["string", [
"'function () { return 22; }'"
]],
["punctuation", ")"],
["punctuation", ","],
["property", [
"'binary'"
]],
["operator", ":"],
["builtin", "BinData"],
["punctuation", "("],
["number", "1"],
["punctuation", ","],
["string", [
"'232sa3d323sd232a32sda3s2d3a2s1d23s21d3sa'"
]],
["punctuation", ")"],
["punctuation", ","],
["property", [
"'dbref'"
]],
["operator", ":"],
["builtin", "DBRef"],
["punctuation", "("],
["string", [
"'namespace'"
]],
["punctuation", ","],
["builtin", "ObjectId"],
["punctuation", "("],
["string", [
"'5ec72f4200316be87cab3926'"
]],
["punctuation", ")"],
["punctuation", ","],
["string", [
"'db'"
]],
["punctuation", ")"],
["punctuation", ","],
["property", [
"'timestamp'"
]],
["operator", ":"],
["builtin", "Timestamp"],
["punctuation", "("],
["number", "0"],
["punctuation", ","],
["number", "0"],
["punctuation", ")"],
["punctuation", ","],
["property", [
"'long'"
]],
["operator", ":"],
["builtin", "NumberLong"],
["punctuation", "("],
["number", "9223372036854775807"],
["punctuation", ")"],
["punctuation", ","],
["property", [
"'decimal'"
]],
["operator", ":"],
["builtin", "NumberDecimal"],
["punctuation", "("],
["string", [
"'1000.55'"
]],
["punctuation", ")"],
["punctuation", ","],
["property", [
"'integer'"
]],
["operator", ":"],
["number", "100"],
["punctuation", ","],
["property", [
"'maxkey'"
]],
["operator", ":"],
["builtin", "MaxKey"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", ","],
["property", [
"'minkey'"
]],
["operator", ":"],
["builtin", "MinKey"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", ","],
["property", [
"'isodate'"
]],
["operator", ":"],
["builtin", "ISODate"],
["punctuation", "("],
["string", [
"'2012-01-01T00:00:00.000Z'"
]],
["punctuation", ")"],
["punctuation", ","],
["property", [
"'regexp'"
]],
["operator", ":"],
["builtin", "RegExp"],
["punctuation", "("],
["string", [
"'prism(js)?'"
]],
["punctuation", ","],
["string", [
"'i'"
]],
["punctuation", ")"],
["punctuation", ","],
["property", [
"'string'"
]],
["operator", ":"],
["string", [
"'Hello World'"
]],
["punctuation", ","],
["property", [
"'numberArray'"
]],
["operator", ":"],
["punctuation", "["],
["number", "1"],
["punctuation", ","],
["number", "2"],
["punctuation", ","],
["number", "3"],
["punctuation", "]"],
["punctuation", ","],
["property", [
"'stringArray'"
]],
["operator", ":"],
["punctuation", "["],
["string", [
"'1'"
]],
["punctuation", ","],
["string", [
"'2'"
]],
["punctuation", ","],
["string", [
"'3'"
]],
["punctuation", "]"],
["punctuation", ","],
["property", [
"'randomKey'"
]],
["operator", ":"],
["keyword", "null"],
["punctuation", ","],
["property", [
"'object'"
]],
["operator", ":"],
["punctuation", "{"],
["property", [
"'a'"
]],
["operator", ":"],
["number", "1"],
["punctuation", ","],
["property", [
"'b'"
]],
["operator", ":"],
["number", "2"],
["punctuation", "}"],
["punctuation", ","],
["property", [
"'max_key2'"
]],
["operator", ":"],
["builtin", "MaxKey"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", ","],
["property", [
"'number'"
]],
["operator", ":"],
["number", "1234"],
["punctuation", ","],
["property", [
"'invalid-key'"
]],
["operator", ":"],
["number", "123"],
["punctuation", ","],
["property", [
"noQuotesKey"
]],
["operator", ":"],
["string", [
"'value'"
]],
["punctuation", ","],
["punctuation", "}"]
]
----------------------------------------------------
Common document.

View File

@ -0,0 +1,61 @@
ObjectId()
ObjectId ()
Code()
BinData()
DBRef()
Timestamp()
NumberLong()
NumberDecimal()
MaxKey()
MinKey()
RegExp()
ISODate()
UUID()
----------------------------------------------------
[
["builtin", "ObjectId"],
["punctuation", "("],
["punctuation", ")"],
["builtin", "ObjectId"],
["punctuation", "("],
["punctuation", ")"],
["builtin", "Code"],
["punctuation", "("],
["punctuation", ")"],
["builtin", "BinData"],
["punctuation", "("],
["punctuation", ")"],
["builtin", "DBRef"],
["punctuation", "("],
["punctuation", ")"],
["builtin", "Timestamp"],
["punctuation", "("],
["punctuation", ")"],
["builtin", "NumberLong"],
["punctuation", "("],
["punctuation", ")"],
["builtin", "NumberDecimal"],
["punctuation", "("],
["punctuation", ")"],
["builtin", "MaxKey"],
["punctuation", "("],
["punctuation", ")"],
["builtin", "MinKey"],
["punctuation", "("],
["punctuation", ")"],
["builtin", "RegExp"],
["punctuation", "("],
["punctuation", ")"],
["builtin", "ISODate"],
["punctuation", "("],
["punctuation", ")"],
["builtin", "UUID"],
["punctuation", "("],
["punctuation", ")"]
]
----------------------------------------------------
Checks for built-in functions.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,71 @@
db.users.find({
_id: { $nin: ObjectId('5ec72ffe00316be87cab3927') },
age: { $gte: 18, $lte: 99 },
field: { $exists: true }
})
----------------------------------------------------
[
"db",
["punctuation", "."],
"users",
["punctuation", "."],
["function", "find"],
["punctuation", "("],
["punctuation", "{"],
["property", [
"_id"
]],
["operator", ":"],
["punctuation", "{"],
["property", [
["keyword", "$nin"]
]],
["operator", ":"],
["builtin", "ObjectId"],
["punctuation", "("],
["string", [
"'5ec72ffe00316be87cab3927'"
]],
["punctuation", ")"],
["punctuation", "}"],
["punctuation", ","],
["property", [
"age"
]],
["operator", ":"],
["punctuation", "{"],
["property", [
["keyword", "$gte"]
]],
["operator", ":"],
["number", "18"],
["punctuation", ","],
["property", [
["keyword", "$lte"]
]],
["operator", ":"],
["number", "99"],
["punctuation", "}"],
["punctuation", ","],
["property", [
"field"
]],
["operator", ":"],
["punctuation", "{"],
["property", [
["keyword", "$exists"]
]],
["operator", ":"],
["boolean", "true"],
["punctuation", "}"],
["punctuation", "}"],
["punctuation", ")"]
]
----------------------------------------------------
Common query.

View File

@ -0,0 +1,33 @@
{
field1: 'Here is url: http://prismjs.com/'
field2: 'Here is ip: 192.168.0.1'
}
----------------------------------------------------
[
["punctuation", "{"],
["property", [
"field1"
]],
["operator", ":"],
["string", [
"'Here is url: ",
["url", "http://prismjs.com/"],
"'"
]],
["property", [
"field2"
]],
["operator", ":"],
["string", [
"'Here is ip: ",
["entity", "192.168.0.1"],
"'"
]],
["punctuation", "}"]
]
----------------------------------------------------
Checks for URL and IP highlighting inside string.

View File

@ -0,0 +1,81 @@
db.users.updateOne(
{
_id: ObjectId('5ec72ffe00316be87cab3927')
},
{
$set: { age: 30 },
$inc: { updateCount: 1 },
$push: { updateDates: new Date() }
}
)
----------------------------------------------------
[
"db",
["punctuation", "."],
"users",
["punctuation", "."],
["function", "updateOne"],
["punctuation", "("],
["punctuation", "{"],
["property", [
"_id"
]],
["operator", ":"],
["builtin", "ObjectId"],
["punctuation", "("],
["string", [
"'5ec72ffe00316be87cab3927'"
]],
["punctuation", ")"],
["punctuation", "}"],
["punctuation", ","],
["punctuation", "{"],
["property", [
["keyword", "$set"]
]],
["operator", ":"],
["punctuation", "{"],
["property", [
"age"
]],
["operator", ":"],
["number", "30"],
["punctuation", "}"],
["punctuation", ","],
["property", [
["keyword", "$inc"]
]],
["operator", ":"],
["punctuation", "{"],
["property", [
"updateCount"
]],
["operator", ":"],
["number", "1"],
["punctuation", "}"],
["punctuation", ","],
["property", [
["keyword", "$push"]
]],
["operator", ":"],
["punctuation", "{"],
["property", [
"updateDates"
]],
["operator", ":"],
["keyword", "new"],
["class-name", [
"Date"
]],
["punctuation", "("],
["punctuation", ")"],
["punctuation", "}"],
["punctuation", "}"],
["punctuation", ")"]
]
----------------------------------------------------
Common update.