Prism depends on community contributions to expand and cover a wider array of use cases. If you like it, considering giving back by sending a pull request. Here are a few tips:
- Read the [documentation](https://prismjs.com/extending.html). Prism was designed to be extensible.
-- Do not edit `prism.js`, it’s just the version of Prism used by the Prism website and is built automatically. Limit your changes to the unminified files in the `components/` folder. The minified files are also generated automatically.
-- The build system uses [gulp](https://github.com/gulpjs/gulp) to minify the files and build `prism.js`. Having gulp installed, you just need to run the command `gulp`.
+- Do not edit `prism.js`, it’s just the version of Prism used by the Prism website and is built automatically. Limit your changes to the unminified files in the `components/` folder. `prism.js` and all minified files are also generated automatically by our build system.
+- The build system uses [gulp](https://github.com/gulpjs/gulp) to minify the files and build `prism.js`. With all of Prism's dependencies installed, you just need to run the command `npm run build`.
- Please follow the code conventions used in the files already. For example, I use [tabs for indentation and spaces for alignment](http://lea.verou.me/2012/01/why-tabs-are-clearly-superior/). Opening braces are on the same line, closing braces on their own line regardless of construct. There is a space before the opening brace. etc etc.
- Please try to err towards more smaller PRs rather than few huge PRs. If a PR includes changes I want to merge and changes I don't, handling it becomes difficult.
- My time is very limited these days, so it might take a long time to review longer PRs (short ones are usually merged very quickly), especially those modifying the Prism Core. This doesn't mean your PR is rejected.
- If you contribute a new language definition, you will be responsible for handling bug reports about that language definition.
-- If you add a new language definition, theme or plugin, you need to add it to `components.json` as well and rebuild Prism by running `gulp`, so that it becomes available to the download build page. For new languages, please also add a few [tests](https://prismjs.com/test-suite.html) and an example in the `examples/` folder.
+- If you [add a new language definition](https://prismjs.com/extending.html#creating-a-new-language-definition) or plugin, you need to add it to `components.json` as well and rebuild Prism by running `npm run build`, so that it becomes available to the download build page. For new languages, please also add a few [tests](https://prismjs.com/test-suite.html) and an example in the `examples/` folder.
+- Go to [prism-themes](https://github.com/PrismJS/prism-themes) if you want to add a new theme.
Thank you so much for contributing!!
},
"markup": {
"title": "Markup",
- "alias": ["html", "xml", "svg", "mathml"],
+ "alias": ["html", "xml", "svg", "mathml", "ssml", "atom", "rss"],
"aliasTitles": {
"html": "HTML",
"xml": "XML",
"svg": "SVG",
- "mathml": "MathML"
+ "mathml": "MathML",
+ "ssml": "SSML",
+ "atom": "Atom",
+ "rss": "RSS"
},
"option": "default"
},
"owner": "dellagustin"
},
"abnf": {
- "title": "Augmented Backus–Naur form",
+ "title": "ABNF",
"owner": "RunDevelopment"
},
"actionscript": {
"title": "Ada",
"owner": "Lucretia"
},
+ "agda": {
+ "title": "Agda",
+ "owner": "xy-ren"
+ },
+ "al": {
+ "title": "AL",
+ "owner": "RunDevelopment"
+ },
"antlr4": {
"title": "ANTLR4",
"alias": "g4",
"title": "AsciiDoc",
"owner": "Golmote"
},
- "asm6502": {
- "title": "6502 Assembly",
- "owner": "kzurawel"
- },
"aspnet": {
"title": "ASP.NET (C#)",
"require": ["markup", "csharp"],
"owner": "nauzilus"
},
+ "asm6502": {
+ "title": "6502 Assembly",
+ "owner": "kzurawel"
+ },
"autohotkey": {
"title": "AutoHotkey",
"owner": "aviaryan"
"owner": "Golmote"
},
"bnf": {
- "title": "Backus–Naur form",
+ "title": "BNF",
"alias": "rbnf",
"aliasTitles": {
- "rbnf": "Routing Backus–Naur form"
+ "rbnf": "RBNF"
},
"owner": "RunDevelopment"
},
"require": "clike",
"owner": "zeitgeist87"
},
- "concurnas": {
- "title": "Concurnas",
- "alias": "conc",
- "owner": "jasontatton"
- },
"csharp": {
"title": "C#",
"require": "clike",
"title": "CIL",
"owner": "sbrl"
},
+ "clojure": {
+ "title": "Clojure",
+ "owner": "troglotit"
+ },
+ "cmake": {
+ "title": "CMake",
+ "owner": "mjrogozinski"
+ },
"coffeescript": {
"title": "CoffeeScript",
"require": "javascript",
"alias": "coffee",
"owner": "R-osey"
},
- "cmake": {
- "title": "CMake",
- "owner": "mjrogozinski"
+ "concurnas": {
+ "title": "Concurnas",
+ "alias": "conc",
+ "owner": "jasontatton"
},
- "clojure": {
- "title": "Clojure",
- "owner": "troglotit"
+ "csp": {
+ "title": "Content-Security-Policy",
+ "owner": "ScottHelme"
},
"crystal": {
"title": "Crystal",
"require": "ruby",
"owner": "MakeNowJust"
},
- "csp": {
- "title": "Content-Security-Policy",
- "owner": "ScottHelme"
- },
"css-extras": {
"title": "CSS Extras",
"require": "css",
"modify": "css",
"owner": "milesj"
},
+ "cypher": {
+ "title": "Cypher",
+ "owner": "RunDevelopment"
+ },
"d": {
"title": "D",
"require": "clike",
"title": "DAX",
"owner": "peterbud"
},
+ "dhall": {
+ "title": "Dhall",
+ "owner": "RunDevelopment"
+ },
"diff": {
"title": "Diff",
"owner": "uranusjr"
"owner": "JustinBeckwith"
},
"ebnf": {
- "title": "Extended Backus–Naur form",
+ "title": "EBNF",
"owner": "RunDevelopment"
},
+ "editorconfig": {
+ "title": "EditorConfig",
+ "owner": "osipxd"
+ },
"eiffel": {
"title": "Eiffel",
"owner": "Conaclos"
"ejs": {
"title": "EJS",
"require": ["javascript", "markup-templating"],
- "owner": "RunDevelopment"
+ "owner": "RunDevelopment",
+ "alias": "eta",
+ "aliasTitles": {
+ "eta": "Eta"
+ }
},
"elixir": {
"title": "Elixir",
"require": "markup-templating",
"owner": "RunDevelopment"
},
+ "gml": {
+ "title": "GameMaker Language",
+ "alias": "gamemakerlanguage",
+ "require": "clike",
+ "owner": "LiarOnce"
+ },
"gcode": {
"title": "G-code",
"owner": "RunDevelopment"
},
"glsl": {
"title": "GLSL",
- "require": "clike",
+ "require": "c",
"owner": "Golmote"
},
- "gml": {
- "title": "GameMaker Language",
- "alias": "gamemakerlanguage",
- "require": "clike",
- "owner": "LiarOnce"
- },
"go": {
"title": "Go",
"require": "clike",
},
"graphql": {
"title": "GraphQL",
+ "optional": ["markdown"],
"owner": "Golmote"
},
"groovy": {
"title": "HCL",
"owner": "outsideris"
},
+ "hlsl": {
+ "title": "HLSL",
+ "require": "c",
+ "owner": "RunDevelopment"
+ },
"http": {
"title": "HTTP",
"optional": [
"title": "Icon",
"owner": "Golmote"
},
+ "ignore": {
+ "title": ".ignore",
+ "owner": "osipxd",
+ "alias": [
+ "gitignore",
+ "hgignore",
+ "npmignore"
+ ],
+ "aliasTitles": {
+ "gitignore": ".gitignore",
+ "hgignore": ".hgignore",
+ "npmignore": ".npmignore"
+ }
+ },
"inform7": {
"title": "Inform 7",
"owner": "Golmote"
},
"jsdoc": {
"title": "JSDoc",
- "require": ["javascript", "javadoclike"],
+ "require": ["javascript", "javadoclike", "typescript"],
"modify": "javascript",
"optional": [
"actionscript",
],
"owner": "RunDevelopment"
},
+ "json": {
+ "title": "JSON",
+ "alias": "webmanifest",
+ "aliasTitles": {
+ "webmanifest": "Web App Manifest"
+ },
+ "owner": "CupOfTea696"
+ },
+ "json5": {
+ "title": "JSON5",
+ "require": "json",
+ "owner": "RunDevelopment"
+ },
+ "jsonp": {
+ "title": "JSONP",
+ "require": "json",
+ "owner": "RunDevelopment"
+ },
+ "jsstacktrace": {
+ "title": "JS stack trace",
+ "owner": "sbrl"
+ },
"js-templates": {
"title": "JS Templates",
"require": "javascript",
],
"owner": "RunDevelopment"
},
- "json": {
- "title": "JSON",
- "owner": "CupOfTea696"
- },
- "jsonp": {
- "title": "JSONP",
- "require": "json",
- "owner": "RunDevelopment"
- },
- "json5": {
- "title": "JSON5",
- "require": "json",
- "owner": "RunDevelopment"
- },
"julia": {
"title": "Julia",
"owner": "cdagnino"
},
"kotlin": {
"title": "Kotlin",
+ "alias": ["kt", "kts"],
+ "aliasTitles": {
+ "kts": "Kotlin Script"
+ },
"require": "clike",
"owner": "Golmote"
},
"objectivec": {
"title": "Objective-C",
"require": "c",
+ "alias": "objc",
"owner": "uranusjr"
},
"ocaml": {
"alias": "px",
"owner": "RunDevelopment"
},
+ "peoplecode": {
+ "title": "PeopleCode",
+ "alias": "pcode",
+ "owner": "RunDevelopment"
+ },
"perl": {
"title": "Perl",
"owner": "Golmote"
],
"owner": "Golmote"
},
+ "purebasic": {
+ "title": "PureBasic",
+ "require": "clike",
+ "alias": "pbfasm",
+ "owner": "HeX0R101"
+ },
"python": {
"title": "Python",
"alias": "py",
"title": "R",
"owner": "Golmote"
},
+ "racket": {
+ "title": "Racket",
+ "require": "scheme",
+ "alias": "rkt",
+ "owner": "RunDevelopment"
+ },
"jsx": {
"title": "React JSX",
"require": ["markup", "javascript"],
"title": "React TSX",
"require": ["jsx", "typescript"]
},
- "renpy": {
- "title": "Ren'py",
- "owner": "HyuchiaDiego"
- },
"reason": {
"title": "Reason",
"require": "clike",
],
"owner": "RunDevelopment"
},
+ "renpy": {
+ "title": "Ren'py",
+ "alias": "rpy",
+ "owner": "HyuchiaDiego"
+ },
"rest": {
"title": "reST (reStructuredText)",
"owner": "Golmote"
"require": "bash",
"owner": "RunDevelopment"
},
+ "smali": {
+ "title": "Smali",
+ "owner": "RunDevelopment"
+ },
"smalltalk": {
"title": "Smalltalk",
"owner": "Golmote"
},
"solidity": {
"title": "Solidity (Ethereum)",
+ "alias": "sol",
"require": "clike",
"owner": "glachaud"
},
"title": "SQL",
"owner": "multipetros"
},
+ "iecst": {
+ "title": "Structured Text (IEC 61131-3)",
+ "owner": "serhioromano"
+ },
"stylus": {
"title": "Stylus",
"owner": "vkbansal"
"require": "clike",
"owner": "chrischares"
},
+ "t4-templating": {
+ "title": "T4 templating",
+ "owner": "RunDevelopment"
+ },
+ "t4-cs": {
+ "title": "T4 Text Templates (C#)",
+ "require": ["t4-templating", "csharp"],
+ "alias": "t4",
+ "owner": "RunDevelopment"
+ },
+ "t4-vb": {
+ "title": "T4 Text Templates (VB)",
+ "require": ["t4-templating", "vbnet"],
+ "owner": "RunDevelopment"
+ },
"tap": {
"title": "TAP",
"owner": "isaacs",
"title": "Tcl",
"owner": "PeterChaplin"
},
+ "tt2": {
+ "title": "Template Toolkit 2",
+ "require": ["clike", "markup-templating"],
+ "owner": "gflohr"
+ },
"textile": {
"title": "Textile",
"require": "markup",
"title": "TOML",
"owner": "RunDevelopment"
},
- "tt2": {
- "title": "Template Toolkit 2",
- "require": ["clike", "markup-templating"],
- "owner": "gflohr"
- },
"turtle": {
"title": "Turtle",
"alias": "trig",
"alias": "ts",
"owner": "vkbansal"
},
- "t4-cs": {
- "title": "T4 Text Templates (C#)",
- "require": ["t4-templating", "csharp"],
- "alias": "t4",
- "owner": "RunDevelopment"
- },
- "t4-vb": {
- "title": "T4 Text Templates (VB)",
- "require": ["t4-templating", "visual-basic"],
- "owner": "RunDevelopment"
- },
- "t4-templating": {
- "title": "T4 templating",
+ "unrealscript": {
+ "title": "UnrealScript",
+ "alias": ["uscript", "uc"],
"owner": "RunDevelopment"
},
"vala": {
},
"visual-basic": {
"title": "Visual Basic",
- "alias": "vb",
+ "alias": ["vb", "vba"],
+ "aliasTitles": {
+ "vba": "VBA"
+ },
"owner": "Golmote"
},
+ "warpscript": {
+ "title": "WarpScript",
+ "owner": "RunDevelopment"
+ },
"wasm": {
"title": "WebAssembly",
"owner": "Golmote"
},
"owner": "freakmaxi"
},
+ "xml-doc": {
+ "title": "XML doc (.net)",
+ "require": "markup",
+ "modify": ["csharp", "fsharp", "vbnet"],
+ "owner": "RunDevelopment"
+ },
"xojo": {
"title": "Xojo (REALbasic)",
"owner": "Golmote"
"alias": "yml",
"owner": "hason"
},
+ "yang": {
+ "title": "YANG",
+ "owner": "RunDevelopment"
+ },
"zig": {
"title": "Zig",
"owner": "RunDevelopment"
--- /dev/null
+define(["prism/prism"], function () {
+(function (Prism) {
+
+ Prism.languages.agda = {
+ 'comment': /\{-[\s\S]*?(?:-\}|$)|--.*/,
+ 'string': {
+ pattern: /"(?:\\(?:\r\n|[\s\S])|[^\\\r\n"])*"/,
+ greedy: true,
+ },
+ 'punctuation': /[(){}⦃⦄.;@]/,
+ 'class-name': {
+ pattern: /((?:data|record) +)\S+/,
+ lookbehind: true,
+ },
+ 'function': {
+ pattern: /(^[ \t]*)[^:\r\n]+?(?=:)/m,
+ lookbehind: true,
+ },
+ 'operator': {
+ pattern: /(^\s*|\s)(?:[=|:∀→λ\\?_]|->)(?=\s)/,
+ lookbehind: true,
+ },
+ 'keyword': /\b(?:Set|abstract|constructor|data|eta-equality|field|forall|forall|hiding|import|in|inductive|infix|infixl|infixr|instance|let|macro|module|mutual|no-eta-equality|open|overlap|pattern|postulate|primitive|private|public|quote|quoteContext|quoteGoal|quoteTerm|record|renaming|rewrite|syntax|tactic|unquote|unquoteDecl|unquoteDef|using|variable|where|with)\b/,
+ };
+}(Prism));
+
+return Prism; })
\ No newline at end of file
--- /dev/null
+define(["prism/prism"], function () {
+// based on https://github.com/microsoft/AL/blob/master/grammar/alsyntax.tmlanguage
+
+Prism.languages.al = {
+ 'comment': /\/\/.*|\/\*[\s\S]*?\*\//,
+ 'string': {
+ pattern: /'(?:''|[^'\r\n])*'(?!')|"(?:""|[^"\r\n])*"(?!")/,
+ greedy: true
+ },
+ 'function': {
+ pattern: /(\b(?:event|procedure|trigger)\s+|(?:^|[^.])\.\s*)[a-z_]\w*(?=\s*\()/i,
+ lookbehind: true
+ },
+ 'keyword': [
+ // keywords
+ /\b(?:array|asserterror|begin|break|case|do|downto|else|end|event|exit|for|foreach|function|if|implements|in|indataset|interface|internal|local|of|procedure|program|protected|repeat|runonclient|securityfiltering|suppressdispose|temporary|then|to|trigger|until|var|while|with|withevents)\b/i,
+ // objects and metadata that are used like keywords
+ /\b(?:action|actions|addafter|addbefore|addfirst|addlast|area|assembly|chartpart|codeunit|column|controladdin|cuegroup|customizes|dataitem|dataset|dotnet|elements|enum|enumextension|extends|field|fieldattribute|fieldelement|fieldgroup|fieldgroups|fields|filter|fixed|grid|group|key|keys|label|labels|layout|modify|moveafter|movebefore|movefirst|movelast|page|pagecustomization|pageextension|part|profile|query|repeater|report|requestpage|schema|separator|systempart|table|tableelement|tableextension|textattribute|textelement|type|usercontrol|value|xmlport)\b/i
+ ],
+ 'number': /\b(?:0x[\da-f]+|(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(?:F|U(?:LL?)?|LL?)?\b/i,
+ 'boolean': /\b(?:false|true)\b/i,
+ 'variable': /\b(?:Curr(?:FieldNo|Page|Report)|RequestOptionsPage|x?Rec)\b/,
+ 'class-name': /\b(?:automation|biginteger|bigtext|blob|boolean|byte|char|clienttype|code|completiontriggererrorlevel|connectiontype|database|dataclassification|datascope|date|dateformula|datetime|decimal|defaultlayout|dialog|dictionary|dotnetassembly|dotnettypedeclaration|duration|errorinfo|errortype|executioncontext|executionmode|fieldclass|fieldref|fieldtype|file|filterpagebuilder|guid|httpclient|httpcontent|httpheaders|httprequestmessage|httpresponsemessage|instream|integer|joker|jsonarray|jsonobject|jsontoken|jsonvalue|keyref|list|moduledependencyinfo|moduleinfo|none|notification|notificationscope|objecttype|option|outstream|pageresult|record|recordid|recordref|reportformat|securityfilter|sessionsettings|tableconnectiontype|tablefilter|testaction|testfield|testfilterfield|testpage|testpermissions|testrequestpage|text|textbuilder|textconst|textencoding|time|transactionmodel|transactiontype|variant|verbosity|version|view|views|webserviceactioncontext|webserviceactionresultcode|xmlattribute|xmlattributecollection|xmlcdata|xmlcomment|xmldeclaration|xmldocument|xmldocumenttype|xmlelement|xmlnamespacemanager|xmlnametable|xmlnode|xmlnodelist|xmlprocessinginstruction|xmlreadoptions|xmltext|xmlwriteoptions)\b/i,
+ 'operator': /\.\.|:[=:]|[-+*/]=?|<>|[<>]=?|=|\b(?:and|div|mod|not|or|xor)\b/i,
+ 'punctuation': /[()\[\]{}:.;,]/
+};
+
+return Prism; })
\ No newline at end of file
}
},
'command': {
- pattern: /(->\s*)(?:\s*(?:,\s*)?[a-z]\w*(?:\s*\([^()\r\n]*\))?)+(?=\s*;)/i,
+ pattern: /(->\s*)(?:\s*(?:,\s*)?\b[a-z]\w*(?:\s*\([^()\r\n]*\))?)+(?=\s*;)/i,
lookbehind: true,
inside: {
'function': /\b\w+(?=\s*(?:[,(]|$))/,
pattern: /'(?:[^'\r\n]|'')*'/,
greedy: true
},
- 'number': /¯?(?:\d*\.?\d+(?:e[+¯]?\d+)?|¯|∞)(?:j¯?(?:\d*\.?\d+(?:e[+¯]?\d+)?|¯|∞))?/i,
+ 'number': /¯?(?:\d*\.?\b\d+(?:e[+¯]?\d+)?|¯|∞)(?:j¯?(?:\d*\.?\d+(?:e[+¯]?\d+)?|¯|∞))?/i,
'statement': /:[A-Z][a-z][A-Za-z]*\b/,
'system-function': {
pattern: /⎕[A-Z]+/i,
alias: 'operator'
},
'dyadic-operator': {
- pattern: /[.⍣⍠⍤∘⌸@⌺]/,
+ pattern: /[.⍣⍠⍤∘⌸@⌺⍥]/,
alias: 'operator'
},
'assignment': {
alias: 'builtin'
}
};
+
return Prism; })
\ No newline at end of file
Prism.languages.applescript = {
'comment': [
// Allow one level of nesting
- /\(\*(?:\(\*[\s\S]*?\*\)|[\s\S])*?\*\)/,
+ /\(\*(?:\(\*(?:[^*]|\*(?!\)))*\*\)|(?!\(\*)[\s\S])*?\*\)/,
/--.+/,
/#.+/
],
},
'punctuation': /[{}():,¬«»《》]/
};
+
return Prism; })
\ No newline at end of file
Those do not have the restrictions of the constrained quotes.
They are, in order: __emphasis__, **strong**, ++monospace++, +++passthrough+++, ##unquoted##, $$passthrough$$, ~subscript~, ^superscript^, {attribute-reference}, [[anchor]], [[[bibliography anchor]]], <<xref>>, (((indexes))) and ((indexes))
*/
- pattern: /(^|[^\\])(?:(?:\B\[(?:[^\]\\"]|(["'])(?:(?!\2)[^\\]|\\.)*\2|\\.)*\])?(?:\b_(?!\s)(?: _|[^_\\\r\n]|\\.)+(?:(?:\r?\n|\r)(?: _|[^_\\\r\n]|\\.)+)*_\b|\B``(?!\s).+?(?:(?:\r?\n|\r).+?)*''\B|\B`(?!\s)(?: ['`]|.)+?(?:(?:\r?\n|\r)(?: ['`]|.)+?)*['`]\B|\B(['*+#])(?!\s)(?: \3|(?!\3)[^\\\r\n]|\\.)+(?:(?:\r?\n|\r)(?: \3|(?!\3)[^\\\r\n]|\\.)+)*\3\B)|(?:\[(?:[^\]\\"]|(["'])(?:(?!\4)[^\\]|\\.)*\4|\\.)*\])?(?:(__|\*\*|\+\+\+?|##|\$\$|[~^]).+?(?:(?:\r?\n|\r).+?)*\5|\{[^}\r\n]+\}|\[\[\[?.+?(?:(?:\r?\n|\r).+?)*\]?\]\]|<<.+?(?:(?:\r?\n|\r).+?)*>>|\(\(\(?.+?(?:(?:\r?\n|\r).+?)*\)?\)\)))/m,
+ pattern: /(^|[^\\])(?:(?:\B\[(?:[^\]\\"]|(["'])(?:(?!\2)[^\\]|\\.)*\2|\\.)*\])?(?:\b_(?!\s)(?: _|[^_\\\r\n]|\\.)+(?:(?:\r?\n|\r)(?: _|[^_\\\r\n]|\\.)+)*_\b|\B``(?!\s).+?(?:(?:\r?\n|\r).+?)*''\B|\B`(?!\s)(?:[^`'\s]|\s+\S)+['`]\B|\B(['*+#])(?!\s)(?: \3|(?!\3)[^\\\r\n]|\\.)+(?:(?:\r?\n|\r)(?: \3|(?!\3)[^\\\r\n]|\\.)+)*\3\B)|(?:\[(?:[^\]\\"]|(["'])(?:(?!\4)[^\\]|\\.)*\4|\\.)*\])?(?:(__|\*\*|\+\+\+?|##|\$\$|[~^]).+?(?:(?:\r?\n|\r).+?)*\5|\{[^}\r\n]+\}|\[\[\[?.+?(?:(?:\r?\n|\r).+?)*\]?\]\]|<<.+?(?:(?:\r?\n|\r).+?)*>>|\(\(\(?.+?(?:(?:\r?\n|\r).+?)*\)?\)\)))/m,
lookbehind: true,
inside: {
'attributes': attributes,
},
'string': /(["'`])(?:\\.|(?!\1)[^\\\r\n])*\1/,
'opcode': {
- pattern: /\b(?:adc|and|asl|bcc|bcs|beq|bit|bmi|bne|bpl|brk|bvc|bvs|clc|cld|cli|clv|cmp|cpx|cpy|dec|dex|dey|eor|inc|inx|iny|jmp|jsr|lda|ldx|ldy|lsr|nop|ora|pha|php|pla|plp|rol|ror|rti|rts|sbc|sec|sed|sei|sta|stx|sty|tax|tay|tsx|txa|txs|tya|ADC|AND|ASL|BCC|BCS|BEQ|BIT|BMI|BNE|BPL|BRK|BVC|BVS|CLC|CLD|CLI|CLV|CMP|CPX|CPY|DEC|DEX|DEY|EOR|INC|INX|INY|JMP|JSR|LDA|LDX|LDY|LSR|NOP|ORA|PHA|PHP|PLA|PLP|ROL|ROR|RTI|RTS|SBC|SEC|SED|SEI|STA|STX|STY|TAX|TAY|TSX|TXA|TXS|TYA)\b/,
+ pattern: /\b(?:adc|and|asl|bcc|bcs|beq|bit|bmi|bne|bpl|brk|bvc|bvs|clc|cld|cli|clv|cmp|cpx|cpy|dec|dex|dey|eor|inc|inx|iny|jmp|jsr|lda|ldx|ldy|lsr|nop|ora|pha|php|pla|plp|rol|ror|rti|rts|sbc|sec|sed|sei|sta|stx|sty|tax|tay|tsx|txa|txs|tya|ADC|AND|ASL|BCC|BCS|BEQ|BIT|BMI|BNE|BPL|BRK|BVC|BVS|CLC|CLD|CLI|CLV|CMP|CPX|CPY|DEC|DEX|DEY|EOR|INC|INX|INY|JMP|JSR|LDA|LDX|LDY|LSR|NOP|ORA|PHA|PHP|PLA|PLP|ROL|ROR|RTI|RTS|SBC|SEC|SED|SEI|STA|STX|STY|TAX|TAY|TSX|TXA|TXS|TYA)\b/,
alias: 'property'
},
'hexnumber': {
- pattern: /#?\$[\da-f]{2,4}/i,
+ pattern: /#?\$[\da-f]{2,4}\b/i,
alias: 'string'
},
'binarynumber': {
- pattern: /#?%[01]+/,
+ pattern: /#?%[01]+\b/,
alias: 'string'
},
'decimalnumber': {
- pattern: /#?\d+/,
+ pattern: /#?\b\d+\b/,
alias: 'string'
},
'register': {
define(["prism/prism"], function () {
// NOTES - follows first-first highlight method, block is locked after highlight, different from SyntaxHl
-Prism.languages.autohotkey= {
- 'comment': {
- pattern: /(^[^";\n]*(?:"[^"\n]*?"[^"\n]*?)*)(?:;.*$|^\s*\/\*[\s\S]*\n\*\/)/m,
- lookbehind: true
- },
+Prism.languages.autohotkey = {
+ 'comment': [
+ {
+ pattern: /(^|\s);.*/,
+ lookbehind: true
+ },
+ {
+ pattern: /(^\s*)\/\*[^\r\n]*(?:[\r\n](?![ \t]*\*\/)|[^\r\n])*(?:[\r\n][ \t]*\*\/)?/m,
+ lookbehind: true,
+ greedy: true
+ }
+ ],
'string': /"(?:[^"\n\r]|"")*"/m,
- 'function': /[^(); \t,\n+*\-=?>:\\\/<&%\[\]]+?(?=\()/m, //function - don't use .*\) in the end bcoz string locks it
- 'tag': /^[ \t]*[^\s:]+?(?=:(?:[^:]|$))/m, //labels
+ 'tag': /^[ \t]*[^\s:]+?(?=:(?:[^:]|$))/m, //labels
'variable': /%\w+%/,
'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,
'operator': /\?|\/\/?=?|:=|\|[=|]?|&[=&]?|\+[=+]?|-[=-]?|\*[=*]?|<(?:<=?|>|=)?|>>?=?|[.^!=~]=?|\b(?:AND|NOT|OR)\b/,
- 'punctuation': /[{}[\]():,]/,
'boolean': /\b(?:true|false)\b/,
- 'selector': /\b(?:AutoTrim|BlockInput|Break|Click|ClipWait|Continue|Control|ControlClick|ControlFocus|ControlGet|ControlGetFocus|ControlGetPos|ControlGetText|ControlMove|ControlSend|ControlSendRaw|ControlSetText|CoordMode|Critical|DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|DriveSpaceFree|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|FileDelete|FileEncoding|FileGetAttrib|FileGetShortcut|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|GuiControlGet|Hotkey|ImageSearch|IniDelete|IniRead|IniWrite|Input|InputBox|KeyWait|ListHotkeys|ListLines|ListVars|Loop|Menu|MouseClick|MouseClickDrag|MouseGetPos|MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|PixelSearch|PostMessage|Process|Progress|Random|RegDelete|RegRead|RegWrite|Reload|Repeat|Return|Run|RunAs|RunWait|Send|SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|SetBatchLines|SetCapslockState|SetControlDelay|SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|SetMouseDelay|SetNumlockState|SetScrollLockState|SetStoreCapslockMode|SetTimer|SetTitleMatchMode|SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|StringGetPos|StringLeft|StringLen|StringLower|StringMid|StringReplace|StringRight|StringSplit|StringTrimLeft|StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|Transform|TrayTip|URLDownloadToFile|WinActivate|WinActivateBottom|WinClose|WinGet|WinGetActiveStats|WinGetActiveTitle|WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinHide|WinKill|WinMaximize|WinMenuSelectItem|WinMinimize|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinRestore|WinSet|WinSetTitle|WinShow|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive)\b/i,
+ 'selector': /\b(?:AutoTrim|BlockInput|Break|Click|ClipWait|Continue|Control|ControlClick|ControlFocus|ControlGet|ControlGetFocus|ControlGetPos|ControlGetText|ControlMove|ControlSend|ControlSendRaw|ControlSetText|CoordMode|Critical|DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|DriveSpaceFree|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|FileDelete|FileEncoding|FileGetAttrib|FileGetShortcut|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|GuiControlGet|Hotkey|ImageSearch|IniDelete|IniRead|IniWrite|Input|InputBox|KeyWait|ListHotkeys|ListLines|ListVars|Loop|Menu|MouseClick|MouseClickDrag|MouseGetPos|MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|PixelSearch|PostMessage|Process|Progress|Random|RegDelete|RegRead|RegWrite|Reload|Repeat|Return|Run|RunAs|RunWait|Send|SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|SetBatchLines|SetCapslockState|SetControlDelay|SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|SetMouseDelay|SetNumlockState|SetRegView|SetScrollLockState|SetStoreCapslockMode|SetTimer|SetTitleMatchMode|SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|StringGetPos|StringLeft|StringLen|StringLower|StringMid|StringReplace|StringRight|StringSplit|StringTrimLeft|StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|Transform|TrayTip|URLDownloadToFile|WinActivate|WinActivateBottom|WinClose|WinGet|WinGetActiveStats|WinGetActiveTitle|WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinHide|WinKill|WinMaximize|WinMenuSelectItem|WinMinimize|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinRestore|WinSet|WinSetTitle|WinShow|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive)\b/i,
- 'constant': /\b(?:a_ahkpath|a_ahkversion|a_appdata|a_appdatacommon|a_autotrim|a_batchlines|a_caretx|a_carety|a_computername|a_controldelay|a_cursor|a_dd|a_ddd|a_dddd|a_defaultmousespeed|a_desktop|a_desktopcommon|a_detecthiddentext|a_detecthiddenwindows|a_endchar|a_eventinfo|a_exitreason|a_formatfloat|a_formatinteger|a_gui|a_guievent|a_guicontrol|a_guicontrolevent|a_guiheight|a_guiwidth|a_guix|a_guiy|a_hour|a_iconfile|a_iconhidden|a_iconnumber|a_icontip|a_index|a_ipaddress1|a_ipaddress2|a_ipaddress3|a_ipaddress4|a_isadmin|a_iscompiled|a_iscritical|a_ispaused|a_issuspended|a_isunicode|a_keydelay|a_language|a_lasterror|a_linefile|a_linenumber|a_loopfield|a_loopfileattrib|a_loopfiledir|a_loopfileext|a_loopfilefullpath|a_loopfilelongpath|a_loopfilename|a_loopfileshortname|a_loopfileshortpath|a_loopfilesize|a_loopfilesizekb|a_loopfilesizemb|a_loopfiletimeaccessed|a_loopfiletimecreated|a_loopfiletimemodified|a_loopreadline|a_loopregkey|a_loopregname|a_loopregsubkey|a_loopregtimemodified|a_loopregtype|a_mday|a_min|a_mm|a_mmm|a_mmmm|a_mon|a_mousedelay|a_msec|a_mydocuments|a_now|a_nowutc|a_numbatchlines|a_ostype|a_osversion|a_priorhotkey|programfiles|a_programfiles|a_programs|a_programscommon|a_screenheight|a_screenwidth|a_scriptdir|a_scriptfullpath|a_scriptname|a_sec|a_space|a_startmenu|a_startmenucommon|a_startup|a_startupcommon|a_stringcasesense|a_tab|a_temp|a_thisfunc|a_thishotkey|a_thislabel|a_thismenu|a_thismenuitem|a_thismenuitempos|a_tickcount|a_timeidle|a_timeidlephysical|a_timesincepriorhotkey|a_timesincethishotkey|a_titlematchmode|a_titlematchmodespeed|a_username|a_wday|a_windelay|a_windir|a_workingdir|a_yday|a_year|a_yweek|a_yyyy|clipboard|clipboardall|comspec|errorlevel)\b/i,
+ 'constant': /\b(?:a_ahkpath|a_ahkversion|a_appdata|a_appdatacommon|a_autotrim|a_batchlines|a_caretx|a_carety|a_computername|a_controldelay|a_cursor|a_dd|a_ddd|a_dddd|a_defaultmousespeed|a_desktop|a_desktopcommon|a_detecthiddentext|a_detecthiddenwindows|a_endchar|a_eventinfo|a_exitreason|a_fileencoding|a_formatfloat|a_formatinteger|a_gui|a_guievent|a_guicontrol|a_guicontrolevent|a_guiheight|a_guiwidth|a_guix|a_guiy|a_hour|a_iconfile|a_iconhidden|a_iconnumber|a_icontip|a_index|a_ipaddress1|a_ipaddress2|a_ipaddress3|a_ipaddress4|a_is64bitos|a_isadmin|a_iscompiled|a_iscritical|a_ispaused|a_issuspended|a_isunicode|a_keydelay|a_language|a_lasterror|a_linefile|a_linenumber|a_loopfield|a_loopfileattrib|a_loopfiledir|a_loopfileext|a_loopfilefullpath|a_loopfilelongpath|a_loopfilename|a_loopfileshortname|a_loopfileshortpath|a_loopfilesize|a_loopfilesizekb|a_loopfilesizemb|a_loopfiletimeaccessed|a_loopfiletimecreated|a_loopfiletimemodified|a_loopreadline|a_loopregkey|a_loopregname|a_loopregsubkey|a_loopregtimemodified|a_loopregtype|a_mday|a_min|a_mm|a_mmm|a_mmmm|a_mon|a_mousedelay|a_msec|a_mydocuments|a_now|a_nowutc|a_numbatchlines|a_ostype|a_osversion|a_priorhotkey|a_priorkey|programfiles|a_programfiles|a_programs|a_programscommon|a_ptrsize|a_regview|a_screendpi|a_screenheight|a_screenwidth|a_scriptdir|a_scriptfullpath|a_scripthwnd|a_scriptname|a_sec|a_space|a_startmenu|a_startmenucommon|a_startup|a_startupcommon|a_stringcasesense|a_tab|a_temp|a_thisfunc|a_thishotkey|a_thislabel|a_thismenu|a_thismenuitem|a_thismenuitempos|a_tickcount|a_timeidle|a_timeidlephysical|a_timesincepriorhotkey|a_timesincethishotkey|a_titlematchmode|a_titlematchmodespeed|a_username|a_wday|a_windelay|a_windir|a_workingdir|a_yday|a_year|a_yweek|a_yyyy|clipboard|clipboardall|comspec|errorlevel)\b/i,
- 'builtin': /\b(?:abs|acos|asc|asin|atan|ceil|chr|class|cos|dllcall|exp|fileexist|Fileopen|floor|il_add|il_create|il_destroy|instr|substr|isfunc|islabel|IsObject|ln|log|lv_add|lv_delete|lv_deletecol|lv_getcount|lv_getnext|lv_gettext|lv_insert|lv_insertcol|lv_modify|lv_modifycol|lv_setimagelist|mod|onmessage|numget|numput|registercallback|regexmatch|regexreplace|round|sin|tan|sqrt|strlen|sb_seticon|sb_setparts|sb_settext|strsplit|tv_add|tv_delete|tv_getchild|tv_getcount|tv_getnext|tv_get|tv_getparent|tv_getprev|tv_getselection|tv_gettext|tv_modify|varsetcapacity|winactive|winexist|__New|__Call|__Get|__Set)\b/i,
+ 'builtin': /\b(?:abs|acos|asc|asin|atan|ceil|chr|class|comobjactive|comobjarray|comobjconnect|comobjcreate|comobjerror|comobjflags|comobjget|comobjquery|comobjtype|comobjvalue|cos|dllcall|exp|fileexist|Fileopen|floor|format|il_add|il_create|il_destroy|instr|substr|isfunc|islabel|IsObject|ln|log|lv_add|lv_delete|lv_deletecol|lv_getcount|lv_getnext|lv_gettext|lv_insert|lv_insertcol|lv_modify|lv_modifycol|lv_setimagelist|ltrim|rtrim|mod|onmessage|numget|numput|registercallback|regexmatch|regexreplace|round|sin|tan|sqrt|strlen|strreplace|sb_seticon|sb_setparts|sb_settext|strsplit|tv_add|tv_delete|tv_getchild|tv_getcount|tv_getnext|tv_get|tv_getparent|tv_getprev|tv_getselection|tv_gettext|tv_modify|varsetcapacity|winactive|winexist|__New|__Call|__Get|__Set)\b/i,
'symbol': /\b(?:alt|altdown|altup|appskey|backspace|browser_back|browser_favorites|browser_forward|browser_home|browser_refresh|browser_search|browser_stop|bs|capslock|ctrl|ctrlbreak|ctrldown|ctrlup|del|delete|down|end|enter|esc|escape|f1|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f2|f20|f21|f22|f23|f24|f3|f4|f5|f6|f7|f8|f9|home|ins|insert|joy1|joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|joy19|joy2|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|joy28|joy29|joy3|joy30|joy31|joy32|joy4|joy5|joy6|joy7|joy8|joy9|joyaxes|joybuttons|joyinfo|joyname|joypov|joyr|joyu|joyv|joyx|joyy|joyz|lalt|launch_app1|launch_app2|launch_mail|launch_media|lbutton|lcontrol|lctrl|left|lshift|lwin|lwindown|lwinup|mbutton|media_next|media_play_pause|media_prev|media_stop|numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9|numpadadd|numpadclear|numpaddel|numpaddiv|numpaddot|numpaddown|numpadend|numpadenter|numpadhome|numpadins|numpadleft|numpadmult|numpadpgdn|numpadpgup|numpadright|numpadsub|numpadup|pgdn|pgup|printscreen|ralt|rbutton|rcontrol|rctrl|right|rshift|rwin|rwindown|rwinup|scrolllock|shift|shiftdown|shiftup|space|tab|up|volume_down|volume_mute|volume_up|wheeldown|wheelleft|wheelright|wheelup|xbutton1|xbutton2)\b/i,
- 'important': /#\b(?:AllowSameLineComments|ClipboardTimeout|CommentFlag|ErrorStdOut|EscapeChar|HotkeyInterval|HotkeyModifierTimeout|Hotstring|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Include|IncludeAgain|InstallKeybdHook|InstallMouseHook|KeyHistory|LTrim|MaxHotkeysPerInterval|MaxMem|MaxThreads|MaxThreadsBuffer|MaxThreadsPerHotkey|NoEnv|NoTrayIcon|Persistent|SingleInstance|UseHook|WinActivateForce)\b/i,
+ 'important': /#\b(?:AllowSameLineComments|ClipboardTimeout|CommentFlag|DerefChar|ErrorStdOut|EscapeChar|HotkeyInterval|HotkeyModifierTimeout|Hotstring|If|IfTimeout|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Include|IncludeAgain|InputLevel|InstallKeybdHook|InstallMouseHook|KeyHistory|MaxHotkeysPerInterval|MaxMem|MaxThreads|MaxThreadsBuffer|MaxThreadsPerHotkey|MenuMaskKey|NoEnv|NoTrayIcon|Persistent|SingleInstance|UseHook|Warn|WinActivateForce)\b/i,
- 'keyword': /\b(?:Abort|AboveNormal|Add|ahk_class|ahk_group|ahk_id|ahk_pid|All|Alnum|Alpha|AltSubmit|AltTab|AltTabAndMenu|AltTabMenu|AltTabMenuDismiss|AlwaysOnTop|AutoSize|Background|BackgroundTrans|BelowNormal|between|BitAnd|BitNot|BitOr|BitShiftLeft|BitShiftRight|BitXOr|Bold|Border|Button|ByRef|Checkbox|Checked|CheckedGray|Choose|ChooseString|Close|Color|ComboBox|Contains|ControlList|Count|Date|DateTime|Days|DDL|Default|DeleteAll|Delimiter|Deref|Destroy|Digit|Disable|Disabled|DropDownList|Edit|Eject|Else|Enable|Enabled|Error|Exist|Expand|ExStyle|FileSystem|First|Flash|Float|FloatFast|Focus|Font|for|global|Grid|Group|GroupBox|GuiClose|GuiContextMenu|GuiDropFiles|GuiEscape|GuiSize|Hdr|Hidden|Hide|High|HKCC|HKCR|HKCU|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_LOCAL_MACHINE|HKEY_USERS|HKLM|HKU|Hours|HScroll|Icon|IconSmall|ID|IDLast|If|IfEqual|IfExist|IfGreater|IfGreaterOrEqual|IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Ignore|ImageList|in|Integer|IntegerFast|Interrupt|is|italic|Join|Label|LastFound|LastFoundExist|Limit|Lines|List|ListBox|ListView|local|Lock|Logoff|Low|Lower|Lowercase|MainWindow|Margin|Maximize|MaximizeBox|MaxSize|Minimize|MinimizeBox|MinMax|MinSize|Minutes|MonthCal|Mouse|Move|Multi|NA|No|NoActivate|NoDefault|NoHide|NoIcon|NoMainWindow|norm|Normal|NoSort|NoSortHdr|NoStandard|Not|NoTab|NoTimers|Number|Off|Ok|On|OwnDialogs|Owner|Parse|Password|Picture|Pixel|Pos|Pow|Priority|ProcessName|Radio|Range|Read|ReadOnly|Realtime|Redraw|REG_BINARY|REG_DWORD|REG_EXPAND_SZ|REG_MULTI_SZ|REG_SZ|Region|Relative|Rename|Report|Resize|Restore|Retry|RGB|Screen|Seconds|Section|Serial|SetLabel|ShiftAltTab|Show|Single|Slider|SortDesc|Standard|static|Status|StatusBar|StatusCD|strike|Style|Submit|SysMenu|Tab2|TabStop|Text|Theme|Tile|ToggleCheck|ToggleEnable|ToolWindow|Top|Topmost|TransColor|Transparent|Tray|TreeView|TryAgain|Type|UnCheck|underline|Unicode|Unlock|UpDown|Upper|Uppercase|UseErrorLevel|Vis|VisFirst|Visible|VScroll|Wait|WaitClose|WantCtrlA|WantF2|WantReturn|While|Wrap|Xdigit|xm|xp|xs|Yes|ym|yp|ys)\b/i
+ 'keyword': /\b(?:Abort|AboveNormal|Add|ahk_class|ahk_exe|ahk_group|ahk_id|ahk_pid|All|Alnum|Alpha|AltSubmit|AltTab|AltTabAndMenu|AltTabMenu|AltTabMenuDismiss|AlwaysOnTop|AutoSize|Background|BackgroundTrans|BelowNormal|between|BitAnd|BitNot|BitOr|BitShiftLeft|BitShiftRight|BitXOr|Bold|Border|Button|ByRef|Checkbox|Checked|CheckedGray|Choose|ChooseString|Close|Color|ComboBox|Contains|ControlList|Count|Date|DateTime|Days|DDL|Default|DeleteAll|Delimiter|Deref|Destroy|Digit|Disable|Disabled|DropDownList|Edit|Eject|Else|Enable|Enabled|Error|Exist|Expand|ExStyle|FileSystem|First|Flash|Float|FloatFast|Focus|Font|for|global|Grid|Group|GroupBox|GuiClose|GuiContextMenu|GuiDropFiles|GuiEscape|GuiSize|Hdr|Hidden|Hide|High|HKCC|HKCR|HKCU|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_LOCAL_MACHINE|HKEY_USERS|HKLM|HKU|Hours|HScroll|Icon|IconSmall|ID|IDLast|If|IfEqual|IfExist|IfGreater|IfGreaterOrEqual|IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Ignore|ImageList|in|Integer|IntegerFast|Interrupt|is|italic|Join|Label|LastFound|LastFoundExist|Limit|Lines|List|ListBox|ListView|local|Lock|Logoff|Low|Lower|Lowercase|MainWindow|Margin|Maximize|MaximizeBox|MaxSize|Minimize|MinimizeBox|MinMax|MinSize|Minutes|MonthCal|Mouse|Move|Multi|NA|No|NoActivate|NoDefault|NoHide|NoIcon|NoMainWindow|norm|Normal|NoSort|NoSortHdr|NoStandard|Not|NoTab|NoTimers|Number|Off|Ok|On|OwnDialogs|Owner|Parse|Password|Picture|Pixel|Pos|Pow|Priority|ProcessName|Radio|Range|Read|ReadOnly|Realtime|Redraw|REG_BINARY|REG_DWORD|REG_EXPAND_SZ|REG_MULTI_SZ|REG_SZ|Region|Relative|Rename|Report|Resize|Restore|Retry|RGB|Screen|Seconds|Section|Serial|SetLabel|ShiftAltTab|Show|Single|Slider|SortDesc|Standard|static|Status|StatusBar|StatusCD|strike|Style|Submit|SysMenu|Tab2|TabStop|Text|Theme|Tile|ToggleCheck|ToggleEnable|ToolWindow|Top|Topmost|TransColor|Transparent|Tray|TreeView|TryAgain|Throw|Try|Catch|Finally|Type|UnCheck|underline|Unicode|Unlock|Until|UpDown|Upper|Uppercase|UseErrorLevel|Vis|VisFirst|Visible|VScroll|Wait|WaitClose|WantCtrlA|WantF2|WantReturn|While|Wrap|Xdigit|xm|xp|xs|Yes|ym|yp|ys)\b/i,
+ 'function': /[^(); \t,\n+*\-=?>:\\\/<&%\[\]]+?(?=\()/m,
+ 'punctuation': /[{}[\]():,]/
};
return Prism; })
\ No newline at end of file
},
'variable': insideString.variable,
'function': {
- pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|aptitude|apt-cache|apt-get|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
+ pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|aptitude|apt-cache|apt-get|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
lookbehind: true
},
'keyword': {
'punctuation': /:/
}
};
- var string = /"[^"]*"/;
+ var string = /"(?:[\\"]"|[^"])*"(?!")/;
var number = /(?:\b|-)\d+\b/;
Prism.languages.batch = {
},
{
// Other commands
- pattern: /((?:^|[&(])[ \t]*@?)\w+\b(?:[^^&)\r\n]|\^(?:\r\n|[\s\S]))*/im,
+ pattern: /((?:^|[&(])[ \t]*@?)\w+\b(?:"(?:[\\"]"|[^"])*"(?!")|[^"^&)\r\n]|\^(?:\r\n|[\s\S]))*/im,
lookbehind: true,
inside: {
'keyword': /^\w+\b/i,
'punctuation': /[()']/
};
}(Prism));
+
return Prism; })
\ No newline at end of file
'macro': {
// allow for multiline macro definitions
// spaces after the # character compile fine with gcc
- pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im,
+ pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
lookbehind: true,
+ greedy: true,
alias: 'property',
inside: {
- // highlight the path of the include statement as a string
- 'string': {
- pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/,
- lookbehind: true
- },
+ 'string': [
+ {
+ // highlight the path of the include statement as a string
+ pattern: /^(#\s*include\s*)<[^>]+>/,
+ lookbehind: true
+ },
+ Prism.languages.c['string']
+ ],
+ 'comment': Prism.languages.c['comment'],
// highlight macro directives as keywords
'directive': {
- pattern: /(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,
+ pattern: /^(#\s*)[a-z]+/,
lookbehind: true,
alias: 'keyword'
+ },
+ 'directive-hash': /^#/,
+ 'punctuation': /##|\\(?=[\r\n])/,
+ 'expression': {
+ pattern: /\S[\s\S]*/,
+ inside: Prism.languages.c
}
}
},
define(["prism/prism","prism/components/prism-c"], function () {
-Prism.languages.cpp = Prism.languages.extend('c', {
- 'class-name': {
- pattern: /(\b(?:class|enum|struct)\s+)\w+/,
- lookbehind: true
- },
- 'keyword': /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char8_t|char16_t|char32_t|class|compl|concept|const|consteval|constexpr|constinit|const_cast|continue|co_await|co_return|co_yield|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,
- 'number': {
- pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,
- greedy: true
- },
- 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
- 'boolean': /\b(?:true|false)\b/
-});
+(function (Prism) {
-Prism.languages.insertBefore('cpp', 'string', {
- 'raw-string': {
- pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
- alias: 'string',
- greedy: true
- }
-});
+ var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char8_t|char16_t|char32_t|class|compl|concept|const|consteval|constexpr|constinit|const_cast|continue|co_await|co_return|co_yield|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
+
+ Prism.languages.cpp = Prism.languages.extend('c', {
+ 'class-name': [
+ {
+ pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source
+ .replace(/<keyword>/g, function () { return keyword.source; })),
+ lookbehind: true
+ },
+ // This is intended to capture the class name of method implementations like:
+ // void foo::bar() const {}
+ // However! The `foo` in the above example could also be a namespace, so we only capture the class name if
+ // it starts with an uppercase letter. This approximation should give decent results.
+ /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
+ // This will capture the class name before destructors like:
+ // Foo::~Foo() {}
+ /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
+ // This also intends to capture the class name of method implementations but here the class has template
+ // parameters, so it can't be a namespace (until C++ adds generic namespaces).
+ /\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/
+ ],
+ 'keyword': keyword,
+ 'number': {
+ pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,
+ greedy: true
+ },
+ 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
+ 'boolean': /\b(?:true|false)\b/
+ });
+
+ Prism.languages.insertBefore('cpp', 'string', {
+ 'raw-string': {
+ pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
+ alias: 'string',
+ greedy: true
+ }
+ });
+
+ Prism.languages.insertBefore('cpp', 'class-name', {
+ // the base clause is an optional list of parent classes
+ // https://en.cppreference.com/w/cpp/language/class
+ 'base-clause': {
+ pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)(?:[^;{}"'])+?(?=\s*[;{])/,
+ lookbehind: true,
+ greedy: true,
+ inside: Prism.languages.extend('cpp', {})
+ }
+ });
+ Prism.languages.insertBefore('inside', 'operator', {
+ // All untokenized words that are not namespaces should be class names
+ 'class-name': /\b[a-z_]\w*\b(?!\s*::)/i
+ }, Prism.languages.cpp['base-clause']);
+
+}(Prism));
return Prism; })
\ No newline at end of file
typeDeclaration: 'class enum interface struct',
// contextual keywords
// ("var" and "dynamic" are missing because they are used like types)
- contextual: 'add alias ascending async await by descending from get global group into join let nameof notnull on orderby partial remove select set unmanaged value when where where',
+ contextual: 'add alias and ascending async await by descending from get global group into join let nameof not notnull on or orderby partial remove select set unmanaged value when where where',
// all other keywords
other: 'abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield'
};
var genericName = replace(/<<0>>(?:\s*<<1>>)?/.source, [name, generic]);
var identifier = replace(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source, [nonTypeKeywords, genericName]);
var array = /\[\s*(?:,\s*)*\]/.source;
+ var typeExpressionWithoutTuple = replace(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source, [identifier, array]);
var tupleElement = replace(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source, [generic, nestedRound, array])
var tuple = replace(/\(<<0>>+(?:,<<0>>+)+\)/.source, [tupleElement]);
var typeExpression = replace(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source, [tuple, identifier, array]);
// Casts and checks via as and is.
// as Foo<A>, is Bar<B>
// (things like if(a is Foo b) is covered by variable declaration)
- pattern: re(/(\b(?:is|as)\s+)<<0>>/.source, [typeExpression]),
+ pattern: re(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source, [typeExpressionWithoutTuple]),
lookbehind: true,
inside: typeInside
},
{
// Variable, field and parameter declaration
// (Foo bar, Bar baz, Foo[,,] bay, Foo<Bar, FooBar<Bar>> bax)
- pattern: re(/\b<<0>>(?=\s+(?!<<1>>)<<2>>(?:\s*[=,;:{)\]]|\s+in))/.source, [typeExpression, nonContextualKeywords, name]),
+ pattern: re(/\b<<0>>(?=\s+(?!<<1>>)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source, [typeExpression, nonContextualKeywords, name]),
inside: typeInside
}
],
// attributes
var regularStringOrCharacter = regularString + '|' + character;
- var regularStringCharacterOrComment = replace(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*[\s\S]*?\*\/|<<0>>/.source, [regularStringOrCharacter]);
+ var regularStringCharacterOrComment = replace(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>/.source, [regularStringOrCharacter]);
var roundExpression = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
// https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/attributes/#attribute-targets
var mInterpolationRound = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2)
var mInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [mInterpolationRound, formatString]);
// single line
- var sInterpolationRound = nested(replace(/[^"'/()]|\/(?!\*)|\/\*.*?\*\/|<<0>>|\(<<self>>*\)/.source, [regularStringOrCharacter]), 2)
+ var sInterpolationRound = nested(replace(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source, [regularStringOrCharacter]), 2)
var sInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [sInterpolationRound, formatString]);
function createInterpolationInside(interpolation, interpolationRound) {
return {
'interpolation': {
- pattern: re(/([^{](?:\{\{)*)<<0>>/.source, [interpolation]),
+ pattern: re(/((?:^|[^{])(?:\{\{)*)<<0>>/.source, [interpolation]),
lookbehind: true,
inside: {
'format-string': {
Prism.languages.csp = {
'directive': {
- pattern: /\b(?:(?:base-uri|form-action|frame-ancestors|plugin-types|referrer|reflected-xss|report-to|report-uri|require-sri-for|sandbox) |(?:block-all-mixed-content|disown-opener|upgrade-insecure-requests)(?: |;)|(?:child|connect|default|font|frame|img|manifest|media|object|script|style|worker)-src )/i,
+ pattern: /\b(?:base-uri|block-all-mixed-content|(?:child|connect|default|font|frame|img|manifest|media|object|script|style|worker)-src|disown-opener|form-action|frame-ancestors|plugin-types|referrer|reflected-xss|report-to|report-uri|require-sri-for|sandbox|upgrade-insecure-requests)\b/i,
alias: 'keyword'
},
'safe': {
inside: selectorInside = {
'pseudo-element': /:(?:after|before|first-letter|first-line|selection)|::[-\w]+/,
'pseudo-class': /:[-\w]+/,
- 'class': /\.[-:.\w]+/,
- 'id': /#[-:.\w]+/,
+ 'class': /\.[-\w]+/,
+ 'id': /#[-\w]+/,
'attribute': {
pattern: RegExp('\\[(?:[^[\\]"\']|' + string.source + ')*\\]'),
greedy: true,
'punctuation': /\|$/
}
},
- 'attribute': {
+ 'attr-name': {
pattern: /^(\s*)[-\w\xA0-\uFFFF]+/,
lookbehind: true
},
- 'value': [
+ 'attr-value': [
string,
{
pattern: /(=\s*)[-\w\xA0-\uFFFF]+(?=\s*$)/,
lookbehind: true
}
],
- 'punctuation': /[()]/
+ 'combinator': />|\+|~|\|\|/,
+
+ // the `tag` token has been existed and removed.
+ // because we can't find a perfect tokenize to match it.
+ // if you want to add it, please read https://github.com/PrismJS/prism/pull/2373 first.
+
+ 'punctuation': /[(),]/,
}
};
});
var unit = {
- pattern: /(\d)(?:%|[a-z]+)/,
+ pattern: /(\b\d+)(?:%|[a-z]+\b)/,
lookbehind: true
};
// 123 -123 .123 -.123 12.3 -12.3
}
}
],
+ // it's important that there is no boundary assertion after the hex digits
'entity': /\\[\da-f]{1,8}/i,
'unit': unit,
'number': number
pattern: /(\bselector\s*\((?!\s*\))\s*)(?:[^()]|\((?:[^()]|\([^()]*\))*\))+?(?=\s*\))/,
lookbehind: true,
alias: 'selector'
+ },
+ 'keyword': {
+ pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
+ lookbehind: true
}
// See rest below
}
},
'url': {
- pattern: RegExp('url\\((?:' + string.source + '|[^\n\r()]*)\\)', 'i'),
+ // https://drafts.csswg.org/css-values-3/#urls
+ pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
greedy: true,
inside: {
'function': /^url/i,
- 'punctuation': /^\(|\)$/
+ 'punctuation': /^\(|\)$/,
+ 'string': {
+ pattern: RegExp('^' + string.source + '$'),
+ alias: 'url'
+ }
}
},
'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'),
--- /dev/null
+define(["prism/prism"], function () {
+Prism.languages.cypher = {
+ // https://neo4j.com/docs/cypher-manual/current/syntax/comments/
+ 'comment': /\/\/.*/,
+ 'string': {
+ pattern: /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/,
+ greedy: true
+ },
+ 'class-name': {
+ pattern: /(:\s*)(?:\w+|`(?:[^`\\\r\n])*`)(?=\s*[{):])/,
+ lookbehind: true,
+ greedy: true
+ },
+ 'relationship': {
+ pattern: /(-\[\s*(?:\w+\s*|`(?:[^`\\\r\n])*`\s*)?:\s*|\|\s*:\s*)(?:\w+|`(?:[^`\\\r\n])*`)/,
+ lookbehind: true,
+ greedy: true,
+ alias: 'property'
+ },
+ 'identifier': {
+ pattern: /`(?:[^`\\\r\n])*`/,
+ greedy: true,
+ alias: 'symbol'
+ },
+
+ 'variable': /\$\w+/,
+
+ // https://neo4j.com/docs/cypher-manual/current/syntax/reserved/
+ 'keyword': /\b(?:ADD|ALL|AND|AS|ASC|ASCENDING|ASSERT|BY|CALL|CASE|COMMIT|CONSTRAINT|CONTAINS|CREATE|CSV|DELETE|DESC|DESCENDING|DETACH|DISTINCT|DO|DROP|ELSE|END|ENDS|EXISTS|FOR|FOREACH|IN|INDEX|IS|JOIN|KEY|LIMIT|LOAD|MANDATORY|MATCH|MERGE|NODE|NOT|OF|ON|OPTIONAL|OR|ORDER(?=\s+BY)|PERIODIC|REMOVE|REQUIRE|RETURN|SCALAR|SCAN|SET|SKIP|START|STARTS|THEN|UNION|UNIQUE|UNWIND|USING|WHEN|WHERE|WITH|XOR|YIELD)\b/i,
+
+ 'function': /\b\w+\b(?=\s*\()/,
+
+ 'boolean': /\b(?:true|false|null)\b/i,
+ 'number': /\b(?:0x[\da-fA-F]+|\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b/,
+ // https://neo4j.com/docs/cypher-manual/current/syntax/operators/
+ 'operator': /:|<--?|--?>?|<>|=~?|[<>]=?|[+*/%^|]|\.\.\.?/,
+ 'punctuation': /[()[\]{},;.]/
+};
+
+return Prism; })
\ No newline at end of file
pattern: RegExp(/(^|[^\\])/.source + '(?:' + [
// /+ comment +/
// Allow one level of nesting
- /\/\+(?:\/\+[\s\S]*?\+\/|(?!\/\+)[\s\S])*?\+\//.source,
+ /\/\+(?:\/\+(?:[^+]|\+(?!\/))*\+\/|(?!\/\+)[\s\S])*?\+\//.source,
// // comment
/\/\/.*/.source,
// /* comment */
],
'keyword': [
/\b(?:async|sync|yield)\*/,
- /\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|default|deferred|do|dynamic|else|enum|export|external|extends|factory|final|finally|for|get|if|implements|import|in|library|new|null|operator|part|rethrow|return|set|static|super|switch|this|throw|try|typedef|var|void|while|with|yield)\b/
+ /\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|covariant|default|deferred|do|dynamic|else|enum|export|extension|external|extends|factory|final|finally|for|Function|get|hide|if|implements|interface|import|in|library|mixin|new|null|on|operator|part|rethrow|return|set|show|static|super|switch|sync|this|throw|try|typedef|var|void|while|with|yield)\b/
],
'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/
});
alias: 'symbol'
}
});
+
return Prism; })
\ No newline at end of file
--- /dev/null
+define(["prism/prism"], function () {
+// ABNF grammar:
+// https://github.com/dhall-lang/dhall-lang/blob/master/standard/dhall.abnf
+
+Prism.languages.dhall = {
+ // Multi-line comments can be nested. E.g. {- foo {- bar -} -}
+ // The multi-line pattern is essentially this:
+ // \{-(?:[^-{]|-(?!\})|\{(?!-)|<SELF>)*-\}
+ 'comment': /--.*|\{-(?:[^-{]|-(?!\})|\{(?!-)|\{-(?:[^-{]|-(?!\})|\{(?!-))*-\})*-\}/,
+ 'string': {
+ pattern: /"(?:[^"\\]|\\.)*"|''(?:[^']|'(?!')|'''|''\$\{)*''(?!'|\$)/,
+ greedy: true,
+ inside: {
+ 'interpolation': {
+ pattern: /\$\{[^{}]*\}/,
+ inside: {
+ 'expression': {
+ pattern: /(^\$\{)[\s\S]+(?=\}$)/,
+ lookbehind: true,
+ alias: 'language-dhall',
+ inside: null // see blow
+ },
+ 'punctuation': /\$\{|\}/
+ }
+ }
+ }
+ },
+ 'label': {
+ pattern: /`[^`]*`/,
+ greedy: true
+ },
+ 'url': {
+ // https://github.com/dhall-lang/dhall-lang/blob/5fde8ef1bead6fb4e999d3c1ffe7044cd019d63a/standard/dhall.abnf#L596
+ pattern: /\bhttps?:\/\/[\w.:%!$&'*+;=@~-]+(?:\/[\w.:%!$&'*+;=@~-]*)*(?:\?[/?\w.:%!$&'*+;=@~-]*)?/,
+ greedy: true
+ },
+ 'env': {
+ // https://github.com/dhall-lang/dhall-lang/blob/5fde8ef1bead6fb4e999d3c1ffe7044cd019d63a/standard/dhall.abnf#L661
+ pattern: /\benv:(?:(?!\d)\w+|"(?:[^"\\=]|\\.)*")/,
+ greedy: true,
+ inside: {
+ 'function': /^env/,
+ 'operator': /^:/,
+ 'variable': /[\s\S]+/
+ }
+ },
+ 'hash': {
+ // https://github.com/dhall-lang/dhall-lang/blob/5fde8ef1bead6fb4e999d3c1ffe7044cd019d63a/standard/dhall.abnf#L725
+ pattern: /\bsha256:[\da-fA-F]{64}\b/,
+ inside: {
+ 'function': /sha256/,
+ 'operator': /:/,
+ 'number': /[\da-fA-F]{64}/
+ }
+ },
+
+ // https://github.com/dhall-lang/dhall-lang/blob/5fde8ef1bead6fb4e999d3c1ffe7044cd019d63a/standard/dhall.abnf#L359
+ 'keyword': /\b(?:as|assert|else|forall|if|in|let|merge|missing|then|toMap|using|with)\b|\u2200/,
+ 'builtin': /\b(?:Some|None)\b/,
+
+ 'boolean': /\b(?:False|True)\b/,
+ 'number': /\bNaN\b|-?\bInfinity\b|[+-]?\b(?:0x[\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/,
+ 'operator': /\/\\|\/\/\\\\|&&|\|\||[!=]=|===|\/\/|->|\+\+|::|[+*#@=:?<>|\\\u2227\u2a53\u2261\u2afd\u03bb\u2192]/,
+ 'punctuation': /\.\.|[{}\[\](),./]/,
+
+ // we'll just assume that every capital word left is a type name
+ 'class-name': /\b[A-Z]\w*\b/
+};
+
+Prism.languages.dhall.string.inside.interpolation.inside.expression.inside = Prism.languages.dhall;
+
+return Prism; })
\ No newline at end of file
}
Prism.languages.diff[name] = {
- // pattern: /^(?:[_].*(?:\r\n?|\n|(?![\s\S])))+/m
pattern: RegExp('^(?:[' + prefix + '].*(?:\r\n?|\n|(?![\\s\\S])))+', 'm'),
- alias: alias
+ alias: alias,
+ inside: {
+ 'line': {
+ pattern: /(.)(?=[\s\S]).*(?:\r\n?|\n)?/,
+ lookbehind: true
+ },
+ 'prefix': {
+ pattern: /[\s\S]/,
+ alias: /\w+/.exec(name)[0]
+ }
+ }
};
+
});
// make prefixes available to Diff plugin
lookbehind: true
},
'string': /("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/,
- 'comment': /#.*/,
+ 'comment': {
+ pattern: /#.*/,
+ greedy: true
+ },
'punctuation': /---|\.\.\.|[:[\]{}\-,|>?]/
};
lookbehind: true,
alias: ['rule', 'keyword']
},
- 'rule': /[a-z]\w*(?:[ \t]+[a-z]\w*)*/i,
+ 'rule': /\b[a-z]\w*(?:[ \t]+[a-z]\w*)*\b/i,
'punctuation': /\([:/]|[:/]\)|[.,;()[\]{}]/,
'operator': /[-=|*/!]/
--- /dev/null
+define(["prism/prism"], function () {
+Prism.languages.editorconfig = {
+ // https://editorconfig-specification.readthedocs.io/en/latest/
+ 'comment': /[;#].*/,
+ 'section': {
+ pattern: /(^[ \t]*)\[.+]/m,
+ lookbehind: true,
+ alias: 'keyword',
+ inside: {
+ 'regex': /\\\\[\[\]{},!?.*]/, // Escape special characters with '\\'
+ 'operator': /[!?]|\.\.|\*{1,2}/,
+ 'punctuation': /[\[\]{},]/
+ }
+ },
+ 'property': {
+ pattern: /(^[ \t]*)[^\s=]+(?=[ \t]*=)/m,
+ lookbehind: true
+ },
+ 'value': {
+ pattern: /=.*/,
+ alias: 'string',
+ inside: {
+ 'punctuation': /^=/
+ }
+ }
+};
+
+return Prism; })
\ No newline at end of file
},
// Single-line string
{
- pattern: /"(?:%\s+%|%.|[^%"\r\n])*"/,
+ pattern: /"(?:%\s*\n\s*%|%.|[^%"\r\n])*"/,
greedy: true
}
],
// hexa | octal | bin
/\b0[xcb][\da-f](?:_*[\da-f])*\b/i,
// Decimal
- /(?:\d(?:_*\d)*)?\.(?:(?:\d(?:_*\d)*)?e[+-]?)?\d(?:_*\d)*|\d(?:_*\d)*\.?/i
+ /(?:\b\d(?:_*\d)*)?\.(?:(?:\d(?:_*\d)*)?e[+-]?)?\d(?:_*\d)*\b|\b\d(?:_*\d)*\b\.?/i
],
'punctuation': /:=|<<|>>|\(\||\|\)|->|\.(?=\w)|[{}[\];(),:?]/,
'operator': /\\\\|\|\.\.\||\.\.|\/[~\/=]?|[><]=?|[-+*^=~]/
Prism.languages['markup-templating'].tokenizePlaceholders(env, 'ejs');
});
+ Prism.languages.eta = Prism.languages.ejs;
+
}(Prism));
return Prism; })
\ No newline at end of file
'string': [
{
// ~s"""foo""" (multi-line), ~s'''foo''' (multi-line), ~s/foo/, ~s|foo|, ~s"foo", ~s'foo', ~s(foo), ~s[foo], ~s{foo} (with interpolation care), ~s<foo>
- pattern: /~[cCsSwW](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|#\{[^}]+\}|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[csa]?/,
+ pattern: /~[cCsSwW](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|#\{[^}]+\}|#(?!\{)|[^#\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[csa]?/,
greedy: true,
inside: {
// See interpolation below
}
},
'function-name': {
- pattern: /[A-Z]\w*(?=\()/i,
+ pattern: /\b[A-Z]\w*(?=\()/i,
alias: 'keyword'
},
'range': {
- pattern: /\$?(?:[A-Z]+\$?\d+:\$?[A-Z]+\$?\d+|[A-Z]+:\$?[A-Z]+|\d+:\$?\d+)/i,
+ pattern: /\$?\b(?:[A-Z]+\$?\d+:\$?[A-Z]+\$?\d+|[A-Z]+:\$?[A-Z]+|\d+:\$?\d+)\b/i,
alias: 'property',
inside: {
'operator': /:/,
'cell': {
// Excel is case insensitive, so the string "foo1" could be either a variable or a cell.
// To combat this, we match cells case insensitive, if the contain at least one "$", and case sensitive otherwise.
- pattern: /[A-Z]+\d+|\$[A-Za-z]+\$?\d+|[A-Za-z]+\$\d+/,
+ pattern: /\b[A-Z]+\d+\b|\$[A-Za-z]+\$?\d+\b|\b[A-Za-z]+\$\d+\b/,
alias: 'property'
},
'number': /(?:\b\d+(?:\.\d+)?|\B\.\d+)(?:e[+-]?\d+)?\b/i,
// https://freemarker.apache.org/docs/dgui_template_exp.html
// FTL expression with 4 levels of nesting supported
- var FTL_EXPR = /(?!<#--)[^()"']|\((?:<expr>)*\)|<#--[\s\S]*?-->|"(?:[^\\"]|\\.)*"|'(?:[^\\']|\\.)*'/.source;
+ var FTL_EXPR = /[^<()"']|\((?:<expr>)*\)|<(?!#--)|<#--(?:[^-]|-(?!->))*-->|"(?:[^\\"]|\\.)*"|'(?:[^\\']|\\.)*'/.source;
for (var i = 0; i < 2; i++) {
FTL_EXPR = FTL_EXPR.replace(/<expr>/g, function () { return FTL_EXPR; });
}
- FTL_EXPR = FTL_EXPR.replace(/<expr>/g, '[^\s\S]');
+ FTL_EXPR = FTL_EXPR.replace(/<expr>/g, /[^\s\S]/.source);
var ftl = {
'comment': /<#--[\s\S]*?-->/,
-define(["prism/prism","prism/components/prism-clike"], function () {
-Prism.languages.glsl = Prism.languages.extend('clike', {
- 'comment': [
- /\/\*[\s\S]*?\*\//,
- /\/\/(?:\\(?:\r\n|[\s\S])|[^\\\r\n])*/
- ],
- 'number': /(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ulf]*/i,
+define(["prism/prism","prism/components/prism-c"], function () {
+Prism.languages.glsl = Prism.languages.extend('c', {
'keyword': /\b(?:attribute|const|uniform|varying|buffer|shared|coherent|volatile|restrict|readonly|writeonly|atomic_uint|layout|centroid|flat|smooth|noperspective|patch|sample|break|continue|do|for|while|switch|case|default|if|else|subroutine|in|out|inout|float|double|int|void|bool|true|false|invariant|precise|discard|return|d?mat[234](?:x[234])?|[ibdu]?vec[234]|uint|lowp|mediump|highp|precision|[iu]?sampler[123]D|[iu]?samplerCube|sampler[12]DShadow|samplerCubeShadow|[iu]?sampler[12]DArray|sampler[12]DArrayShadow|[iu]?sampler2DRect|sampler2DRectShadow|[iu]?samplerBuffer|[iu]?sampler2DMS(?:Array)?|[iu]?samplerCubeArray|samplerCubeArrayShadow|[iu]?image[123]D|[iu]?image2DRect|[iu]?imageCube|[iu]?imageBuffer|[iu]?image[12]DArray|[iu]?imageCubeArray|[iu]?image2DMS(?:Array)?|struct|common|partition|active|asm|class|union|enum|typedef|template|this|resource|goto|inline|noinline|public|static|extern|external|interface|long|short|half|fixed|unsigned|superp|input|output|hvec[234]|fvec[234]|sampler3DRect|filter|sizeof|cast|namespace|using)\b/
});
-Prism.languages.insertBefore('glsl', 'comment', {
- 'preprocessor': {
- pattern: /(^[ \t]*)#(?:(?:define|undef|if|ifdef|ifndef|else|elif|endif|error|pragma|extension|version|line)\b)?/m,
- lookbehind: true,
- alias: 'builtin'
- }
-});
return Prism; })
\ No newline at end of file
define(["prism/prism"], function () {
Prism.languages.graphql = {
'comment': /#.*/,
+ 'description': {
+ pattern: /(?:"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*")(?=\s*[a-z_])/i,
+ greedy: true,
+ alias: 'string',
+ inside: {
+ 'language-markdown': {
+ pattern: /(^"(?:"")?)(?!\1)[\s\S]+(?=\1$)/,
+ lookbehind: true,
+ inside: Prism.languages.markdown
+ }
+ }
+ },
'string': {
- pattern: /"(?:\\.|[^\\"\r\n])*"/,
+ pattern: /"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*"/,
greedy: true
},
'number': /(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
greedy: true
},
'class-name': {
- pattern: /(\b(?:enum|implements|interface|on|scalar|type|union)\s+)[a-zA-Z_]\w*/,
+ pattern: /(\b(?:enum|implements|interface|on|scalar|type|union)\s+|&\s*)[a-zA-Z_]\w*/,
lookbehind: true
},
'fragment': {
lookbehind: true,
alias: 'function'
},
- 'keyword': /\b(?:enum|fragment|implements|input|interface|mutation|on|query|scalar|schema|type|union)\b/,
- 'operator': /[!=|]|\.{3}/,
+ 'keyword': /\b(?:directive|enum|extend|fragment|implements|input|interface|mutation|on|query|repeatable|scalar|schema|subscription|type|union)\b/,
+ 'operator': /[!=|&]|\.{3}/,
'punctuation': /[!(){}\[\]:=,]/,
'constant': /\b(?!ID\b)[A-Z][A-Z_\d]*\b/
};
Prism.languages.groovy = Prism.languages.extend('clike', {
'string': [
{
- pattern: /("""|''')(?:[^\\]|\\[\s\S])*?\1|\$\/(?:\$\/\$|[\s\S])*?\/\$/,
+ // https://groovy-lang.org/syntax.html#_dollar_slashy_string
+ pattern: /("""|''')(?:[^\\]|\\[\s\S])*?\1|\$\/(?:[^/$]|\$(?:[/$]|(?![/$]))|\/(?!\$))*\/\$/,
greedy: true
},
{
}
}
},
- {
- pattern: /[\w-]+(?=\s+{)/
- }
+ /[\w-]+(?=\s+{)/
],
'property': [
/[\w-\.]+(?=\s*=(?!=))/,
pattern: /"(?:\\[\s\S]|[^\\"])*"/,
greedy: true,
},
- 'number': /\b0x[\da-f]+|\d+\.?\d*(?:e[+-]?\d+)?/i,
+ 'number': /\b0x[\da-f]+\b|\b\d+\.?\d*(?:e[+-]?\d+)?/i,
'punctuation': /[!\$#%&'()*+,.\/;<=>@\[\\\]^`{|}~?:]/,
}
},
}
},
- 'number': /\b0x[\da-f]+|\d+\.?\d*(?:e[+-]?\d+)?/i,
+ 'number': /\b0x[\da-f]+\b|\b\d+\.?\d*(?:e[+-]?\d+)?/i,
'boolean': /\b(?:true|false)\b/i,
'punctuation': /[=\[\]{}]/,
};
--- /dev/null
+define(["prism/prism","prism/components/prism-c"], function () {
+Prism.languages.hlsl = Prism.languages.extend('c', {
+
+ // Regarding keywords and class names:
+ // The list of all keywords was split into 'keyword' and 'class-name' tokens based on whether they are capitalized.
+ // https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-keywords
+ // https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-reserved-words
+ 'class-name': [
+ Prism.languages.c['class-name'],
+ /\b(?:AppendStructuredBuffer|BlendState|Buffer|ByteAddressBuffer|CompileShader|ComputeShader|ConsumeStructuredBuffer|DepthStencilState|DepthStencilView|DomainShader|GeometryShader|Hullshader|InputPatch|LineStream|OutputPatch|PixelShader|PointStream|RasterizerState|RenderTargetView|RWBuffer|RWByteAddressBuffer|RWStructuredBuffer|RWTexture(?:1D|1DArray|2D|2DArray|3D)|SamplerComparisonState|SamplerState|StructuredBuffer|Texture(?:1D|1DArray|2D|2DArray|2DMS|2DMSArray|3D|Cube|CubeArray)|TriangleStream|VertexShader)\b/
+ ],
+ 'keyword': [
+ // HLSL keyword
+ /\b(?:asm|asm_fragment|auto|break|case|catch|cbuffer|centroid|char|class|column_major|compile|compile_fragment|const|const_cast|continue|default|delete|discard|do|dynamic_cast|else|enum|explicit|export|extern|for|friend|fxgroup|goto|groupshared|if|in|inline|inout|interface|line|lineadj|linear|long|matrix|mutable|namespace|new|nointerpolation|noperspective|operator|out|packoffset|pass|pixelfragment|point|precise|private|protected|public|register|reinterpret_cast|return|row_major|sample|sampler|shared|short|signed|sizeof|snorm|stateblock|stateblock_state|static|static_cast|string|struct|switch|tbuffer|technique|technique10|technique11|template|texture|this|throw|triangle|triangleadj|try|typedef|typename|uniform|union|unorm|unsigned|using|vector|vertexfragment|virtual|void|volatile|while)\b/,
+ // scalar, vector, and matrix types
+ /\b(?:bool|double|dword|float|half|int|min(?:10float|12int|16(?:float|int|uint))|uint)(?:[1-4](?:x[1-4])?)?\b/
+ ],
+ // https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-grammar#floating-point-numbers
+ 'number': /(?:(?:\b\d+\.?\d*|\B\.\d+)(?:[eE][+-]?\d+)?|\b0x[\da-fA-F]+)[fFhHlLuU]?\b/,
+ 'boolean': /\b(?:false|true)\b/
+});
+
+return Prism; })
\ No newline at end of file
alias: 'keyword'
},
'safe': {
- pattern: /\d{7,}/,
+ pattern: /\b\d{7,}\b/,
alias: 'selector'
},
'unsafe': {
- pattern: /\d{1,6}/,
+ pattern: /\b\d{1,6}\b/,
alias: 'function'
}
};
alias: 'keyword'
},
'safe': {
- pattern: /\d{8,}/,
+ pattern: /\b\d{8,}\b/,
alias: 'selector'
},
'unsafe': {
- pattern: /\d{1,7}/,
+ pattern: /\b\d{1,7}\b/,
alias: 'function'
}
};
--- /dev/null
+define(["prism/prism"], function () {
+Prism.languages.iecst = {
+ 'comment': [
+ {
+ pattern: /(^|[^\\])(?:\/\*[\s\S]*?(?:\*\/|$)|\(\*[\s\S]*?(?:\*\)|$)|\{[\s\S]*?(?:\}|$))/,
+ lookbehind: true,
+ },
+ {
+ pattern: /(^|[^\\:])\/\/.*/,
+ lookbehind: true,
+ greedy: true,
+ },
+ ],
+ 'string': {
+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
+ greedy: true,
+ },
+ 'class-name': /\b(?:END_)?(?:PROGRAM|CONFIGURATION|INTERFACE|FUNCTION_BLOCK|FUNCTION|ACTION|TRANSITION|TYPE|STRUCT|(?:INITIAL_)?STEP|NAMESPACE|LIBRARY|CHANNEL|FOLDER|RESOURCE|VAR_(?:GLOBAL|INPUT|PUTPUT|IN_OUT|ACCESS|TEMP|EXTERNAL|CONFIG)|VAR|METHOD|PROPERTY)\b/i,
+ 'keyword': /\b(?:(?:END_)?(?:IF|WHILE|REPEAT|CASE|FOR)|ELSE|FROM|THEN|ELSIF|DO|TO|BY|PRIVATE|PUBLIC|PROTECTED|CONSTANT|RETURN|EXIT|CONTINUE|GOTO|JMP|AT|RETAIN|NON_RETAIN|TASK|WITH|UNTIL|USING|EXTENDS|IMPLEMENTS|GET|SET|__TRY|__CATCH|__FINALLY|__ENDTRY)\b/,
+ 'variable': /\b(?:AT|BOOL|BYTE|(?:D|L)?WORD|U?(?:S|D|L)?INT|L?REAL|TIME(?:_OF_DAY)?|TOD|DT|DATE(?:_AND_TIME)?|STRING|ARRAY|ANY|POINTER)\b/,
+ 'symbol': /%[IQM][XBWDL][\d.]*|%[IQ][\d.]*/,
+ 'number': /\b(?:16#[\da-f]+|2#[01_]+|0x[\da-f]+)\b|\b(?:T|D|DT|TOD)#[\d_shmd:]*|\b[A-Z]*\#[\d.,_]*|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
+ 'boolean': /\b(?:TRUE|FALSE|NULL)\b/,
+ 'function': /\w+(?=\()/,
+ 'operator': /(?:S?R?:?=>?|&&?|\*\*?|<=?|>=?|[-:^/+])|\b(?:OR|AND|MOD|NOT|XOR|LE|GE|EQ|NE|GE|LT)\b/,
+ 'punctuation': /[();]/,
+ 'type': {
+ 'pattern': /#/,
+ 'alias': 'selector',
+ },
+};
+
+return Prism; })
\ No newline at end of file
--- /dev/null
+define(["prism/prism"], function () {
+(function (Prism) {
+ Prism.languages.ignore = {
+ // https://git-scm.com/docs/gitignore
+ 'comment': /^#.*/m,
+ 'entry': {
+ pattern: /\S(?:.*(?:(?:\\ )|\S))?/,
+ alias: 'string',
+ inside: {
+ 'operator': /^!|\*\*?|\?/,
+ 'regex': {
+ pattern: /(^|[^\\])\[[^\[\]]*\]/,
+ lookbehind: true
+ },
+ 'punctuation': /\//
+ }
+ }
+ };
+
+ Prism.languages.gitignore = Prism.languages.ignore
+ Prism.languages.hgignore = Prism.languages.ignore
+ Prism.languages.npmignore = Prism.languages.ignore
+
+}(Prism));
+
+return Prism; })
\ No newline at end of file
'builtin':/\b(?:Array|AudioDevice|AudioMixer|Block|Box|Buffer|CFunction|CGI|Color|Curses|DBM|DNSResolver|DOConnection|DOProxy|DOServer|Date|Directory|Duration|DynLib|Error|Exception|FFT|File|Fnmatch|Font|Future|GL|GLE|GLScissor|GLU|GLUCylinder|GLUQuadric|GLUSphere|GLUT|Host|Image|Importer|LinkList|List|Lobby|Locals|MD5|MP3Decoder|MP3Encoder|Map|Message|Movie|Notification|Number|Object|OpenGL|Point|Protos|Regex|SGML|SGMLElement|SGMLParser|SQLite|Server|Sequence|ShowMessage|SleepyCat|SleepyCatCursor|Socket|SocketManager|Sound|Soup|Store|String|Tree|UDPSender|UPDReceiver|URL|User|Warning|WeakLink|Random|BigNum|Sequence)\b/,
'boolean': /\b(?:true|false|nil)\b/,
'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e-?\d+)?/i,
- 'operator': /[=!*/%+-^&|]=|>>?=?|<<?=?|:?:?=|\+\+?|--?|\*\*?|\/\/?|%|\|\|?|&&?|\b(?:return|and|or|not)\b|@@?|\?\??|\.\./,
+ 'operator': /[=!*/%+\-^&|]=|>>?=?|<<?=?|:?:?=|\+\+?|--?|\*\*?|\/\/?|%|\|\|?|&&?|\b(?:return|and|or|not)\b|@@?|\?\??|\.\./,
'punctuation': /[{}[\];(),.:]/
};
pattern: /(?!\^:|;\.|[=!][.:])(?:\{(?:\.|::?)?|p(?:\.\.?|:)|[=!\]]|[<>+*\-%$|,#][.:]?|[?^]\.?|[;\[]:?|[~}"i][.:]|[ACeEIjLor]\.|(?:[_\/\\qsux]|_?\d):)/,
alias: 'keyword'
},
- 'number': /\b_?(?:(?!\d:)\d+(?:\.\d+)?(?:(?:[ejpx]|ad|ar)_?\d+(?:\.\d+)?)*(?:b_?[\da-z]+(?:\.[\da-z]+)?)?|_(?!\.))/,
+ 'number': /\b_?(?:(?!\d:)\d+(?:\.\d+)?(?:(?:[ejpx]|ad|ar)_?\d+(?:\.\d+)?)*(?:b_?[\da-z]+(?:\.[\da-z]+)?)?|_\b(?!\.))/,
'adverb': {
pattern: /[~}]|[\/\\]\.?|[bfM]\.|t[.:]/,
alias: 'builtin'
},
'punctuation': /[()]/
};
+
return Prism; })
\ No newline at end of file
lookbehind: true
},
'namespace': {
- pattern: /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)[a-z]\w*(?:\.[a-z]\w*)+/,
+ pattern: RegExp(
+ /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/
+ .source.replace(/<keyword>/g, function () { return keywords.source; })),
lookbehind: true,
inside: {
'punctuation': /\./,
define(["prism/prism","prism/components/prism-markup","prism/components/prism-java","prism/components/prism-javadoclike"], function () {
(function (Prism) {
- var codeLines = {
- 'code': {
- pattern: /(^(?:\s*(?:\*\s*)*)).*[^*\s].+$/m,
- lookbehind: true,
- inside: Prism.languages.java,
- alias: 'language-java'
- }
- };
+ var codeLinePattern = /(^(?:\s*(?:\*\s*)*)).*[^*\s].*$/m;
+
+ var memberReference = /#\s*\w+(?:\s*\([^()]*\))?/.source;
+ var reference = /(?:[a-zA-Z]\w+\s*\.\s*)*[A-Z]\w*(?:\s*<mem>)?|<mem>/.source.replace(/<mem>/g, function () { return memberReference });
Prism.languages.javadoc = Prism.languages.extend('javadoclike', {});
Prism.languages.insertBefore('javadoc', 'keyword', {
- 'class-name': [
- {
- pattern: /(@(?:exception|throws|see|link|linkplain|value)\s+(?:[a-z\d]+\.)*)[A-Z](?:\w*[a-z]\w*)?(?:\.[A-Z](?:\w*[a-z]\w*)?)*/,
- lookbehind: true,
- inside: {
- 'punctuation': /\./
- }
- },
- {
- // @param <T> the first generic type parameter
- pattern: /(@param\s+)<[A-Z]\w*>/,
- lookbehind: true,
- inside: {
- 'punctuation': /[.<>]/
- }
+ 'reference': {
+ pattern: RegExp(/(@(?:exception|throws|see|link|linkplain|value)\s+(?:\*\s*)?)/.source + '(?:' + reference + ')'),
+ lookbehind: true,
+ inside: {
+ 'function': {
+ pattern: /(#\s*)\w+(?=\s*\()/,
+ lookbehind: true
+ },
+ 'field': {
+ pattern: /(#\s*)\w+/,
+ lookbehind: true
+ },
+ 'namespace': {
+ pattern: /\b(?:[a-z]\w*\s*\.\s*)+/,
+ inside: {
+ 'punctuation': /\./
+ }
+ },
+ 'class-name': /\b[A-Z]\w*/,
+ 'keyword': Prism.languages.java.keyword,
+ 'punctuation': /[#()[\],.]/
}
- ],
- 'namespace': {
- pattern: /(@(?:exception|throws|see|link|linkplain)\s+)(?:[a-z\d]+\.)+/,
+ },
+ 'class-name': {
+ // @param <T> the first generic type parameter
+ pattern: /(@param\s+)<[A-Z]\w*>/,
lookbehind: true,
inside: {
- 'punctuation': /\./
+ 'punctuation': /[.<>]/
}
},
'code-section': [
{
- pattern: /(\{@code\s+)(?:[^{}]|\{[^{}]*\})+?(?=\s*\})/,
+ pattern: /(\{@code\s+)(?:[^{}]|\{(?:[^{}]|\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\})*\})+?(?=\s*\})/,
lookbehind: true,
- inside: codeLines
+ inside: {
+ 'code': {
+ // there can't be any HTML inside of {@code} tags
+ pattern: codeLinePattern,
+ lookbehind: true,
+ inside: Prism.languages.java,
+ alias: 'language-java'
+ }
+ }
},
{
- pattern: /(<(code|tt)>\s*)[\s\S]+?(?=\s*<\/\2>)/,
+ pattern: /(<(code|pre|tt)>(?!<code>)\s*)[\s\S]+?(?=\s*<\/\2>)/,
lookbehind: true,
- inside: codeLines
+ inside: {
+ 'line': {
+ pattern: codeLinePattern,
+ lookbehind: true,
+ inside: {
+ // highlight HTML tags and entities
+ 'tag': Prism.languages.markup.tag,
+ 'entity': Prism.languages.markup.entity,
+ 'code': {
+ // everything else is Java code
+ pattern: /.+/,
+ inside: Prism.languages.java,
+ alias: 'language-java'
+ }
+ }
+ }
+ }
}
],
'tag': Prism.languages.markup.tag,
+ 'entity': Prism.languages.markup.entity,
});
Prism.languages.javadoclike.addSupport('java', Prism.languages.javadoc);
lookbehind: true
},
{
- pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
+ pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|(?:get|set)(?=\s*[\[$\w\xA0-\uFFFF])|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
lookbehind: true
},
],
'number': /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
'function': /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
- 'operator': /--|\+\+|\*\*=?|=>|&&|\|\||[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?[.?]?|[~:]/
+ 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
});
Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;
Prism.languages.insertBefore('javascript', 'keyword', {
'regex': {
- pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=(?:\s|\/\*[\s\S]*?\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
+ pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
lookbehind: true,
greedy: true
},
inside: Prism.languages.javascript
},
{
- pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,
+ pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,
lookbehind: true,
inside: Prism.languages.javascript
}
'variable': /\B\$\w+/,
'property-literal': {
- pattern: /[a-z_]\w*(?=\s*:(?!:))/i,
+ pattern: /\b[a-z_]\w*(?=\s*:(?!:))/i,
alias: 'property'
},
'keyword': /\b(?:as|break|catch|def|elif|else|end|foreach|if|import|include|label|module|modulemeta|null|reduce|then|try|while)\b/,
'boolean': /\b(?:true|false)\b/,
- 'number': /(?:\b\d+\.|\B\.)?\d+(?:[eE][+-]?\d+)?\b/,
+ 'number': /(?:\b\d+\.|\B\.)?\b\d+(?:[eE][+-]?\d+)?\b/,
'operator': [
{
-define(["prism/prism","prism/components/prism-javascript","prism/components/prism-javadoclike"], function () {
+define(["prism/prism","prism/components/prism-javascript","prism/components/prism-javadoclike","prism/components/prism-typescript"], function () {
(function (Prism) {
var javascript = Prism.languages.javascript;
},
'class-name': [
{
- pattern: RegExp('(@[a-z]+\\s+)' + type),
+ pattern: RegExp(/(@(?:augments|extends|class|interface|memberof!?|template|this|typedef)\s+(?:<TYPE>\s+)?)[A-Z]\w*(?:\.[A-Z]\w*)*/.source.replace(/<TYPE>/g, function () { return type; })),
lookbehind: true,
inside: {
- 'punctuation': /[.,:?=<>|{}()[\]]/
+ 'punctuation': /\./
}
},
{
- pattern: /(@(?:augments|extends|class|interface|memberof!?|this)\s+)[A-Z]\w*(?:\.[A-Z]\w*)*/,
+ pattern: RegExp('(@[a-z]+\\s+)' + type),
lookbehind: true,
inside: {
- 'punctuation': /\./
+ 'string': javascript.string,
+ 'number': javascript.number,
+ 'boolean': javascript.boolean,
+ 'keyword': Prism.languages.typescript.keyword,
+ 'operator': /=>|\.\.\.|[&|?:*]/,
+ 'punctuation': /[.,;=<>{}()[\]]/
}
}
],
define(["prism/prism"], function () {
+// https://www.json.org/json-en.html
Prism.languages.json = {
'property': {
pattern: /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
greedy: true
},
- 'comment': /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
- 'number': /-?\d+\.?\d*(?:e[+-]?\d+)?/i,
+ 'comment': {
+ pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
+ greedy: true
+ },
+ 'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
'punctuation': /[{}[\],]/,
'operator': /:/,
'boolean': /\b(?:true|false)\b/,
}
};
+Prism.languages.webmanifest = Prism.languages.json;
+
return Prism; })
\ No newline at end of file
pattern: string,
greedy: true
},
- 'number': /[+-]?(?:NaN|Infinity|0x[a-fA-F\d]+|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)/
+ 'number': /[+-]?\b(?:NaN|Infinity|0x[a-fA-F\d]+)\b|[+-]?(?:\b\d+\.?\d*|\B\.\d+)(?:[eE][+-]?\d+\b)?/
});
}(Prism));
--- /dev/null
+define(["prism/prism"], function () {
+Prism.languages.jsstacktrace = {
+ 'error-message': {
+ pattern: /^\S.*/m,
+ alias: 'string'
+ },
+
+ 'stack-frame': {
+ pattern: /^[ \t]+at[ \t]+.*/m,
+ inside: {
+ 'not-my-code': {
+ pattern: /[ \t]+at[ \t]+(?:node\.js|\<unknown\>|.*(?:node_modules|\(\<anonymous\>\)|\(\<unknown\>|\<anonymous\>$|\(internal\/|\(node\.js)).*/m,
+ alias: 'comment'
+ },
+
+ 'filename': {
+ pattern: /(\bat\s+|\()(?:[a-zA-Z]:)?[^():]+(?=:)/,
+ lookbehind: true,
+ alias: 'url'
+ },
+
+ 'function': {
+ pattern: /(at\s+(?:new\s+)?)[_$a-zA-Z\xA0-\uFFFF<][.$\w\xA0-\uFFFF<>]*/,
+ lookbehind: true,
+ inside: {
+ 'punctuation': /\./
+ }
+ },
+
+ 'punctuation': /[()]/,
+
+ 'keyword': /\b(?:at|new)\b/,
+
+ 'alias': {
+ pattern: /\[(?:as\s+)?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\]/,
+ alias: 'variable'
+ },
+
+ 'line-number': {
+ pattern: /:[0-9]+(?::[0-9]+)?\b/,
+ alias: 'number',
+ inside: {
+ 'punctuation': /:/
+ }
+ },
+
+ }
+ }
+}
+
+return Prism; })
\ No newline at end of file
var javascript = Prism.util.clone(Prism.languages.javascript);
Prism.languages.jsx = Prism.languages.extend('markup', javascript);
-Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:$-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\s*\.{3}\s*[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\s*\}))*\s*\/?)?>/i;
+Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:$-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])+\}))?|\{\s*\.{3}\s*[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\s*\}))*\s*\/?)?>/i;
Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
Prism.languages.insertBefore('inside', 'attr-value',{
'script': {
// Allow for two levels of nesting
- pattern: /=(?:\{(?:\{(?:\{[^}]*\}|[^}])*\}|[^}])+\})/i,
+ pattern: /=(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])+\})/i,
inside: {
'script-punctuation': {
pattern: /^=(?={)/,
define(["prism/prism"], function () {
-Prism.languages.julia= {
+Prism.languages.julia = {
'comment': {
- pattern: /(^|[^\\])#.*/,
+ // support one level of nested comments
+ // https://github.com/JuliaLang/julia/pull/6128
+ pattern: /(^|[^\\])(?:#=(?:[^#=]|=(?!#)|#(?!=)|#=(?:[^#=]|=(?!#)|#(?!=))*=#)*=#|#.*)/,
lookbehind: true
},
- 'string': /("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2/,
- 'keyword' : /\b(?:abstract|baremodule|begin|bitstype|break|catch|ccall|const|continue|do|else|elseif|end|export|finally|for|function|global|if|immutable|import|importall|in|let|local|macro|module|print|println|quote|return|struct|try|type|typealias|using|while)\b/,
- 'boolean' : /\b(?:true|false)\b/,
- 'number' : /(?:\b(?=\d)|\B(?=\.))(?:0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:[efp][+-]?\d+)?j?/i,
- 'operator': /[-+*^%÷&$\\]=?|\/[\/=]?|!=?=?|\|[=>]?|<(?:<=?|[=:])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥]/,
- 'punctuation' : /[{}[\];(),.:]/,
- 'constant': /\b(?:(?:NaN|Inf)(?:16|32|64)?)\b/
+ 'regex': {
+ // https://docs.julialang.org/en/v1/manual/strings/#Regular-Expressions-1
+ pattern: /r"(?:\\.|[^"\\\r\n])*"[imsx]{0,4}/,
+ greedy: true
+ },
+ 'string': {
+ // https://docs.julialang.org/en/v1/manual/strings/#man-characters-1
+ // https://docs.julialang.org/en/v1/manual/strings/#String-Basics-1
+ // https://docs.julialang.org/en/v1/manual/strings/#non-standard-string-literals-1
+ // https://docs.julialang.org/en/v1/manual/running-external-programs/#Running-External-Programs-1
+ pattern: /"""[\s\S]+?"""|\w*"(?:\\.|[^"\\\r\n])*"|(^|[^\w'])'(?:\\[^\r\n][^'\r\n]*|[^\\\r\n])'|`(?:[^\\`\r\n]|\\.)*`/,
+ lookbehind: true,
+ greedy: true
+ },
+ 'keyword': /\b(?:abstract|baremodule|begin|bitstype|break|catch|ccall|const|continue|do|else|elseif|end|export|finally|for|function|global|if|immutable|import|importall|in|let|local|macro|module|print|println|quote|return|struct|try|type|typealias|using|while)\b/,
+ 'boolean': /\b(?:true|false)\b/,
+ 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[box])?(?:[\da-f]+(?:_[\da-f]+)*\.?(?:\d+(?:_\d+)*)?|\.\d+(?:_\d+)*)(?:[efp][+-]?\d+(?:_\d+)*)?j?/i,
+ // https://docs.julialang.org/en/v1/manual/mathematical-operations/
+ // https://docs.julialang.org/en/v1/manual/mathematical-operations/#Operator-Precedence-and-Associativity-1
+ 'operator': /&&|\|\||[-+*^%÷⊻&$\\]=?|\/[\/=]?|!=?=?|\|[=>]?|<(?:<=?|[=:|])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥'√∛]/,
+ 'punctuation': /::?|[{}[\]();,.?]/,
+ // https://docs.julialang.org/en/v1/base/numbers/#Base.im
+ 'constant': /\b(?:(?:NaN|Inf)(?:16|32|64)?|im|pi|e|catalan|eulergamma|golden)\b|[πℯγφ]/
};
return Prism; })
\ No newline at end of file
interpolation: interpolation
};
+ Prism.languages.kt = Prism.languages.kotlin;
+ Prism.languages.kts = Prism.languages.kotlin;
}(Prism));
return Prism; })
\ No newline at end of file
define(["prism/prism","prism/components/prism-scheme"], function () {
(function (Prism) {
- var schemeExpression = /\((?:[^();"#\\]|\\[\s\S]|;.*|"(?:[^"\\]|\\.)*"|#(?:\{(?:(?!#\})[\s\S])*#\}|[^{])|<expr>)*\)/.source;
+ var schemeExpression = /\((?:[^();"#\\]|\\[\s\S]|;.*(?!.)|"(?:[^"\\]|\\.)*"|#(?:\{(?:(?!#\})[\s\S])*#\}|[^{])|<expr>)*\)/.source;
// allow for up to pow(2, recursivenessLog2) many levels of recursive brace expressions
// For some reason, this can't be 4
var recursivenessLog2 = 5;
],
'regex': [
{
- pattern: /\/\/(?:\[.+?]|\\.|(?!\/\/)[^\\])+\/\/[gimyu]{0,5}/,
+ pattern: /\/\/(?:\[[^\r\n\]]*\]|\\.|(?!\/\/)[^\\\[])+\/\/[gimyu]{0,5}/,
greedy: true,
inside: {
'comment': {
}
},
{
- pattern: /\/(?:\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}/,
+ pattern: /\/(?:\[[^\r\n\]]*\]|\\.|[^/\\\r\n\[])+\/[gimyu]{0,5}/,
greedy: true
}
],
/\bBTW.+/
],
'string': {
- pattern: /"(?::.|[^"])*"/,
+ pattern: /"(?::.|[^":])*"/,
inside: {
'variable': /:\{[^}]+\}/,
'symbol': [
},
'punctuation': /\.{3}|…|,|!/
};
+
return Prism; })
\ No newline at end of file
* _Note:_ Keep in mind that this adds a capturing group.
*
* @param {string} pattern
- * @param {boolean} starAlternative Whether to also add an alternative where all `_`s are replaced with `*`s.
* @returns {RegExp}
*/
- function createInline(pattern, starAlternative) {
+ function createInline(pattern) {
pattern = pattern.replace(/<inner>/g, function () { return inner; });
- if (starAlternative) {
- pattern = pattern + '|' + pattern.replace(/_/g, '\\*');
- }
return RegExp(/((?:^|[^\\])(?:\\{2})*)/.source + '(?:' + pattern + ')');
}
- var tableCell = /(?:\\.|``.+?``|`[^`\r\n]+`|[^\\|\r\n`])+/.source;
+ var tableCell = /(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source;
var tableRow = /\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|$)/.source.replace(/__/g, function () { return tableCell; });
var tableLine = /\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;
// __strong__
// allow one nested instance of italic text using the same delimiter
- pattern: createInline(/__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__/.source, true),
+ pattern: createInline(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),
lookbehind: true,
greedy: true,
inside: {
// _em_
// allow one nested instance of bold text using the same delimiter
- pattern: createInline(/_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_/.source, true),
+ pattern: createInline(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),
lookbehind: true,
greedy: true,
inside: {
'strike': {
// ~~strike through~~
// ~strike~
- pattern: createInline(/(~~?)(?:(?!~)<inner>)+?\2/.source, false),
+ pattern: createInline(/(~~?)(?:(?!~)<inner>)+?\2/.source),
lookbehind: true,
greedy: true,
inside: {
// [example](http://example.com "Optional title")
// [example][id]
// [example] [id]
- pattern: createInline(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)| ?\[(?:(?!\])<inner>)+\])/.source, false),
+ pattern: createInline(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)| ?\[(?:(?!\])<inner>)+\])/.source),
lookbehind: true,
greedy: true,
inside: {
'comment': /<!--[\s\S]*?-->/,
'prolog': /<\?[\s\S]+?\?>/,
'doctype': {
- pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:(?!<!--)[^"'\]]|"[^"]*"|'[^']*'|<!--[\s\S]*?-->)*\]\s*)?>/i,
- greedy: true
+ // https://www.w3.org/TR/xml/#NT-doctypedecl
+ pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
+ greedy: true,
+ inside: {
+ 'internal-subset': {
+ pattern: /(\[)[\s\S]+(?=\]>$)/,
+ lookbehind: true,
+ greedy: true,
+ inside: null // see below
+ },
+ 'string': {
+ pattern: /"[^"]*"|'[^']*'/,
+ greedy: true
+ },
+ 'punctuation': /^<!|>$|[[\]]/,
+ 'doctype-tag': /^DOCTYPE/,
+ 'name': /[^\s<>'"]+/
+ }
},
'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
'tag': {
- pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,
+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
greedy: true,
inside: {
'tag': {
- pattern: /^<\/?[^\s>\/]+/i,
+ pattern: /^<\/?[^\s>\/]+/,
inside: {
'punctuation': /^<\/?/,
'namespace': /^[^\s>\/:]+:/
}
},
'attr-value': {
- pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,
+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
inside: {
'punctuation': [
- /^=/,
{
- pattern: /^(\s*)["']|["']$/,
- lookbehind: true
- }
+ pattern: /^=/,
+ alias: 'attr-equals'
+ },
+ /"|'/
]
}
},
}
},
- 'entity': /&#?[\da-z]{1,8};/i
+ 'entity': [
+ {
+ pattern: /&[\da-z]{1,8};/i,
+ alias: 'named-entity'
+ },
+ /&#x?[\da-f]{1,8};/i
+ ]
};
Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
Prism.languages.markup['entity'];
+Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
// Plugin to make entity title show the real entity, idea by Roman Komarov
-Prism.hooks.add('wrap', function(env) {
+Prism.hooks.add('wrap', function (env) {
if (env.type === 'entity') {
env.attributes['title'] = env.content.replace(/&/, '&');
var def = {};
def[tagName] = {
- pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[[\s\S]*?\]\]>\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
+ pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
lookbehind: true,
greedy: true,
inside: inside
}
});
-Prism.languages.xml = Prism.languages.extend('markup', {});
Prism.languages.html = Prism.languages.markup;
Prism.languages.mathml = Prism.languages.markup;
Prism.languages.svg = Prism.languages.markup;
+Prism.languages.xml = Prism.languages.extend('markup', {});
+Prism.languages.ssml = Prism.languages.xml;
+Prism.languages.atom = Prism.languages.xml;
+Prism.languages.rss = Prism.languages.xml;
+
return Prism; })
\ No newline at end of file
alias: 'keyword'
},
'string': {
- pattern: /(^|[[{(=:,\s])(?:('''|""")\r?\n(?:(?:[^\r\n]|\r?\n(?![\t ]*\2))*\r?\n)?[\t ]*\2|'[^'\r\n]*'|"(?:\\.|[^"\r\n])*")/,
+ pattern: /(^|[[{(=:,\s])(?:('''|""")\r?\n(?:(?:[^\r\n]|\r?\n(?![\t ]*\2))*\r?\n)?[\t ]*\2|'[^'\r\n]*'|"(?:\\.|[^\\"\r\n])*")/,
lookbehind: true,
greedy: true
},
delete Prism.languages.objectivec['class-name'];
+Prism.languages.objc = Prism.languages.objectivec;
return Prism; })
\ No newline at end of file
'boolean': /\b(?:false|true)\b/,
// Custom operators are allowed
'operator': /:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/,
- 'punctuation': /[(){}\[\]|_.,:;]/
+ 'punctuation': /[(){}\[\]|.,:;]|\b_\b/
};
+
return Prism; })
\ No newline at end of file
greedy: true,
alias: 'builtin'
},
- 'keyword': /[$_]|\[\]|\b(?:at|attr|case|catch|choice|class|cond|declare|define|dis|else(?:case|if)?|end|export|fail|false|feat|finally|from|fun|functor|if|import|in|local|lock|meth|nil|not|of|or|prepare|proc|prop|raise|require|self|skip|then|thread|true|try|unit)\b/,
+ 'keyword': /\$|\[\]|\b(?:_|at|attr|case|catch|choice|class|cond|declare|define|dis|else(?:case|if)?|end|export|fail|false|feat|finally|from|fun|functor|if|import|in|local|lock|meth|nil|not|of|or|prepare|proc|prop|raise|require|self|skip|then|thread|true|try|unit)\b/,
'function': [
- /[a-z][A-Za-z\d]*(?=\()/,
+ /\b[a-z][A-Za-z\d]*(?=\()/,
{
- pattern: /(\{)[A-Z][A-Za-z\d]*/,
+ pattern: /(\{)[A-Z][A-Za-z\d]*\b/,
lookbehind: true
}
],
- 'number': /\b(?:0[bx][\da-f]+|\d+\.?\d*(?:e~?\d+)?\b)|&(?:[^\\]|\\(?:\d{3}|.))/i,
+ 'number': /\b(?:0[bx][\da-f]+|\d+\.?\d*(?:e~?\d+)?)\b|&(?:[^\\]|\\(?:\d{3}|.))/i,
'variable': /\b[A-Z][A-Za-z\d]*|`(?:[^`\\]|\\.)+`/,
'attr-name': /\w+(?=:)/,
'operator': /:(?:=|::?)|<[-:=]?|=(?:=|<?:?)|>=?:?|\\=:?|!!?|[|#+\-*\/,~^@]|\b(?:andthen|div|mod|orelse)\b/,
'punctuation': /[\[\](){}.:;?]/
};
+
return Prism; })
\ No newline at end of file
'function': /\w[\w ]*?(?= *\()/,
'number': {
// The lookbehind and the negative lookahead prevent from breaking the .. operator
- pattern: /((?:\. *\. *)?)(?:\d(?: *\d)*(?: *(?!\. *\.)\.(?: *\d)*)?|\. *\d(?: *\d)*)(?: *e *[+-]? *\d(?: *\d)*)?/i,
+ pattern: /((?:\. *\. *)?)(?:\b\d(?: *\d)*(?: *(?!\. *\.)\.(?: *\d)*)?|\. *\d(?: *\d)*)(?: *e *[+-]? *\d(?: *\d)*)?/i,
lookbehind: true
},
'operator': /\. *\.|[*\/!](?: *=)?|%(?: *=|(?: *#)?(?: *')*)?|\+(?: *[+=])?|-(?: *[-=>])?|<(?:(?: *<)?(?: *=)?| *>)?|>(?: *>)?(?: *=)?|=(?: *=){0,2}|\\(?: *\/)?(?: *=)?|&(?: *&)?|\| *\||['#~^]/,
'punctuation': /[\[\]{}().,:;|]/
};
+
return Prism; })
\ No newline at end of file
/\/\/.*/
],
'string': {
- pattern: /(?:'(?:''|[^'\r\n])*'|#[&$%]?[a-f\d]+)+|\^[a-z]/i,
+ pattern: /(?:'(?:''|[^'\r\n])*'(?!')|#[&$%]?[a-f\d]+)+|\^[a-z]/i,
greedy: true
},
'keyword': [
};
Prism.languages.objectpascal = Prism.languages.pascal;
+
return Prism; })
\ No newline at end of file
--- /dev/null
+define(["prism/prism"], function () {
+Prism.languages.peoplecode = {
+ 'comment': RegExp([
+ // C-style multiline comments
+ /\/\*[\s\S]*?\*\//.source,
+ // REM comments
+ /\bREM[^;]*;/.source,
+ // Nested <* *> comments
+ /<\*(?:[^<*]|\*(?!>)|<(?!\*)|<\*(?:(?!\*>)[\s\S])*\*>)*\*>/.source,
+ // /+ +/ comments
+ /\/\+[\s\S]*?\+\//.source,
+ ].join("|")),
+ 'string': {
+ pattern: /'(?:''|[^'\r\n])*'(?!')|"(?:""|[^"\r\n])*"(?!")/,
+ greedy: true
+ },
+ 'variable': /%\w+/,
+ 'function-definition': {
+ pattern: /((?:^|[^\w-])(?:function|method)\s+)\w+/i,
+ lookbehind: true,
+ alias: 'function'
+ },
+ 'class-name': {
+ pattern: /((?:^|[^-\w])(?:as|catch|class|component|create|extends|global|implements|instance|local|of|property|returns)\s+)\w+(?::\w+)*/i,
+ lookbehind: true,
+ inside: {
+ 'punctuation': /:/
+ }
+ },
+ 'keyword': /\b(?:abstract|alias|as|catch|class|component|constant|create|declare|else|end-(?:class|evaluate|for|function|get|if|method|set|try|while)|evaluate|extends|for|function|get|global|implements|import|instance|if|library|local|method|null|of|out|peopleCode|private|program|property|protected|readonly|ref|repeat|returns?|set|step|then|throw|to|try|until|value|when(?:-other)?|while)\b/i,
+ 'operator-keyword': {
+ pattern: /\b(?:and|not|or)\b/i,
+ alias: 'operator'
+ },
+ 'function': /[_a-z]\w*(?=\s*\()/i,
+
+ 'boolean': /\b(?:false|true)\b/i,
+ 'number': /\b\d+(?:\.\d+)?\b/,
+ 'operator': /<>|[<>]=?|!=|\*\*|[-+*/|=@]/,
+ 'punctuation': /[:.;,()[\]]/
+};
+
+Prism.languages.pcode = Prism.languages.peoplecode;
+
+return Prism; })
\ No newline at end of file
});
var string_interpolation = {
- pattern: /{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[.+?]|->\w+)*)/,
+ pattern: /{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)*)/,
lookbehind: true,
inside: Prism.languages.php
};
Prism.languages.insertBefore('php', 'string', {
'nowdoc-string': {
- pattern: /<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,
+ pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,
greedy: true,
alias: 'string',
inside: {
}
},
'heredoc-string': {
- pattern: /<<<(?:"([^"]+)"(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;|([a-z_]\w*)(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\2;)/i,
+ pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,
greedy: true,
alias: 'string',
inside: {
inside: {
'function': {
// Allow for one level of nesting
- pattern: /(^|[^`])\$\((?:\$\(.*?\)|(?!\$\()[^\r\n)])*\)/,
+ pattern: /(^|[^`])\$\((?:\$\([^\r\n()]*\)|(?!\$\()[^\r\n)])*\)/,
lookbehind: true,
// Populated at end of file
inside: {}
// Supports two levels of nested brackets (e.g. `[OutputType([System.Collections.Generic.List[int]])]`)
'namespace': /\[[a-z](?:\[(?:\[[^\]]*]|[^\[\]])*]|[^\[\]])*]/i,
'boolean': /\$(?:true|false)\b/i,
- 'variable': /\$\w+\b/i,
+ 'variable': /\$\w+\b/,
// Cmdlets and aliases. Aliases should come last, otherwise "write" gets preferred over "write-host" for example
// Get-Command | ?{ $_.ModuleName -match "Microsoft.PowerShell.(Util|Core|Management)" }
// Get-Alias | ?{ $_.ReferencedCommand.Module.Name -match "Microsoft.PowerShell.(Util|Core|Management)" }
'function': [
- /\b(?:Add-(?:Computer|Content|History|Member|PSSnapin|Type)|Checkpoint-Computer|Clear-(?:Content|EventLog|History|Item|ItemProperty|Variable)|Compare-Object|Complete-Transaction|Connect-PSSession|ConvertFrom-(?:Csv|Json|StringData)|Convert-Path|ConvertTo-(?:Csv|Html|Json|Xml)|Copy-(?:Item|ItemProperty)|Debug-Process|Disable-(?:ComputerRestore|PSBreakpoint|PSRemoting|PSSessionConfiguration)|Disconnect-PSSession|Enable-(?:ComputerRestore|PSBreakpoint|PSRemoting|PSSessionConfiguration)|Enter-PSSession|Exit-PSSession|Export-(?:Alias|Clixml|Console|Csv|FormatData|ModuleMember|PSSession)|ForEach-Object|Format-(?:Custom|List|Table|Wide)|Get-(?:Alias|ChildItem|Command|ComputerRestorePoint|Content|ControlPanelItem|Culture|Date|Event|EventLog|EventSubscriber|FormatData|Help|History|Host|HotFix|Item|ItemProperty|Job|Location|Member|Module|Process|PSBreakpoint|PSCallStack|PSDrive|PSProvider|PSSession|PSSessionConfiguration|PSSnapin|Random|Service|TraceSource|Transaction|TypeData|UICulture|Unique|Variable|WmiObject)|Group-Object|Import-(?:Alias|Clixml|Csv|LocalizedData|Module|PSSession)|Invoke-(?:Command|Expression|History|Item|RestMethod|WebRequest|WmiMethod)|Join-Path|Limit-EventLog|Measure-(?:Command|Object)|Move-(?:Item|ItemProperty)|New-(?:Alias|Event|EventLog|Item|ItemProperty|Module|ModuleManifest|Object|PSDrive|PSSession|PSSessionConfigurationFile|PSSessionOption|PSTransportOption|Service|TimeSpan|Variable|WebServiceProxy)|Out-(?:Default|File|GridView|Host|Null|Printer|String)|Pop-Location|Push-Location|Read-Host|Receive-(?:Job|PSSession)|Register-(?:EngineEvent|ObjectEvent|PSSessionConfiguration|WmiEvent)|Remove-(?:Computer|Event|EventLog|Item|ItemProperty|Job|Module|PSBreakpoint|PSDrive|PSSession|PSSnapin|TypeData|Variable|WmiObject)|Rename-(?:Computer|Item|ItemProperty)|Reset-ComputerMachinePassword|Resolve-Path|Restart-(?:Computer|Service)|Restore-Computer|Resume-(?:Job|Service)|Save-Help|Select-(?:Object|String|Xml)|Send-MailMessage|Set-(?:Alias|Content|Date|Item|ItemProperty|Location|PSBreakpoint|PSDebug|PSSessionConfiguration|Service|StrictMode|TraceSource|Variable|WmiInstance)|Show-(?:Command|ControlPanelItem|EventLog)|Sort-Object|Split-Path|Start-(?:Job|Process|Service|Sleep|Transaction)|Stop-(?:Computer|Job|Process|Service)|Suspend-(?:Job|Service)|Tee-Object|Test-(?:ComputerSecureChannel|Connection|ModuleManifest|Path|PSSessionConfigurationFile)|Trace-Command|Unblock-File|Undo-Transaction|Unregister-(?:Event|PSSessionConfiguration)|Update-(?:FormatData|Help|List|TypeData)|Use-Transaction|Wait-(?:Event|Job|Process)|Where-Object|Write-(?:Debug|Error|EventLog|Host|Output|Progress|Verbose|Warning))\b/i,
+ /\b(?:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|ForEach|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Move|New|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Tee|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Where|Write)-[a-z]+\b/i,
/\b(?:ac|cat|chdir|clc|cli|clp|clv|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|ebp|echo|epal|epcsv|epsn|erase|fc|fl|ft|fw|gal|gbp|gc|gci|gcs|gdr|gi|gl|gm|gp|gps|group|gsv|gu|gv|gwmi|iex|ii|ipal|ipcsv|ipsn|irm|iwmi|iwr|kill|lp|ls|measure|mi|mount|move|mp|mv|nal|ndr|ni|nv|ogv|popd|ps|pushd|pwd|rbp|rd|rdr|ren|ri|rm|rmdir|rni|rnp|rp|rv|rvpa|rwmi|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spps|spsv|start|sv|swmi|tee|trcm|type|write)\b/i
],
// per http://technet.microsoft.com/en-us/library/hh847744.aspx
var builtinTypes = /\b(?:double|float|[su]?int(?:32|64)|s?fixed(?:32|64)|bool|string|bytes)\b/;
Prism.languages.protobuf = Prism.languages.extend('clike', {
- 'class-name': {
- pattern: /(\b(?:enum|extend|message|service)\s+)[A-Za-z_]\w*(?=\s*\{)/,
- lookbehind: true
- },
- 'keyword': /\b(?:enum|extend|extensions|import|message|oneof|option|optional|package|public|repeated|required|reserved|service|syntax|to)\b/
+ 'class-name': [
+ {
+ pattern: /(\b(?:enum|extend|message|service)\s+)[A-Za-z_]\w*(?=\s*\{)/,
+ lookbehind: true
+ },
+ {
+ pattern: /(\b(?:rpc\s+\w+|returns)\s*\(\s*(?:stream\s+)?)\.?[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*(?=\s*\))/,
+ lookbehind: true
+ }
+ ],
+ 'keyword': /\b(?:enum|extend|extensions|import|message|oneof|option|optional|package|public|repeated|required|reserved|returns|rpc(?=\s+\w)|service|stream|syntax|to)\b(?!\s*=\s*\d)/,
+ 'function': /[a-z_]\w*(?=\s*\()/i
});
Prism.languages.insertBefore('protobuf', 'operator', {
'map': {
- pattern: /\bmap<\s*[\w.]+\s*,\s*[\w.]+\s*>(?=\s+[A-Za-z_]\w*\s*[=;])/,
+ pattern: /\bmap<\s*[\w.]+\s*,\s*[\w.]+\s*>(?=\s+[a-z_]\w*\s*[=;])/i,
alias: 'class-name',
inside: {
'punctuation': /[<>.,]/,
},
'builtin': builtinTypes,
'positional-class-name': {
- pattern: /(?:\b|\B\.)[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*(?=\s+[A-Za-z_]\w*\s*[=;])/,
+ pattern: /(?:\b|\B\.)[a-z_]\w*(?:\.[a-z_]\w*)*(?=\s+[a-z_]\w*\s*[=;])/i,
alias: 'class-name',
inside: {
'punctuation': /\./
}
},
'annotation': {
- pattern: /(\[\s*)[A-Za-z_]\w*(?=\s*=)/,
+ pattern: /(\[\s*)[a-z_]\w*(?=\s*=)/i,
lookbehind: true
}
});
}
}
],
- 'punctuation': /:/
+ 'punctuation': /:/,
+ 'attr-id': /#[\w\-]+/,
+ 'attr-class': /\.[\w\-]+/
}
},
'code': [
define(["prism/prism"], function () {
(function (Prism) {
+ // https://agraef.github.io/pure-docs/pure.html#lexical-matters
+
Prism.languages.pure = {
'comment': [
{
alias: 'builtin'
},
// Any combination of operator chars can be an operator
- 'operator': /(?=\b_|[^_])[!"#$%&'*+,\-.\/:<=>?@\\^_`|~\u00a1-\u00bf\u00d7-\u00f7\u20d0-\u2bff]+|\b(?:and|div|mod|not|or)\b/,
+ 'operator': /(?:[!"#$%&'*+,\-.\/:<=>?@\\^`|~\u00a1-\u00bf\u00d7-\u00f7\u20d0-\u2bff]|\b_+\b)+|\b(?:and|div|mod|not|or)\b/,
// FIXME: How can we prevent | and , to be highlighted as operator when they are used alone?
'punctuation': /[(){}\[\];,|]/
};
--- /dev/null
+define(["prism/prism","prism/components/prism-clike"], function () {
+/*
+Original Code by Bas Groothedde
+!!MANY THANKS!! I never would have made this, regex and me will never be best friends ;)
+==> https://codepen.io/ImagineProgramming/details/JYydBy/
+slightly changed to pass all tests
+*/
+
+
+// PureBasic support, steal stuff from ansi-c
+Prism.languages.purebasic = Prism.languages.extend('clike', {
+ 'comment': /;.*/,
+ 'keyword': /\b(?:declarecdll|declaredll|compilerselect|compilercase|compilerdefault|compilerendselect|compilererror|enableexplicit|disableexplicit|not|and|or|xor|calldebugger|debuglevel|enabledebugger|disabledebugger|restore|read|includepath|includebinary|threaded|runtime|with|endwith|structureunion|endstructureunion|align|newlist|newmap|interface|endinterface|extends|enumeration|endenumeration|swap|foreach|continue|fakereturn|goto|gosub|return|break|module|endmodule|declaremodule|enddeclaremodule|declare|declarec|prototype|prototypec|enableasm|disableasm|dim|redim|data|datasection|enddatasection|to|procedurereturn|debug|default|case|select|endselect|as|import|endimport|importc|compilerif|compilerelse|compilerendif|compilerelseif|end|structure|endstructure|while|wend|for|next|step|if|else|elseif|endif|repeat|until|procedure|proceduredll|procedurec|procedurecdll|endprocedure|protected|shared|static|global|define|includefile|xincludefile|macro|endmacro)\b/i,
+ 'function': /\b\w+(?:\.\w+)?\s*(?=\()/,
+ 'number': /(?:\$[\da-f]+|\b-?\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
+ 'operator': /(?:@\*?|\?|\*)\w+|-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|?\||[~^%?*/@]/
+});
+
+Prism.languages.insertBefore('purebasic', 'keyword', {
+ 'tag': /#\w+/,
+ 'asm': {
+ pattern: /(^\s*)!.*/m,
+ lookbehind: true,
+ alias: 'tag',
+ inside: {
+ 'comment': /;.*/,
+ 'string': {
+ pattern: /(["'`])(?:\\.|(?!\1)[^\\\r\n])*\1/,
+ greedy: true
+ },
+ // Anonymous label references, i.e.: jmp @b
+ 'label-reference-anonymous': {
+ pattern: /(\s*!\s*j[a-z]+\s+)@[fb]/i,
+ lookbehind: true,
+ alias: 'fasm-label'
+ },
+ // Named label reference, i.e.: jne label1
+ 'label-reference-addressed': {
+ pattern: /(\s*!\s*j[a-z]+\s+)[A-Z._?$@][\w.?$@~#]*/i,
+ lookbehind: true,
+ alias: 'fasm-label'
+ },
+ 'function': {
+ pattern: /^(\s*!\s*)[\da-z]+(?=\s|$)/im,
+ lookbehind: true
+ },
+ 'function-inline': {
+ pattern: /(\s*:\s*)[\da-z]+(?=\s)/i,
+ lookbehind: true,
+ alias: 'function'
+ },
+ 'label': {
+ pattern: /^(\s*!\s*)[A-Za-z._?$@][\w.?$@~#]*(?=:)/m,
+ lookbehind: true,
+ alias: 'fasm-label'
+ },
+ 'keyword': [
+ /(?:extern|extern|global)[^;\r\n]*/i,
+ /(?:CPU|FLOAT|DEFAULT).*/
+ ],
+ 'register': /\b(?:st\d|[xyz]mm\d\d?|[cdt]r\d|r\d\d?[bwd]?|[er]?[abcd]x|[abcd][hl]|[er]?(?:bp|sp|si|di)|[cdefgs]s|mm\d+)\b/i,
+ 'number': /(?:\b|-|(?=\$))(?:0[hx][\da-f]*\.?[\da-f]+(?:p[+-]?\d+)?|\d[\da-f]+[hx]|\$\d[\da-f]*|0[oq][0-7]+|[0-7]+[oq]|0[by][01]+|[01]+[by]|0[dt]\d+|\d*\.?\d+(?:\.?e[+-]?\d+)?[dt]?)\b/i,
+ 'operator': /[\[\]*+\-/%<>=&|$!,.:]/
+ }
+ }
+});
+
+delete Prism.languages.purebasic['class-name'];
+delete Prism.languages.purebasic['boolean'];
+
+Prism.languages.pbfasm = Prism.languages['purebasic'];
+
+return Prism; })
\ No newline at end of file
lookbehind: true
},
'string-interpolation': {
- pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
+ pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
greedy: true,
inside: {
'interpolation': {
}
},
'triple-quoted-string': {
- pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]+?\1/i,
+ pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]*?\1/i,
greedy: true,
alias: 'string'
},
alias: 'function'
},
'verb': {
- pattern: /(?:\B\.\B|\b[01]:|<[=>]?|>=?|[:+\-*%,!?_~=|$&#@^]):?/,
+ pattern: /(?:\B\.\B|\b[01]:|<[=>]?|>=?|[:+\-*%,!?~=|$&#@^]):?|\b_\b:?/,
alias: 'operator'
},
'punctuation': /[(){}\[\];.]/
};
+
return Prism; })
\ No newline at end of file
(function (Prism) {
var jsString = /"(?:\\.|[^\\"\r\n])*"|'(?:\\.|[^\\'\r\n])*'/.source;
- var jsComment = /\/\/.*|\/\*(?:(?!\*\/)[\s\S])*\*\//.source;
+ var jsComment = /\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))*\*\//.source;
var jsExpr = /(?:[^\\()[\]{}"'/]|<string>|\/(?![*/])|<comment>|\(<expr>*\)|\[<expr>*\]|\{<expr>*\}|\\[\s\S])/
.source.replace(/<string>/g, function () { return jsString; }).replace(/<comment>/g, function () { return jsComment; });
--- /dev/null
+define(["prism/prism","prism/components/prism-scheme"], function () {
+Prism.languages.racket = Prism.languages.extend('scheme', {
+ 'lambda-parameter': {
+ // the racket lambda syntax is a lot more complex, so we won't even attempt to capture it.
+ // this will just prevent false positives of the `function` pattern
+ pattern: /(\(lambda\s+\()[^()'\s]+/,
+ lookbehind: true
+ }
+});
+
+// Add brackets to racket
+// The basic idea here is to go through all pattens of Scheme and replace all occurrences of "(" with the union of "("
+// and "["; Similar for ")". This is a bit tricky because "(" can be escaped or inside a character set. Both cases
+// have to be handled differently and, of course, we don't want to destroy groups, so we can only replace literal "("
+// and ")".
+// To do this, we use a regular expression which will parse any JS regular expression. It works because regexes are
+// matches from left to right and already matched text cannot be matched again. We use this to first capture all
+// escaped characters (not really, we don't get escape sequences but we don't need them). Because we already captured
+// all escaped characters, we know that any "[" character is the start of a character set, so we match that character
+// set whole.
+// With the regex parsed, we only have to replace all escaped "(" (they cannot be unescaped outside of character sets)
+// with /[([]/ and replace all "(" inside character sets.
+// Note: This method does not work for "(" that are escaped like this /\x28/ or this /\u0028/.
+Prism.languages.DFS(Prism.languages.racket, function (key, value) {
+ if (Prism.util.type(value) === 'RegExp') {
+ var source = value.source.replace(/\\(.)|\[\^?((?:\\.|[^\\\]])*)\]/g, function (m, g1, g2) {
+ if (g1) {
+ if (g1 === '(') {
+ // replace all '(' characters outside character sets
+ return '[([]';
+ }
+ if (g1 === ')') {
+ // replace all ')' characters outside character sets
+ return '[)\\]]';
+ }
+ }
+ if (g2) {
+ var prefix = m[1] === '^' ? '[^' : '[';
+ return prefix + g2.replace(/\\(.)|[()]/g, function (m, g1) {
+ if (m === '(' || g1 === '(') {
+ // replace all '(' characters inside character sets
+ return '([';
+ }
+ if (m === ')' || g1 === ')') {
+ // replace all ')' characters inside character sets
+ return ')\\]';
+ }
+ return m;
+ }) + ']';
+ }
+ return m;
+ });
+
+ this[key] = RegExp(source, value.flags);
+ }
+});
+
+Prism.languages.insertBefore('racket', 'string', {
+ 'lang': {
+ pattern: /^#lang.+/m,
+ greedy: true,
+ alias: 'keyword'
+ }
+});
+
+Prism.languages.rkt = Prism.languages.racket;
+
+return Prism; })
\ No newline at end of file
pattern: /\\[\\(){}[\]^$+*?|.]/,
alias: 'escape'
};
- var escape = /\\(?:x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]+\}|c[a-zA-Z]|0[0-7]{0,2}|[123][0-7]{2}|.)/
- var charClass = /\\[wsd]|\.|\\p{[^{}]+}/i
+ var escape = /\\(?:x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]+\}|c[a-zA-Z]|0[0-7]{0,2}|[123][0-7]{2}|.)/;
+ var charClass = {
+ pattern: /\.|\\[wsd]|\\p{[^{}]+}/i,
+ alias: 'class-name'
+ };
+ var charClassWithoutDot = {
+ pattern: /\\[wsd]|\\p{[^{}]+}/i,
+ alias: 'class-name'
+ };
var rangeChar = '(?:[^\\\\-]|' + escape.source + ')';
var range = RegExp(rangeChar + '-' + rangeChar);
alias: 'variable'
};
- var backreference = [
- /\\(?![123][0-7]{2})[1-9]/, // a backreference which is not an octal escape
- {
- pattern: /\\k<[^<>']+>/,
- inside: {
- 'group-name': groupName
- }
- }
- ];
-
Prism.languages.regex = {
'charset': {
pattern: /((?:^|[^\\])(?:\\\\)*)\[(?:[^\\\]]|\\[\s\S])*\]/,
'charset-negation': {
pattern: /(^\[)\^/,
lookbehind: true,
+ alias: 'operator'
+ },
+ 'charset-punctuation': {
+ pattern: /^\[|\]$/,
+ alias: 'punctuation'
},
- 'charset-punctuation': /^\[|\]$/,
'range': {
pattern: range,
inside: {
'escape': escape,
- 'range-punctuation': /-/
+ 'range-punctuation': {
+ pattern: /-/,
+ alias: 'operator'
+ }
}
},
'special-escape': specialEscape,
- 'charclass': charClass,
- 'backreference': backreference,
+ 'charclass': charClassWithoutDot,
'escape': escape
}
},
'special-escape': specialEscape,
'charclass': charClass,
- 'backreference': backreference,
- 'anchor': /[$^]|\\[ABbGZz]/,
+ 'backreference': [
+ {
+ // a backreference which is not an octal escape
+ pattern: /\\(?![123][0-7]{2})[1-9]/,
+ alias: 'keyword'
+ },
+ {
+ pattern: /\\k<[^<>']+>/,
+ alias: 'keyword',
+ inside: {
+ 'group-name': groupName
+ }
+ }
+ ],
+ 'anchor': {
+ pattern: /[$^]|\\[ABbGZz]/,
+ alias: 'function'
+ },
'escape': escape,
'group': [
{
// (), (?<name>), (?'name'), (?>), (?:), (?=), (?!), (?<=), (?<!), (?is-m), (?i-m:)
pattern: /\((?:\?(?:<[^<>']+>|'[^<>']+'|[>:]|<?[=!]|[idmnsuxU]+(?:-[idmnsuxU]+)?:?))?/,
+ alias: 'punctuation',
inside: {
'group-name': groupName
}
},
- /\)/
+ {
+ pattern: /\)/,
+ alias: 'punctuation'
+ }
],
- 'quantifier': /[+*?]|\{(?:\d+,?\d*)\}/,
- 'alternation': /\|/
+ 'quantifier': {
+ pattern: /(?:[+*?]|\{(?:\d+,?\d*)\})[?+]?/,
+ alias: 'number'
+ },
+ 'alternation': {
+ pattern: /\|/,
+ alias: 'keyword'
+ }
};
var grammar = Prism.languages[lang];
if (grammar) {
grammar['regex'].inside = {
- 'regex-flags': /[a-z]+$/,
- 'regex-delimiter': /^\/|\/$/,
'language-regex': {
- pattern: /[\s\S]+/,
+ pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/i,
+ lookbehind: true,
inside: Prism.languages.regex
- }
+ },
+ 'regex-flags': /[a-z]+$/i,
+ 'regex-delimiter': /^\/|\/$/,
};
}
});
'punctuation' : /[{}[\];(),.:]/
};
+Prism.languages.rpy = Prism.languages.renpy;
+
return Prism; })
\ No newline at end of file
'character': /\B`[^\s`'",.:;#\/\\()<>\[\]{}]\b/,
'regex': {
- pattern: /(^|[^/])\/(?!\/)(?:\[.+?]|\\.|[^/\\\r\n])+\/(?=\s*(?:$|[\r\n,.;})]))/,
+ pattern: /(^|[^/])\/(?!\/)(?:\[[^\n\r\]]*\]|\\.|[^/\\\r\n\[])+\/(?=\s*(?:$|[\r\n,.;})]))/,
lookbehind: true,
greedy: true
},
pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
greedy: true
},
- 'number': /[+-]?(?:(?:\d+\.\d+)|(?:\d+))/,
+ 'number': /[+-]?\b(?:\d+\.\d+|\d+)\b/,
'punctuation': /(?:\.{2,3})|[`,.:;=\/\\()<>\[\]{}]/,
var docTag = {
- pattern: /(\[Documentation\](?: |\t)[ \t]*)(?![ \t]|#)(?:.|[ \t]*(?:\r\n?|\n)[ \t]*\.{3}[ \t]*)+/,
+ pattern: /(\[Documentation\](?: |\t)[ \t]*)(?![ \t]|#)(?:.|(?:\r\n?|\n)[ \t]*\.{3})+/,
lookbehind: true,
alias: 'string'
};
Prism.languages['robotframework'] = {
'settings': createSection('Settings', {
'documentation': {
- pattern: /([\r\n] ?Documentation(?: |\t)[ \t]*)(?![ \t]|#)(?:.|[ \t]*(?:\r\n?|\n)[ \t]*\.{3}[ \t]*)+/,
+ pattern: /([\r\n] ?Documentation(?: |\t)[ \t]*)(?![ \t]|#)(?:.|(?:\r\n?|\n)[ \t]*\.{3})+/,
lookbehind: true,
alias: 'string'
},
Prism.languages.insertBefore('ruby', 'keyword', {
'regex': [
{
- pattern: /%r([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[gim]{0,3}/,
- greedy: true,
- inside: {
- 'interpolation': interpolation
- }
- },
- {
- pattern: /%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,
- greedy: true,
- inside: {
- 'interpolation': interpolation
- }
- },
- {
- // Here we need to specifically allow interpolation
- pattern: /%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,
- greedy: true,
- inside: {
- 'interpolation': interpolation
- }
- },
- {
- pattern: /%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,
- greedy: true,
- inside: {
- 'interpolation': interpolation
- }
- },
- {
- pattern: /%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,
+ pattern: RegExp(/%r/.source + '(?:' + [
+ /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[gim]{0,3}/.source,
+ /\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/.source,
+ // Here we need to specifically allow interpolation
+ /\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/.source,
+ /\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/.source,
+ /<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/.source
+ ].join('|') + ')'),
greedy: true,
inside: {
'interpolation': interpolation
Prism.languages.ruby.string = [
{
- pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
- greedy: true,
- inside: {
- 'interpolation': interpolation
- }
- },
- {
- pattern: /%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,
- greedy: true,
- inside: {
- 'interpolation': interpolation
- }
- },
- {
- // Here we need to specifically allow interpolation
- pattern: /%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,
- greedy: true,
- inside: {
- 'interpolation': interpolation
- }
- },
- {
- pattern: /%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,
- greedy: true,
- inside: {
- 'interpolation': interpolation
- }
- },
- {
- pattern: /%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,
+ pattern: RegExp(/%[qQiIwWxs]?/.source + '(?:' + [
+ /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
+ /\((?:[^()\\]|\\[\s\S])*\)/.source,
+ // Here we need to specifically allow interpolation
+ /\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/.source,
+ /\[(?:[^\[\]\\]|\\[\s\S])*\]/.source,
+ /<(?:[^<>\\]|\\[\s\S])*>/.source
+ ].join('|') + ')'),
greedy: true,
inside: {
'interpolation': interpolation
define(["prism/prism"], function () {
-/* TODO
- Add support for Markdown notation inside doc comments
- Add support for nested block comments...
- Match closure params even when not followed by dash or brace
- Add better support for macro definition
-*/
+(function (Prism) {
-Prism.languages.rust = {
- 'comment': [
- {
- pattern: /(^|[^\\])\/\*[\s\S]*?\*\//,
- lookbehind: true
- },
- {
- pattern: /(^|[^\\:])\/\/.*/,
- lookbehind: true
- }
- ],
- 'string': [
- {
- pattern: /b?r(#*)"(?:\\.|(?!"\1)[^\\\r\n])*"\1/,
+ var multilineComment = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source;
+ for (var i = 0; i < 2; i++) {
+ // support 4 levels of nested comments
+ multilineComment = multilineComment.replace(/<self>/g, function () { return multilineComment; });
+ }
+ multilineComment = multilineComment.replace(/<self>/g, function () { return /[^\s\S]/.source; });
+
+
+ Prism.languages.rust = {
+ 'comment': [
+ {
+ pattern: RegExp(/(^|[^\\])/.source + multilineComment),
+ lookbehind: true,
+ greedy: true
+ },
+ {
+ pattern: /(^|[^\\:])\/\/.*/,
+ lookbehind: true,
+ greedy: true
+ }
+ ],
+ 'string': {
+ pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,
greedy: true
},
- {
- pattern: /b?"(?:\\.|[^\\\r\n"])*"/,
- greedy: true
- }
- ],
- 'char': {
- pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u{(?:[\da-fA-F]_*){1,6}|.)|[^\\\r\n\t'])'/,
- alias: 'string'
- },
- 'lifetime-annotation': {
- pattern: /'[^\s>']+/,
- alias: 'symbol'
- },
- 'keyword': /\b(?:abstract|alignof|as|async|await|be|box|break|const|continue|crate|do|dyn|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|match|mod|move|mut|offsetof|once|override|priv|pub|pure|ref|return|sizeof|static|self|Self|struct|super|true|trait|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
+ 'char': {
+ pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u{(?:[\da-fA-F]_*){1,6}|.)|[^\\\r\n\t'])'/,
+ greedy: true,
+ alias: 'string'
+ },
+ 'attribute': {
+ pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,
+ greedy: true,
+ alias: 'attr-name',
+ inside: {
+ 'string': null // see below
+ }
+ },
+
+ // Closure params should not be confused with bitwise OR |
+ 'closure-params': {
+ pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,
+ lookbehind: true,
+ greedy: true,
+ inside: {
+ 'closure-punctuation': {
+ pattern: /^\||\|$/,
+ alias: 'punctuation'
+ },
+ rest: null // see below
+ }
+ },
+
+ 'lifetime-annotation': {
+ pattern: /'\w+/,
+ alias: 'symbol'
+ },
+
+ 'fragment-specifier': {
+ pattern: /(\$\w+:)[a-z]+/,
+ lookbehind: true,
+ alias: 'punctuation'
+ },
+ 'variable': /\$\w+/,
- 'attribute': {
- pattern: /#!?\[.+?\]/,
- greedy: true,
- alias: 'attr-name'
- },
+ 'function-definition': {
+ pattern: /(\bfn\s+)\w+/,
+ lookbehind: true,
+ alias: 'function'
+ },
+ 'type-definition': {
+ pattern: /(\b(?:enum|struct|union)\s+)\w+/,
+ lookbehind: true,
+ alias: 'class-name'
+ },
+ 'module-declaration': [
+ {
+ pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,
+ lookbehind: true,
+ alias: 'namespace'
+ },
+ {
+ pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,
+ lookbehind: true,
+ alias: 'namespace',
+ inside: {
+ 'punctuation': /::/
+ }
+ }
+ ],
+ 'keyword': [
+ // https://github.com/rust-lang/reference/blob/master/src/keywords.md
+ /\b(?:abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|Self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
+ // primitives and str
+ // https://doc.rust-lang.org/stable/rust-by-example/primitives.html
+ /\b(?:[ui](?:8|16|32|64|128|size)|f(?:32|64)|bool|char|str)\b/
+ ],
+
+ // functions can technically start with an upper-case letter, but this will introduce a lot of false positives
+ // and Rust's naming conventions recommend snake_case anyway.
+ // https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
+ 'function': /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
+ 'macro': {
+ pattern: /\w+!/,
+ alias: 'property'
+ },
+ 'constant': /\b[A-Z_][A-Z_\d]+\b/,
+ 'class-name': /\b[A-Z]\w*\b/,
+
+ 'namespace': {
+ pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,
+ inside: {
+ 'punctuation': /::/
+ }
+ },
- 'function': [
- /\w+(?=\s*\()/,
- // Macros can use parens or brackets
- /\w+!(?=\s*\(|\[)/
- ],
- 'macro-rules': {
- pattern: /\w+!/,
- alias: 'function'
- },
+ // Hex, oct, bin, dec numbers with visual separators and type suffix
+ 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:[iu](?:8|16|32|64|size)?|f32|f64))?\b/,
+ 'boolean': /\b(?:false|true)\b/,
+ 'punctuation': /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
+ 'operator': /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
+ };
- // Hex, oct, bin, dec numbers with visual separators and type suffix
- 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:[iu](?:8|16|32|64)?|f32|f64))?\b/,
+ Prism.languages.rust['closure-params'].inside.rest = Prism.languages.rust;
+ Prism.languages.rust['attribute'].inside['string'] = Prism.languages.rust['string'];
- // Closure params should not be confused with bitwise OR |
- 'closure-params': {
- pattern: /\|[^|]*\|(?=\s*[{-])/,
- inside: {
- 'punctuation': /[|:,]/,
- 'operator': /[&*]/
- }
- },
- 'punctuation': /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
- 'operator': /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
-};
+}(Prism));
return Prism; })
\ No newline at end of file
alias: 'number'
};
+ var macroVariable = {
+ pattern: /&[a-z_][a-z_0-9]*/i
+ };
+
+ var macroKeyword = {
+ pattern: /((?:^|\s|=|\())%(?:ABORT|BY|CMS|COPY|DISPLAY|DO|ELSE|END|EVAL|GLOBAL|GO|GOTO|IF|INC|INCLUDE|INDEX|INPUT|KTRIM|LENGTH|LET|LIST|LOCAL|PUT|QKTRIM|QSCAN|QSUBSTR|QSYSFUNC|QUPCASE|RETURN|RUN|SCAN|SUBSTR|SUPERQ|SYMDEL|SYMGLOBL|SYMLOCAL|SYMEXIST|SYSCALL|SYSEVALF|SYSEXEC|SYSFUNC|SYSGET|SYSRPUT|THEN|TO|TSO|UNQUOTE|UNTIL|UPCASE|WHILE|WINDOW)\b/i,
+ lookbehind: true,
+ alias: 'keyword'
+ };
+
var step = {
pattern: /(^|\s+)(?:proc\s+\w+|quit|run|data(?!\=))\b/i,
alias: 'keyword',
lookbehind: true
},
'operator': /=/,
- 'macro-variable': {
- pattern: /&[^\.]*\./i,
- alias: 'string'
- },
+ 'macro-variable': macroVariable,
'arg': {
pattern: /[A-Z]+/i,
alias: 'keyword'
pattern: /(?:action)/i,
alias: 'keyword'
},
+ 'comment': comment,
'function': func,
'arg-value': args['arg-value'],
'operator': args.operator,
- 'comment': comment,
'argument': args.arg,
'number': number,
'numeric-constant': numericConstant,
},
'proc-groovy': {
- pattern: /(^proc\s+groovy(?:\s+[\w|=]+)?;)(?:\s*submit)[\s\S]+?(?=^(?:proc\s+\w+|quit|run|data);|(?![\s\S]))/im,
+ pattern: /(^proc\s+groovy(?:\s+[\w|=]+)?;)[\s\S]+?(?=^(?:proc\s+\w+|quit|run|data);|(?![\s\S]))/im,
lookbehind: true,
inside: {
+ 'comment': comment,
'groovy': {
pattern: RegExp(/(^[ \t]*submit(?:\s+(?:load|parseonly|norun))?)(?:<str>|[^"'])+?(?=endsubmit;)/.source.replace(/<str>/g, function () { return stringPattern; }), 'im'),
lookbehind: true,
alias: 'language-groovy',
inside: Prism.languages.groovy
},
+ 'keyword': keywords,
'submit-statement': submitStatement,
'global-statements': globalStatements,
'number': number,
},
'proc-lua': {
- pattern: /(^proc\s+lua(?:\s+[\w|=]+)?;)(?:\s*submit)[\s\S]+?(?=^(?:proc\s+\w+|quit|run|data);|(?![\s\S]))/im,
+ pattern: /(^proc\s+lua(?:\s+[\w|=]+)?;)[\s\S]+?(?=^(?:proc\s+\w+|quit|run|data);|(?![\s\S]))/im,
lookbehind: true,
inside: {
+ 'comment': comment,
'lua': {
pattern: RegExp(/(^[ \t]*submit(?:\s+(?:load|parseonly|norun))?)(?:<str>|[^"'])+?(?=endsubmit;)/.source.replace(/<str>/g, function () { return stringPattern; }), 'im'),
lookbehind: true,
alias: 'language-lua',
inside: Prism.languages.lua
},
+ 'keyword': keywords,
'submit-statement': submitStatement,
'global-statements': globalStatements,
'number': number,
pattern: /(^proc\s+cas(?:\s+[\w|=]+)?;)[\s\S]+?(?=^(?:proc\s+\w+|quit|data);|(?![\s\S]))/im,
lookbehind: true,
inside: {
+ 'comment': comment,
'statement-var': {
pattern: /((?:^|\s)=?)saveresult\s+[^;]+/im,
lookbehind: true,
'step': step,
'keyword': keywords,
'function': func,
- 'comment': comment,
'format': format,
'altformat': altformat,
'global-statements': globalStatements,
lookbehind: true,
inside: args
},
-
/*Special keywords within macros*/
- 'macro-keyword': {
- pattern: /((?:^|\s)=?)%(?:ABORT|BQUOTE|BY|CMS|COPY|DISPLAY|DO|ELSE|END|EVAL|GLOBAL|GO|GOTO|IF|INC|INCLUDE|INDEX|INPUT|KTRIM|LENGTH|LET|LIST|LOCAL|NRBQUOTE|NRQUOTE|NRSTR|PUT|QKTRIM|QSCAN|QSUBSTR|QSYSFUNC|QUOTE|QUPCASE|RETURN|RUN|SCAN|STR|SUBSTR|SUPERQ|SYMDEL|SYMGLOBL|SYMLOCAL|SYMEXIST|SYSCALL|SYSEVALF|SYSEXEC|SYSFUNC|SYSGET|SYSRPUT|THEN|TO|TSO|UNQUOTE|UNTIL|UPCASE|WHILE|WINDOW)\b/i,
+ 'macro-keyword': macroKeyword,
+ 'macro-variable': macroVariable,
+ 'macro-string-functions': {
+ pattern: /((?:^|\s|=))%(?:NRBQUOTE|NRQUOTE|NRSTR|BQUOTE|QUOTE|STR)\(.*?(?:[^%]\))/i,
lookbehind: true,
- alias: 'keyword'
+ inside: {
+ 'function': {
+ pattern: /%(?:NRBQUOTE|NRQUOTE|NRSTR|BQUOTE|QUOTE|STR)/i,
+ alias: 'keyword'
+ },
+ 'macro-keyword': macroKeyword,
+ 'macro-variable': macroVariable,
+ 'escaped-char': {
+ pattern: /%['"()<>=¬^~;,#]/i,
+ },
+ 'punctuation': punctuation
+ }
},
'macro-declaration': {
pattern: /^%macro[^;]+(?=;)/im,
Prism.languages.scheme = {
'comment': /;.*/,
'string': {
- pattern: /"(?:[^"\\]|\\.)*"|'[^()#'\s]+/,
+ pattern: /"(?:[^"\\]|\\.)*"/,
+ greedy: true
+ },
+ 'symbol': {
+ pattern: /'[^()#'\s]+/,
greedy: true
},
'character': {
- pattern: /#\\(?:[ux][a-fA-F\d]+|[a-zA-Z]+|\S)/,
+ pattern: /#\\(?:[ux][a-fA-F\d]+|[-a-zA-Z]+|\S)/,
+ greedy: true,
alias: 'string'
},
+ 'lambda-parameter': [
+ // https://www.cs.cmu.edu/Groups/AI/html/r4rs/r4rs_6.html#SEC30
+ {
+ pattern: /(\(lambda\s+)[^()'\s]+/,
+ lookbehind: true
+ },
+ {
+ pattern: /(\(lambda\s+\()[^()']+/,
+ lookbehind: true
+ }
+ ],
'keyword': {
- pattern: /(\()(?:define(?:-syntax|-library|-values)?|(?:case-)?lambda|let(?:\*|rec)?(?:-values)?|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-rules)(?=[()\s])/,
+ pattern: /(\()(?:define(?:-library|-macro|-syntax|-values)?|defmacro|(?:case-)?lambda|let(?:(?:\*|rec)?(?:-values)?|-syntax|rec-syntax)|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-(?:case|rules))(?=[()\s]|$)/,
lookbehind: true
},
'builtin': {
- pattern: /(\()(?:(?:cons|car|cdr|list|call-with-current-continuation|call\/cc|append|abs|apply|eval)\b|null\?|pair\?|boolean\?|eof-object\?|char\?|procedure\?|number\?|port\?|string\?|vector\?|symbol\?|bytevector\?)(?=[()\s])/,
+ pattern: /(\()(?:(?:cons|car|cdr|list|call-with-current-continuation|call\/cc|append|abs|apply|eval)\b|null\?|pair\?|boolean\?|eof-object\?|char\?|procedure\?|number\?|port\?|string\?|vector\?|symbol\?|bytevector\?)(?=[()\s]|$)/,
lookbehind: true
},
'number': {
- pattern: /([\s()])[-+]?(?:\d+\/\d+|\d*\.?\d+(?:\s*[-+]\s*\d*\.?\d+i)?)\b/,
+ // This pattern (apart from the lookarounds) works like this:
+ //
+ // Decimal numbers
+ // <dec real> := \d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+
+ // <dec complex> := <dec real>(?:[+-]<dec real>i)?|<dec real>i
+ // <dec prefix> := (?:#d(?:#[ei])?|#[ei](?:#d)?)?
+ // <dec number> := <dec prefix>[+-]?<complex>
+ //
+ // Binary, octal, and hexadecimal numbers
+ // <b.o.x. real> := [\da-fA-F]+(?:\/[\da-fA-F]+)?
+ // <b.o.x. complex> := <b.o.x. real>(?:[+-]<b.o.x. real>i)?|<b.o.x. real>i
+ // <b.o.x. prefix> := #[box](?:#[ei])?|#[ei](?:#[box])?
+ // <b.o.x. number> := <b.o.x. prefix>[+-]?<b.o.x. complex>
+ //
+ // <number> := <dec number>|<b.o.x. number>
+ pattern: /(^|[\s()])(?:(?:#d(?:#[ei])?|#[ei](?:#d)?)?[+-]?(?:(?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)(?:[+-](?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)i)?|(?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)i)|(?:#[box](?:#[ei])?|#[ei](?:#[box])?)[+-]?(?:[\da-fA-F]+(?:\/[\da-fA-F]+)?(?:[+-][\da-fA-F]+(?:\/[\da-fA-F]+)?i)?|[\da-fA-F]+(?:\/[\da-fA-F]+)?i))(?=[()\s]|$)/,
+ lookbehind: true
+ },
+ 'boolean': {
+ pattern: /(^|[\s()])#[ft](?=[()\s]|$)/,
lookbehind: true
},
- 'boolean': /#[tf]/,
'operator': {
- pattern: /(\()(?:[-+*%\/]|[<>]=?|=>?)(?=\s|$)/,
+ pattern: /(\()(?:[-+*%\/]|[<>]=?|=>?)(?=[()\s]|$)/,
lookbehind: true
},
'function': {
- pattern: /(\()[^()'\s]+(?=[()\s)]|$)/,
+ pattern: /(\()[^()'\s]+(?=[()\s]|$)/,
lookbehind: true
},
'punctuation': /[()']/
// here doc
// 1 capturing group
- /<<-?\s*(\w+?)\s*(?:\r?\n|\r)[\s\S]*?(?:\r?\n|\r)\2/.source,
+ /<<-?\s*(\w+?)[ \t]*(?!.)[\s\S]*?[\r\n]\2/.source,
// here doc quoted
// 2 capturing group
- /<<-?\s*(["'])(\w+)\3\s*(?:\r?\n|\r)[\s\S]*?(?:\r?\n|\r)\4/.source
+ /<<-?\s*(["'])(\w+)\3[ \t]*(?!.)[\s\S]*?[\r\n]\4/.source
].join('|');
Prism.languages['shell-session'] = {
}
}
},
- 'output': /.(?:.*(?:\r\n?|\n|.$))*/
+ 'output': /.(?:.*(?:[\r\n]|.$))*/
};
}(Prism));
--- /dev/null
+define(["prism/prism"], function () {
+// Test files for the parser itself:
+// https://github.com/JesusFreke/smali/tree/master/smali/src/test/resources/LexerTest
+
+Prism.languages.smali = {
+ 'comment': /#.*/,
+ 'string': {
+ pattern: /"(?:[^\r\n\\"]|\\.)*"|'(?:[^\r\n\\']|\\(?:.|u[\da-fA-F]{4}))'/,
+ greedy: true
+ },
+
+ 'class-name': {
+ pattern: /L(?:(?:\w+|`[^`\r\n]*`)\/)*(?:[\w$]+|`[^`\r\n]*`)(?=\s*;)/,
+ inside: {
+ 'class-name': {
+ pattern: /(^L|\/)(?:[\w$]+|`[^`\r\n]*`)$/,
+ lookbehind: true
+ },
+ 'namespace': {
+ pattern: /^(L)(?:(?:\w+|`[^`\r\n]*`)\/)+/,
+ lookbehind: true,
+ inside: {
+ 'punctuation': /\//
+ }
+ },
+ 'builtin': /^L/
+ }
+ },
+ 'builtin': [
+ {
+ // Reference: https://github.com/JesusFreke/smali/wiki/TypesMethodsAndFields#types
+ pattern: /([();\[])[BCDFIJSVZ]+/,
+ lookbehind: true
+ },
+ {
+ // e.g. .field mWifiOnUid:I
+ pattern: /([\w$>]:)[BCDFIJSVZ]/,
+ lookbehind: true
+ }
+ ],
+ 'keyword': [
+ {
+ pattern: /(\.end\s+)[\w-]+/,
+ lookbehind: true
+ },
+ {
+ pattern: /(^|[^\w.-])\.(?!\d)[\w-]+/,
+ lookbehind: true
+ },
+ {
+ pattern: /(^|[^\w.-])(?:abstract|annotation|bridge|constructor|enum|final|interface|private|protected|public|runtime|static|synthetic|system|transient)(?![\w.-])/,
+ lookbehind: true
+ }
+ ],
+ 'function': {
+ pattern: /(^|[^\w.-])(?:\w+|<[\w$-]+>)(?=\()/,
+ lookbehind: true
+ },
+
+ 'field': {
+ pattern: /[\w$]+(?=:)/,
+ alias: 'variable'
+ },
+ 'register': {
+ pattern: /(^|[^\w.-])[vp]\d(?![\w.-])/,
+ lookbehind: true,
+ alias: 'variable'
+ },
+
+ 'boolean': {
+ pattern: /(^|[^\w.-])(?:true|false)(?![\w.-])/,
+ lookbehind: true
+ },
+ 'number': {
+ pattern: /(^|[^/\w.-])-?(?:NAN|INFINITY|0x(?:[\dA-F]+(?:\.[\dA-F]*)?|\.[\dA-F]+)(?:p[+-]?[\dA-F]+)?|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)[dflst]?(?![\w.-])/i,
+ lookbehind: true
+ },
+
+ 'label': {
+ pattern: /(:)\w+/,
+ lookbehind: true,
+ alias: 'property'
+ },
+
+ 'operator': /->|\.\.|[\[=]/,
+ 'punctuation': /[{}(),;:]/
+};
+
+return Prism; })
\ No newline at end of file
}
});
+Prism.languages.sol = Prism.languages.solidity;
+
return Prism; })
\ No newline at end of file
lookbehind: true
},
'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i, // Should we highlight user defined functions too?
- 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURNS?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
+ 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:S|ING)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
'number': /\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i,
'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
define(["prism/prism"], function () {
(function (Prism) {
+ var unit = {
+ pattern: /(\b\d+)(?:%|[a-z]+)/,
+ lookbehind: true
+ };
+ // 123 -123 .123 -.123 12.3 -12.3
+ var number = {
+ pattern: /(^|[^\w.-])-?\d*\.?\d+/,
+ lookbehind: true
+ };
+
var inside = {
- 'url': /url\((["']?).*?\1\)/i,
+ 'comment': {
+ pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
+ lookbehind: true
+ },
+ 'url': {
+ pattern: /url\((["']?).*?\1\)/i,
+ greedy: true
+ },
'string': {
pattern: /("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/,
greedy: true
lookbehind: true
},
'hexcode': /#[\da-f]{3,6}/i,
- 'number': /\b\d+(?:\.\d+)?%?/,
+ 'color': [
+ /\b(?:AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGr[ae]y|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGr[ae]y|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGr[ae]y|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gr[ae]y|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGr[ae]y|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGr[ae]y|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGr[ae]y|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)\b/i,
+ {
+ pattern: /\b(?:rgb|hsl)\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)\B|\b(?:rgb|hsl)a\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*(?:0|0?\.\d+|1)\s*\)\B/i,
+ inside: {
+ 'unit': unit,
+ 'number': number,
+ 'function': /[\w-]+(?=\()/,
+ 'punctuation': /[(),]/
+ }
+ }
+ ],
+ 'entity': /\\[\da-f]{1,8}/i,
+ 'unit': unit,
'boolean': /\b(?:true|false)\b/,
'operator': [
// We want non-word chars around "-" because it is
// accepted in property names.
- /~|[+!\/%<>?=]=?|[-:]=|\*[*=]?|\.+|&&|\|\||\B-\B|\b(?:and|in|is(?: a| defined| not|nt)?|not|or)\b/
+ /~|[+!\/%<>?=]=?|[-:]=|\*[*=]?|\.{2,3}|&&|\|\||\B-\B|\b(?:and|in|is(?: a| defined| not|nt)?|not|or)\b/
],
+ 'number': number,
'punctuation': /[{}()\[\];:,]/
};
};
Prism.languages.stylus = {
- 'comment': {
- pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
- lookbehind: true
- },
'atrule-declaration': {
pattern: /(^\s*)@.+/m,
lookbehind: true,
lookbehind: true,
inside: {
'interpolation': inside.interpolation,
+ 'comment': inside.comment,
'punctuation': /[{},]/
}
},
'func': inside.func,
'string': inside.string,
+ 'comment': {
+ pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
+ lookbehind: true,
+ greedy: true
+ },
'interpolation': inside.interpolation,
'punctuation': /[{}()\[\];:.]/
};
-define(["prism/prism","prism/components/prism-t4-templating","prism/components/prism-visual-basic"], function () {
-Prism.languages['t4-vb'] = Prism.languages['t4-templating'].createT4('visual-basic');
+define(["prism/prism","prism/components/prism-t4-templating","prism/components/prism-vbnet"], function () {
+Prism.languages['t4-vb'] = Prism.languages['t4-templating'].createT4('vbnet');
return Prism; })
\ No newline at end of file
(function (Prism) {
// We don't allow for pipes inside parentheses
// to not break table pattern |(. foo |). bar |
- var modifierRegex = /(?:\([^|)]+\)|\[[^\]]+\]|\{[^}]+\})+/.source;
+ var modifierRegex = /\([^|()\n]+\)|\[[^\]\n]+\]|\{[^}\n]+\}/.source;
+ // Opening and closing parentheses which are not a modifier
+ // This pattern is necessary to prevent exponential backtracking
+ var parenthesesRegex = /\)|\((?![^|()\n]+\))/.source;
+ /**
+ * @param {string} source
+ * @param {string} [flags]
+ */
+ function withModifier(source, flags) {
+ return RegExp(
+ source
+ .replace(/<MOD>/g, function () { return '(?:' + modifierRegex + ')'; })
+ .replace(/<PAR>/g, function () { return '(?:' + parenthesesRegex + ')'; }),
+ flags || '');
+ }
+
var modifierTokens = {
'css': {
pattern: /\{[^}]+\}/,
// h1. Header 1
'block-tag': {
- pattern: RegExp('^[a-z]\\w*(?:' + modifierRegex + '|[<>=()])*\\.'),
+ pattern: withModifier(/^[a-z]\w*(?:<MOD>|<PAR>|[<>=])*\./.source),
inside: {
'modifier': {
- pattern: RegExp('(^[a-z]\\w*)(?:' + modifierRegex + '|[<>=()])+(?=\\.)'),
+ pattern: withModifier(/(^[a-z]\w*)(?:<MOD>|<PAR>|[<>=])+(?=\.)/.source),
lookbehind: true,
inside: modifierTokens
},
// # List item
// * List item
'list': {
- pattern: RegExp('^[*#]+(?:' + modifierRegex + ')?\\s+.+', 'm'),
+ pattern: withModifier(/^[*#]+<MOD>*\s+.+/.source, 'm'),
inside: {
'modifier': {
- pattern: RegExp('(^[*#]+)' + modifierRegex),
+ pattern: withModifier(/(^[*#]+)<MOD>+/.source),
lookbehind: true,
inside: modifierTokens
},
'table': {
// Modifiers can be applied to the row: {color:red}.|1|2|3|
// or the cell: |{color:red}.1|2|3|
- pattern: RegExp('^(?:(?:' + modifierRegex + '|[<>=()^~])+\\.\\s*)?(?:\\|(?:(?:' + modifierRegex + '|[<>=()^~_]|[\\\\/]\\d+)+\\.)?[^|]*)+\\|', 'm'),
+ pattern: withModifier(/^(?:(?:<MOD>|<PAR>|[<>=^~])+\.\s*)?(?:\|(?:(?:<MOD>|<PAR>|[<>=^~_]|[\\/]\d+)+\.)?[^|]*)+\|/.source, 'm'),
inside: {
'modifier': {
// Modifiers for rows after the first one are
// preceded by a pipe and a line feed
- pattern: RegExp('(^|\\|(?:\\r?\\n|\\r)?)(?:' + modifierRegex + '|[<>=()^~_]|[\\\\/]\\d+)+(?=\\.)'),
+ pattern: withModifier(/(^|\|(?:\r?\n|\r)?)(?:<MOD>|<PAR>|[<>=^~_]|[\\/]\d+)+(?=\.)/.source),
lookbehind: true,
inside: modifierTokens
},
},
'inline': {
- pattern: RegExp('(\\*\\*|__|\\?\\?|[*_%@+\\-^~])(?:' + modifierRegex + ')?.+?\\1'),
+ pattern: withModifier(/(^|[^a-zA-Z\d])(\*\*|__|\?\?|[*_%@+\-^~])<MOD>*.+?\2(?![a-zA-Z\d])/.source),
+ lookbehind: true,
inside: {
// Note: superscripts and subscripts are not handled specifically
// *bold*, **bold**
'bold': {
- pattern: RegExp('(^(\\*\\*?)(?:' + modifierRegex + ')?).+?(?=\\2)'),
+ pattern: withModifier(/(^(\*\*?)<MOD>*).+?(?=\2)/.source),
lookbehind: true
},
// _italic_, __italic__
'italic': {
- pattern: RegExp('(^(__?)(?:' + modifierRegex + ')?).+?(?=\\2)'),
+ pattern: withModifier(/(^(__?)<MOD>*).+?(?=\2)/.source),
lookbehind: true
},
// ??cite??
'cite': {
- pattern: RegExp('(^\\?\\?(?:' + modifierRegex + ')?).+?(?=\\?\\?)'),
+ pattern: withModifier(/(^\?\?<MOD>*).+?(?=\?\?)/.source),
lookbehind: true,
alias: 'string'
},
// @code@
'code': {
- pattern: RegExp('(^@(?:' + modifierRegex + ')?).+?(?=@)'),
+ pattern: withModifier(/(^@<MOD>*).+?(?=@)/.source),
lookbehind: true,
alias: 'keyword'
},
// +inserted+
'inserted': {
- pattern: RegExp('(^\\+(?:' + modifierRegex + ')?).+?(?=\\+)'),
+ pattern: withModifier(/(^\+<MOD>*).+?(?=\+)/.source),
lookbehind: true
},
// -deleted-
'deleted': {
- pattern: RegExp('(^-(?:' + modifierRegex + ')?).+?(?=-)'),
+ pattern: withModifier(/(^-<MOD>*).+?(?=-)/.source),
lookbehind: true
},
// %span%
'span': {
- pattern: RegExp('(^%(?:' + modifierRegex + ')?).+?(?=%)'),
+ pattern: withModifier(/(^%<MOD>*).+?(?=%)/.source),
lookbehind: true
},
'modifier': {
- pattern: RegExp('(^\\*\\*|__|\\?\\?|[*_%@+\\-^~])' + modifierRegex),
+ pattern: withModifier(/(^\*\*|__|\?\?|[*_%@+\-^~])<MOD>+/.source),
lookbehind: true,
inside: modifierTokens
},
// "text":http://example.com
// "text":link-ref
'link': {
- pattern: RegExp('"(?:' + modifierRegex + ')?[^"]+":.+?(?=[^\\w/]?(?:\\s|$))'),
+ pattern: withModifier(/"<MOD>*[^"]+":.+?(?=[^\w/]?(?:\s|$))/.source),
inside: {
'text': {
- pattern: RegExp('(^"(?:' + modifierRegex + ')?)[^"]+(?=")'),
+ pattern: withModifier(/(^"<MOD>*)[^"]+(?=")/.source),
lookbehind: true
},
'modifier': {
- pattern: RegExp('(^")' + modifierRegex),
+ pattern: withModifier(/(^")<MOD>+/.source),
lookbehind: true,
inside: modifierTokens
},
// !image.jpg!
// !image.jpg(Title)!:http://example.com
'image': {
- pattern: RegExp('!(?:' + modifierRegex + '|[<>=()])*[^!\\s()]+(?:\\([^)]+\\))?!(?::.+?(?=[^\\w/]?(?:\\s|$)))?'),
+ pattern: withModifier(/!(?:<MOD>|<PAR>|[<>=])*[^!\s()]+(?:\([^)]+\))?!(?::.+?(?=[^\w/]?(?:\s|$)))?/.source),
inside: {
'source': {
- pattern: RegExp('(^!(?:' + modifierRegex + '|[<>=()])*)[^!\\s()]+(?:\\([^)]+\\))?(?=!)'),
+ pattern: withModifier(/(^!(?:<MOD>|<PAR>|[<>=])*)[^!\s()]+(?:\([^)]+\))?(?=!)/.source),
lookbehind: true,
alias: 'url'
},
'modifier': {
- pattern: RegExp('(^!)(?:' + modifierRegex + '|[<>=()])+'),
+ pattern: withModifier(/(^!)(?:<MOD>|<PAR>|[<>=])+/.source),
lookbehind: true,
inside: modifierTokens
},
define(["prism/prism"], function () {
(function (Prism) {
- // pattern: /(?:[\w-]+|'[^'\n\r]*'|"(?:\.|[^\\"\r\n])*")/
- var key = "(?:[\\w-]+|'[^'\n\r]*'|\"(?:\\.|[^\\\\\"\r\n])*\")";
+ var key = /(?:[\w-]+|'[^'\n\r]*'|"(?:\\.|[^\\"\r\n])*")/.source;
+
+ /**
+ * @param {string} pattern
+ */
+ function insertKey(pattern) {
+ return pattern.replace(/__/g, function () { return key; });
+ }
Prism.languages.toml = {
'comment': {
greedy: true
},
'table': {
- pattern: RegExp("(^\\s*\\[\\s*(?:\\[\\s*)?)" + key + "(?:\\s*\\.\\s*" + key + ")*(?=\\s*\\])", "m"),
+ pattern: RegExp(insertKey(/(^\s*\[\s*(?:\[\s*)?)__(?:\s*\.\s*__)*(?=\s*\])/.source), 'm'),
lookbehind: true,
greedy: true,
alias: 'class-name'
},
'key': {
- pattern: RegExp("(^\\s*|[{,]\\s*)" + key + "(?:\\s*\\.\\s*" + key + ")*(?=\\s*=)", "m"),
+ pattern: RegExp(insertKey(/(^\s*|[{,]\s*)__(?:\s*\.\s*__)*(?=\s*=)/.source), 'm'),
lookbehind: true,
greedy: true,
alias: 'property'
'date': [
{
// Offset Date-Time, Local Date-Time, Local Date
- pattern: /\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?/i,
+ pattern: /\b\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?\b/i,
alias: 'number'
},
{
// Local Time
- pattern: /\d{2}:\d{2}:\d{2}(?:\.\d+)?/i,
+ pattern: /\b\d{2}:\d{2}:\d{2}(?:\.\d+)?\b/,
alias: 'number'
}
],
- 'number': /(?:\b0(?:x[\da-zA-Z]+(?:_[\da-zA-Z]+)*|o[0-7]+(?:_[0-7]+)*|b[10]+(?:_[10]+)*))\b|[-+]?\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?\b|[-+]?(?:inf|nan)\b/,
+ 'number': /(?:\b0(?:x[\da-zA-Z]+(?:_[\da-zA-Z]+)*|o[0-7]+(?:_[0-7]+)*|b[10]+(?:_[10]+)*))\b|[-+]?\b\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?\b|[-+]?\b(?:inf|nan)\b/,
'boolean': /\b(?:true|false)\b/,
'punctuation': /[.,=[\]{}]/
};
Prism.languages.insertBefore('tt2', 'number', {
'operator': /=[>=]?|!=?|<=?|>=?|&&|\|\|?|\b(?:and|or|not)\b/,
'variable': {
- pattern: /[a-z]\w*(?:\s*\.\s*(?:\d+|\$?[a-z]\w*))*/i
+ pattern: /\b[a-z]\w*(?:\s*\.\s*(?:\d+|\$?[a-z]\w*))*\b/i
}
});
greedy: true
},
'url': {
- pattern: /<(?:[^\x00-\x20<>"{}|^`\\]|\\(?:u[\da-f]{4}|U[\da-f]{8}))*>/i,
+ pattern: /<(?:[^\x00-\x20<>"{}|^`\\]|\\(?:u[\da-fA-F]{4}|U[\da-fA-F]{8}))*>/,
greedy: true,
inside: {
'punctuation': /[<>]/
define(["prism/prism","prism/components/prism-javascript"], function () {
-Prism.languages.typescript = Prism.languages.extend('javascript', {
- // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
- 'keyword': /\b(?:abstract|as|async|await|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|null|of|package|private|protected|public|readonly|return|require|set|static|super|switch|this|throw|try|type|typeof|undefined|var|void|while|with|yield)\b/,
- 'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console|Promise|unknown|never)\b/,
-});
+(function (Prism) {
-Prism.languages.ts = Prism.languages.typescript;
+ Prism.languages.typescript = Prism.languages.extend('javascript', {
+ 'class-name': {
+ pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
+ lookbehind: true,
+ greedy: true,
+ inside: null // see below
+ },
+ // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
+ 'keyword': /\b(?:abstract|as|asserts|async|await|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|null|of|package|private|protected|public|readonly|return|require|set|static|super|switch|this|throw|try|type|typeof|undefined|var|void|while|with|yield)\b/,
+ 'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console|Promise|unknown|never)\b/,
+ });
+
+ // doesn't work with TS because TS is too complex
+ delete Prism.languages.typescript['parameter'];
+
+ // a version of typescript specifically for highlighting types
+ var typeInside = Prism.languages.extend('typescript', {});
+ delete typeInside['class-name'];
+
+ Prism.languages.typescript['class-name'].inside = typeInside;
+
+ Prism.languages.insertBefore('typescript', 'function', {
+ 'generic-function': {
+ // e.g. foo<T extends "bar" | "baz">( ...
+ pattern: /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
+ greedy: true,
+ inside: {
+ 'function': /^#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*/,
+ 'generic': {
+ pattern: /<[\s\S]+/, // everything after the first <
+ alias: 'class-name',
+ inside: typeInside
+ }
+ }
+ }
+ });
+
+ Prism.languages.ts = Prism.languages.typescript;
+
+}(Prism));
return Prism; })
\ No newline at end of file
--- /dev/null
+define(["prism/prism"], function () {
+Prism.languages.unrealscript = {
+ 'comment': /\/\/.*|\/\*[\s\S]*?\*\//,
+ 'string': {
+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
+ greedy: true
+ },
+ 'category': {
+ pattern: /(\b(?:(?:autoexpand|hide|show)categories|var)\s*\()[^()]+(?=\))/,
+ lookbehind: true,
+ greedy: true,
+ alias: 'property'
+ },
+ 'metadata': {
+ pattern: /(\w\s*)<\s*\w+\s*=[^<>|=\r\n]+(?:\|\s*\w+\s*=[^<>|=\r\n]+)*>/,
+ lookbehind: true,
+ greedy: true,
+ inside: {
+ 'property': /\w+(?=\s*=)/,
+ 'operator': /=/,
+ 'punctuation': /[<>|]/
+ }
+ },
+ 'macro': {
+ pattern: /`\w+/,
+ alias: 'property'
+ },
+ 'class-name': {
+ pattern: /(\b(?:class|enum|extends|interface|state(?:\(\))?|struct|within)\s+)\w+/,
+ lookbehind: true
+ },
+
+ 'keyword': /\b(?:abstract|actor|array|auto|autoexpandcategories|bool|break|byte|case|class|classgroup|client|coerce|collapsecategories|config|const|continue|default|defaultproperties|delegate|dependson|deprecated|do|dontcollapsecategories|editconst|editinlinenew|else|enum|event|exec|export|extends|final|float|for|forcescriptorder|foreach|function|goto|guid|hidecategories|hidedropdown|if|ignores|implements|inherits|input|int|interface|iterator|latent|local|material|name|native|nativereplication|noexport|nontransient|noteditinlinenew|notplaceable|operator|optional|out|pawn|perobjectconfig|perobjectlocalized|placeable|postoperator|preoperator|private|protected|reliable|replication|return|server|showcategories|simulated|singular|state|static|string|struct|structdefault|structdefaultproperties|switch|texture|transient|travel|unreliable|until|var|vector|while|within)\b/,
+ 'function': /[a-z_]\w*(?=\s*\()/i,
+
+ 'boolean': /\b(?:false|true)\b/,
+ 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
+ // https://docs.unrealengine.com/udk/Three/UnrealScriptExpressions.html
+ 'operator': />>|<<|--|\+\+|\*\*|[-+*/~!=<>$@]=?|&&?|\|\|?|\^\^?|[?:%]|\b(?:Cross|Dot|ClockwiseFrom)\b/,
+ 'punctuation': /[()[\]{};,.]/
+};
+
+Prism.languages.uc = Prism.languages.uscript = Prism.languages.unrealscript;
+
+return Prism; })
\ No newline at end of file
greedy: true
},
'date': {
- pattern: /#[^\S\r\n]*(?:\d+([/-])\d+\1\d+(?:[^\S\r\n]+(?:\d+[^\S\r\n]*(?:AM|PM)|\d+:\d+(?::\d+)?(?:[^\S\r\n]*(?:AM|PM))?))?|(?:\d+[^\S\r\n]*(?:AM|PM)|\d+:\d+(?::\d+)?(?:[^\S\r\n]*(?:AM|PM))?))[^\S\r\n]*#/i,
+ pattern: /#[^\S\r\n]*(?:\d+([/-])\d+\1\d+(?:[^\S\r\n]+(?:\d+[^\S\r\n]*(?:AM|PM)|\d+:\d+(?::\d+)?(?:[^\S\r\n]*(?:AM|PM))?))?|\d+[^\S\r\n]*(?:AM|PM)|\d+:\d+(?::\d+)?(?:[^\S\r\n]*(?:AM|PM))?)[^\S\r\n]*#/i,
alias: 'builtin'
},
'number': /(?:(?:\b\d+(?:\.\d+)?|\.\d+)(?:E[+-]?\d+)?|&[HO][\dA-F]+)(?:U?[ILS]|[FRD])?/i,
'boolean': /\b(?:True|False|Nothing)\b/i,
- 'keyword': /\b(?:AddHandler|AddressOf|Alias|And(?:Also)?|As|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|C(?:Bool|Byte|Char|Date|Dbl|Dec|Int|Lng|Obj|SByte|Short|Sng|Str|Type|UInt|ULng|UShort)|Char|Class|Const|Continue|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else(?:If)?|End(?:If)?|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get(?:Type|XMLNamespace)?|Global|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|IsNot|Let|Lib|Like|Long|Loop|Me|Mod|Module|Must(?:Inherit|Override)|My(?:Base|Class)|Namespace|Narrowing|New|Next|Not(?:Inheritable|Overridable)?|Object|Of|On|Operator|Option(?:al)?|Or(?:Else)?|Out|Overloads|Overridable|Overrides|ParamArray|Partial|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|SByte|Select|Set|Shadows|Shared|short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TryCast|TypeOf|U(?:Integer|Long|Short)|Using|Variant|Wend|When|While|Widening|With(?:Events)?|WriteOnly|Xor)\b/i,
+ 'keyword': /\b(?:AddHandler|AddressOf|Alias|And(?:Also)?|As|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|C(?:Bool|Byte|Char|Date|Dbl|Dec|Int|Lng|Obj|SByte|Short|Sng|Str|Type|UInt|ULng|UShort)|Char|Class|Const|Continue|Currency|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else(?:If)?|End(?:If)?|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get(?:Type|XMLNamespace)?|Global|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|IsNot|Let|Lib|Like|Long|Loop|Me|Mod|Module|Must(?:Inherit|Override)|My(?:Base|Class)|Namespace|Narrowing|New|Next|Not(?:Inheritable|Overridable)?|Object|Of|On|Operator|Option(?:al)?|Or(?:Else)?|Out|Overloads|Overridable|Overrides|ParamArray|Partial|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|SByte|Select|Set|Shadows|Shared|short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TryCast|Type|TypeOf|U(?:Integer|Long|Short)|Using|Variant|Wend|When|While|Widening|With(?:Events)?|WriteOnly|Until|Xor)\b/i,
'operator': [
/[+\-*/\\^<=>&#@$%!]/,
{
};
Prism.languages.vb = Prism.languages['visual-basic'];
+Prism.languages.vba = Prism.languages['visual-basic'];
return Prism; })
\ No newline at end of file
--- /dev/null
+define(["prism/prism"], function () {
+Prism.languages.warpscript = {
+ 'comment': /#.*|\/\/.*|\/\*[\s\S]*?\*\//,
+ 'string': {
+ pattern: /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'|<'(?:[^\\']|'(?!>)|\\.)*'>/,
+ greedy: true
+ },
+ 'variable': /\$\S+/,
+ 'macro': {
+ pattern: /@\S+/,
+ alias: 'property'
+ },
+ // WarpScript doesn't have any keywords, these are all functions under the control category
+ // https://www.warp10.io/tags/control
+ 'keyword': /\b(?:BREAK|CHECKMACRO|CONTINUE|CUDF|DEFINED|DEFINEDMACRO|EVAL|FAIL|FOR|FOREACH|FORSTEP|IFT|IFTE|MSGFAIL|NRETURN|RETHROW|RETURN|SWITCH|TRY|UDF|UNTIL|WHILE)\b/,
+ 'number': /[+-]?\b(?:NaN|Infinity|\d+(?:\.\d*)?(?:[Ee][+-]?\d+)?|0x[\da-fA-F]+|0b[01]+)\b/,
+ 'boolean': /\b(?:false|true|F|T)\b/,
+ 'punctuation': /<%|%>|[{}[\]()]/,
+ // Some operators from the "operators" category
+ // https://www.warp10.io/tags/operators
+ 'operator': /==|&&?|\|\|?|\*\*?|>>>?|<<|==|[<>!~]=?|[-/%^]|\+!?|\b(?:AND|NOT|OR)\b/
+};
+
+return Prism; })
\ No newline at end of file
--- /dev/null
+define(["prism/prism","prism/components/prism-markup"], function () {
+(function (Prism) {
+
+ /**
+ * If the given language is present, it will insert the given doc comment grammar token into it.
+ *
+ * @param {string} lang
+ * @param {any} docComment
+ */
+ function insertDocComment(lang, docComment) {
+ if (Prism.languages[lang]) {
+ Prism.languages.insertBefore(lang, 'comment', {
+ 'doc-comment': docComment
+ });
+ }
+ }
+
+ var tag = Prism.languages.markup.tag;
+
+ var slashDocComment = {
+ pattern: /\/\/\/.*/,
+ greedy: true,
+ alias: 'comment',
+ inside: {
+ 'tag': tag
+ }
+ };
+ var tickDocComment = {
+ pattern: /'''.*/,
+ greedy: true,
+ alias: 'comment',
+ inside: {
+ 'tag': tag
+ }
+ };
+
+ insertDocComment('csharp', slashDocComment);
+ insertDocComment('fsharp', slashDocComment);
+ insertDocComment('vbnet', tickDocComment);
+
+}(Prism));
+
+return Prism; })
\ No newline at end of file
'punctuation': /[[\](){},;:/]/
});
- Prism.languages.xquery.tag.pattern = /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|{(?!{)(?:{(?:{[^}]*}|[^}])*}|[^}])+}|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i;
- Prism.languages.xquery['tag'].inside['attr-value'].pattern = /=(?:("|')(?:\\[\s\S]|{(?!{)(?:{(?:{[^}]*}|[^}])*}|[^}])+}|(?!\1)[^\\])*\1|[^\s'">=]+)/i;
+ Prism.languages.xquery.tag.pattern = /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|{(?!{)(?:{(?:{[^{}]*}|[^{}])*}|[^{}])+}|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i;
+ Prism.languages.xquery['tag'].inside['attr-value'].pattern = /=(?:("|')(?:\\[\s\S]|{(?!{)(?:{(?:{[^{}]*}|[^{}])*}|[^{}])+}|(?!\1)[^\\])*\1|[^\s'">=]+)/i;
Prism.languages.xquery['tag'].inside['attr-value'].inside['punctuation'] = /^="|"$/;
Prism.languages.xquery['tag'].inside['attr-value'].inside['expression'] = {
// Allow for two levels of nesting
- pattern: /{(?!{)(?:{(?:{[^}]*}|[^}])*}|[^}])+}/,
+ pattern: /{(?!{)(?:{(?:{[^{}]*}|[^{}])*}|[^{}])+}/,
inside: Prism.languages.xquery,
alias: 'language-xquery'
};
--- /dev/null
+define(["prism/prism"], function () {
+Prism.languages.yang = {
+ // https://tools.ietf.org/html/rfc6020#page-34
+ // http://www.yang-central.org/twiki/bin/view/Main/YangExamples
+ 'comment': /\/\*[\s\S]*?\*\/|\/\/.*/,
+ 'string': {
+ pattern: /"(?:[^\\"]|\\.)*"|'[^']*'/,
+ greedy: true
+ },
+ 'keyword': {
+ pattern: /(^|[{};\r\n][ \t]*)[a-z_][\w.-]*/i,
+ lookbehind: true
+ },
+ 'namespace': {
+ pattern: /(\s)[a-z_][\w.-]*(?=:)/i,
+ lookbehind: true
+ },
+ 'boolean': /\b(?:false|true)\b/,
+ 'operator': /\+/,
+ 'punctuation': /[{};:]/
+};
+
+return Prism; })
\ No newline at end of file
-define([],function(){return /*START*/{"markup":{"title":"Markup","file":"markup"},"html":{"title":"HTML","file":"markup"},"xml":{"title":"XML","file":"markup"},"svg":{"title":"SVG","file":"markup"},"mathml":{"title":"MathML","file":"markup"},"css":{"title":"CSS","file":"css"},"clike":{"title":"C-like","file":"clike"},"javascript":{"title":"JavaScript","file":"javascript"},"abap":{"title":"ABAP","file":"abap"},"abnf":{"title":"Augmented Backus–Naur form","file":"abnf"},"actionscript":{"title":"ActionScript","file":"actionscript"},"ada":{"title":"Ada","file":"ada"},"antlr4":{"title":"ANTLR4","file":"antlr4"},"apacheconf":{"title":"Apache Configuration","file":"apacheconf"},"apl":{"title":"APL","file":"apl"},"applescript":{"title":"AppleScript","file":"applescript"},"aql":{"title":"AQL","file":"aql"},"arduino":{"title":"Arduino","file":"arduino"},"arff":{"title":"ARFF","file":"arff"},"asciidoc":{"title":"AsciiDoc","file":"asciidoc"},"asm6502":{"title":"6502 Assembly","file":"asm6502"},"aspnet":{"title":"ASP.NET (C#)","file":"aspnet"},"autohotkey":{"title":"AutoHotkey","file":"autohotkey"},"autoit":{"title":"AutoIt","file":"autoit"},"bash":{"title":"Bash","file":"bash"},"basic":{"title":"BASIC","file":"basic"},"batch":{"title":"Batch","file":"batch"},"bbcode":{"title":"BBcode","file":"bbcode"},"bison":{"title":"Bison","file":"bison"},"bnf":{"title":"Backus–Naur form","file":"bnf"},"brainfuck":{"title":"Brainfuck","file":"brainfuck"},"brightscript":{"title":"BrightScript","file":"brightscript"},"bro":{"title":"Bro","file":"bro"},"c":{"title":"C","file":"c"},"concurnas":{"title":"Concurnas","file":"concurnas"},"csharp":{"title":"C#","file":"csharp"},"cpp":{"title":"C++","file":"cpp"},"cil":{"title":"CIL","file":"cil"},"coffeescript":{"title":"CoffeeScript","file":"coffeescript"},"cmake":{"title":"CMake","file":"cmake"},"clojure":{"title":"Clojure","file":"clojure"},"crystal":{"title":"Crystal","file":"crystal"},"csp":{"title":"Content-Security-Policy","file":"csp"},"css-extras":{"title":"CSS Extras","file":"css-extras"},"d":{"title":"D","file":"d"},"dart":{"title":"Dart","file":"dart"},"dax":{"title":"DAX","file":"dax"},"diff":{"title":"Diff","file":"diff"},"django":{"title":"Django/Jinja2","file":"django"},"dns-zone-file":{"title":"DNS zone file","file":"dns-zone-file"},"docker":{"title":"Docker","file":"docker"},"ebnf":{"title":"Extended Backus–Naur form","file":"ebnf"},"eiffel":{"title":"Eiffel","file":"eiffel"},"ejs":{"title":"EJS","file":"ejs"},"elixir":{"title":"Elixir","file":"elixir"},"elm":{"title":"Elm","file":"elm"},"etlua":{"title":"Embedded Lua templating","file":"etlua"},"erb":{"title":"ERB","file":"erb"},"erlang":{"title":"Erlang","file":"erlang"},"excel-formula":{"title":"Excel Formula","file":"excel-formula"},"fsharp":{"title":"F#","file":"fsharp"},"factor":{"title":"Factor","file":"factor"},"firestore-security-rules":{"title":"Firestore security rules","file":"firestore-security-rules"},"flow":{"title":"Flow","file":"flow"},"fortran":{"title":"Fortran","file":"fortran"},"ftl":{"title":"FreeMarker Template Language","file":"ftl"},"gcode":{"title":"G-code","file":"gcode"},"gdscript":{"title":"GDScript","file":"gdscript"},"gedcom":{"title":"GEDCOM","file":"gedcom"},"gherkin":{"title":"Gherkin","file":"gherkin"},"git":{"title":"Git","file":"git"},"glsl":{"title":"GLSL","file":"glsl"},"gml":{"title":"GameMaker Language","file":"gml"},"go":{"title":"Go","file":"go"},"graphql":{"title":"GraphQL","file":"graphql"},"groovy":{"title":"Groovy","file":"groovy"},"haml":{"title":"Haml","file":"haml"},"handlebars":{"title":"Handlebars","file":"handlebars"},"haskell":{"title":"Haskell","file":"haskell"},"haxe":{"title":"Haxe","file":"haxe"},"hcl":{"title":"HCL","file":"hcl"},"http":{"title":"HTTP","file":"http"},"hpkp":{"title":"HTTP Public-Key-Pins","file":"hpkp"},"hsts":{"title":"HTTP Strict-Transport-Security","file":"hsts"},"ichigojam":{"title":"IchigoJam","file":"ichigojam"},"icon":{"title":"Icon","file":"icon"},"inform7":{"title":"Inform 7","file":"inform7"},"ini":{"title":"Ini","file":"ini"},"io":{"title":"Io","file":"io"},"j":{"title":"J","file":"j"},"java":{"title":"Java","file":"java"},"javadoc":{"title":"JavaDoc","file":"javadoc"},"javadoclike":{"title":"JavaDoc-like","file":"javadoclike"},"javastacktrace":{"title":"Java stack trace","file":"javastacktrace"},"jolie":{"title":"Jolie","file":"jolie"},"jq":{"title":"JQ","file":"jq"},"jsdoc":{"title":"JSDoc","file":"jsdoc"},"js-extras":{"title":"JS Extras","file":"js-extras"},"js-templates":{"title":"JS Templates","file":"js-templates"},"json":{"title":"JSON","file":"json"},"jsonp":{"title":"JSONP","file":"jsonp"},"json5":{"title":"JSON5","file":"json5"},"julia":{"title":"Julia","file":"julia"},"keyman":{"title":"Keyman","file":"keyman"},"kotlin":{"title":"Kotlin","file":"kotlin"},"latex":{"title":"LaTeX","file":"latex"},"tex":{"title":"TeX","file":"latex"},"context":{"title":"ConTeXt","file":"latex"},"latte":{"title":"Latte","file":"latte"},"less":{"title":"Less","file":"less"},"lilypond":{"title":"LilyPond","file":"lilypond"},"liquid":{"title":"Liquid","file":"liquid"},"lisp":{"title":"Lisp","file":"lisp"},"livescript":{"title":"LiveScript","file":"livescript"},"llvm":{"title":"LLVM IR","file":"llvm"},"lolcode":{"title":"LOLCODE","file":"lolcode"},"lua":{"title":"Lua","file":"lua"},"makefile":{"title":"Makefile","file":"makefile"},"markdown":{"title":"Markdown","file":"markdown"},"markup-templating":{"title":"Markup templating","file":"markup-templating"},"matlab":{"title":"MATLAB","file":"matlab"},"mel":{"title":"MEL","file":"mel"},"mizar":{"title":"Mizar","file":"mizar"},"monkey":{"title":"Monkey","file":"monkey"},"moonscript":{"title":"MoonScript","file":"moonscript"},"n1ql":{"title":"N1QL","file":"n1ql"},"n4js":{"title":"N4JS","file":"n4js"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","file":"nand2tetris-hdl"},"nasm":{"title":"NASM","file":"nasm"},"neon":{"title":"NEON","file":"neon"},"nginx":{"title":"nginx","file":"nginx"},"nim":{"title":"Nim","file":"nim"},"nix":{"title":"Nix","file":"nix"},"nsis":{"title":"NSIS","file":"nsis"},"objectivec":{"title":"Objective-C","file":"objectivec"},"ocaml":{"title":"OCaml","file":"ocaml"},"opencl":{"title":"OpenCL","file":"opencl"},"oz":{"title":"Oz","file":"oz"},"parigp":{"title":"PARI/GP","file":"parigp"},"parser":{"title":"Parser","file":"parser"},"pascal":{"title":"Pascal","file":"pascal"},"pascaligo":{"title":"Pascaligo","file":"pascaligo"},"pcaxis":{"title":"PC-Axis","file":"pcaxis"},"perl":{"title":"Perl","file":"perl"},"php":{"title":"PHP","file":"php"},"phpdoc":{"title":"PHPDoc","file":"phpdoc"},"php-extras":{"title":"PHP Extras","file":"php-extras"},"plsql":{"title":"PL/SQL","file":"plsql"},"powerquery":{"title":"PowerQuery","file":"powerquery"},"powershell":{"title":"PowerShell","file":"powershell"},"processing":{"title":"Processing","file":"processing"},"prolog":{"title":"Prolog","file":"prolog"},"properties":{"title":".properties","file":"properties"},"protobuf":{"title":"Protocol Buffers","file":"protobuf"},"pug":{"title":"Pug","file":"pug"},"puppet":{"title":"Puppet","file":"puppet"},"pure":{"title":"Pure","file":"pure"},"python":{"title":"Python","file":"python"},"q":{"title":"Q (kdb+ database)","file":"q"},"qml":{"title":"QML","file":"qml"},"qore":{"title":"Qore","file":"qore"},"r":{"title":"R","file":"r"},"jsx":{"title":"React JSX","file":"jsx"},"tsx":{"title":"React TSX","file":"tsx"},"renpy":{"title":"Ren'py","file":"renpy"},"reason":{"title":"Reason","file":"reason"},"regex":{"title":"Regex","file":"regex"},"rest":{"title":"reST (reStructuredText)","file":"rest"},"rip":{"title":"Rip","file":"rip"},"roboconf":{"title":"Roboconf","file":"roboconf"},"robotframework":{"title":"Robot Framework","file":"robotframework"},"ruby":{"title":"Ruby","file":"ruby"},"rust":{"title":"Rust","file":"rust"},"sas":{"title":"SAS","file":"sas"},"sass":{"title":"Sass (Sass)","file":"sass"},"scss":{"title":"Sass (Scss)","file":"scss"},"scala":{"title":"Scala","file":"scala"},"scheme":{"title":"Scheme","file":"scheme"},"shell-session":{"title":"Shell session","file":"shell-session"},"smalltalk":{"title":"Smalltalk","file":"smalltalk"},"smarty":{"title":"Smarty","file":"smarty"},"solidity":{"title":"Solidity (Ethereum)","file":"solidity"},"solution-file":{"title":"Solution file","file":"solution-file"},"soy":{"title":"Soy (Closure Template)","file":"soy"},"sparql":{"title":"SPARQL","file":"sparql"},"splunk-spl":{"title":"Splunk SPL","file":"splunk-spl"},"sqf":{"title":"SQF: Status Quo Function (Arma 3)","file":"sqf"},"sql":{"title":"SQL","file":"sql"},"stylus":{"title":"Stylus","file":"stylus"},"swift":{"title":"Swift","file":"swift"},"tap":{"title":"TAP","file":"tap"},"tcl":{"title":"Tcl","file":"tcl"},"textile":{"title":"Textile","file":"textile"},"toml":{"title":"TOML","file":"toml"},"tt2":{"title":"Template Toolkit 2","file":"tt2"},"turtle":{"title":"Turtle","file":"turtle"},"twig":{"title":"Twig","file":"twig"},"typescript":{"title":"TypeScript","file":"typescript"},"t4-cs":{"title":"T4 Text Templates (C#)","file":"t4-cs"},"t4-vb":{"title":"T4 Text Templates (VB)","file":"t4-vb"},"t4-templating":{"title":"T4 templating","file":"t4-templating"},"vala":{"title":"Vala","file":"vala"},"vbnet":{"title":"VB.Net","file":"vbnet"},"velocity":{"title":"Velocity","file":"velocity"},"verilog":{"title":"Verilog","file":"verilog"},"vhdl":{"title":"VHDL","file":"vhdl"},"vim":{"title":"vim","file":"vim"},"visual-basic":{"title":"Visual Basic","file":"visual-basic"},"wasm":{"title":"WebAssembly","file":"wasm"},"wiki":{"title":"Wiki markup","file":"wiki"},"xeora":{"title":"Xeora","file":"xeora"},"xojo":{"title":"Xojo (REALbasic)","file":"xojo"},"xquery":{"title":"XQuery","file":"xquery"},"yaml":{"title":"YAML","file":"yaml"},"zig":{"title":"Zig","file":"zig"}}/*END*/;});
\ No newline at end of file
+define([],function(){return /*START*/{"markup":{"title":"Markup","file":"markup"},"html":{"title":"HTML","file":"markup"},"xml":{"title":"XML","file":"markup"},"svg":{"title":"SVG","file":"markup"},"mathml":{"title":"MathML","file":"markup"},"ssml":{"title":"SSML","file":"markup"},"atom":{"title":"Atom","file":"markup"},"rss":{"title":"RSS","file":"markup"},"css":{"title":"CSS","file":"css"},"clike":{"title":"C-like","file":"clike"},"javascript":{"title":"JavaScript","file":"javascript"},"abap":{"title":"ABAP","file":"abap"},"abnf":{"title":"ABNF","file":"abnf"},"actionscript":{"title":"ActionScript","file":"actionscript"},"ada":{"title":"Ada","file":"ada"},"agda":{"title":"Agda","file":"agda"},"al":{"title":"AL","file":"al"},"antlr4":{"title":"ANTLR4","file":"antlr4"},"apacheconf":{"title":"Apache Configuration","file":"apacheconf"},"apl":{"title":"APL","file":"apl"},"applescript":{"title":"AppleScript","file":"applescript"},"aql":{"title":"AQL","file":"aql"},"arduino":{"title":"Arduino","file":"arduino"},"arff":{"title":"ARFF","file":"arff"},"asciidoc":{"title":"AsciiDoc","file":"asciidoc"},"aspnet":{"title":"ASP.NET (C#)","file":"aspnet"},"asm6502":{"title":"6502 Assembly","file":"asm6502"},"autohotkey":{"title":"AutoHotkey","file":"autohotkey"},"autoit":{"title":"AutoIt","file":"autoit"},"bash":{"title":"Bash","file":"bash"},"basic":{"title":"BASIC","file":"basic"},"batch":{"title":"Batch","file":"batch"},"bbcode":{"title":"BBcode","file":"bbcode"},"bison":{"title":"Bison","file":"bison"},"bnf":{"title":"BNF","file":"bnf"},"brainfuck":{"title":"Brainfuck","file":"brainfuck"},"brightscript":{"title":"BrightScript","file":"brightscript"},"bro":{"title":"Bro","file":"bro"},"c":{"title":"C","file":"c"},"csharp":{"title":"C#","file":"csharp"},"cpp":{"title":"C++","file":"cpp"},"cil":{"title":"CIL","file":"cil"},"clojure":{"title":"Clojure","file":"clojure"},"cmake":{"title":"CMake","file":"cmake"},"coffeescript":{"title":"CoffeeScript","file":"coffeescript"},"concurnas":{"title":"Concurnas","file":"concurnas"},"csp":{"title":"Content-Security-Policy","file":"csp"},"crystal":{"title":"Crystal","file":"crystal"},"css-extras":{"title":"CSS Extras","file":"css-extras"},"cypher":{"title":"Cypher","file":"cypher"},"d":{"title":"D","file":"d"},"dart":{"title":"Dart","file":"dart"},"dax":{"title":"DAX","file":"dax"},"dhall":{"title":"Dhall","file":"dhall"},"diff":{"title":"Diff","file":"diff"},"django":{"title":"Django/Jinja2","file":"django"},"dns-zone-file":{"title":"DNS zone file","file":"dns-zone-file"},"docker":{"title":"Docker","file":"docker"},"ebnf":{"title":"EBNF","file":"ebnf"},"editorconfig":{"title":"EditorConfig","file":"editorconfig"},"eiffel":{"title":"Eiffel","file":"eiffel"},"ejs":{"title":"EJS","file":"ejs"},"elixir":{"title":"Elixir","file":"elixir"},"elm":{"title":"Elm","file":"elm"},"etlua":{"title":"Embedded Lua templating","file":"etlua"},"erb":{"title":"ERB","file":"erb"},"erlang":{"title":"Erlang","file":"erlang"},"excel-formula":{"title":"Excel Formula","file":"excel-formula"},"fsharp":{"title":"F#","file":"fsharp"},"factor":{"title":"Factor","file":"factor"},"firestore-security-rules":{"title":"Firestore security rules","file":"firestore-security-rules"},"flow":{"title":"Flow","file":"flow"},"fortran":{"title":"Fortran","file":"fortran"},"ftl":{"title":"FreeMarker Template Language","file":"ftl"},"gml":{"title":"GameMaker Language","file":"gml"},"gcode":{"title":"G-code","file":"gcode"},"gdscript":{"title":"GDScript","file":"gdscript"},"gedcom":{"title":"GEDCOM","file":"gedcom"},"gherkin":{"title":"Gherkin","file":"gherkin"},"git":{"title":"Git","file":"git"},"glsl":{"title":"GLSL","file":"glsl"},"go":{"title":"Go","file":"go"},"graphql":{"title":"GraphQL","file":"graphql"},"groovy":{"title":"Groovy","file":"groovy"},"haml":{"title":"Haml","file":"haml"},"handlebars":{"title":"Handlebars","file":"handlebars"},"haskell":{"title":"Haskell","file":"haskell"},"haxe":{"title":"Haxe","file":"haxe"},"hcl":{"title":"HCL","file":"hcl"},"hlsl":{"title":"HLSL","file":"hlsl"},"http":{"title":"HTTP","file":"http"},"hpkp":{"title":"HTTP Public-Key-Pins","file":"hpkp"},"hsts":{"title":"HTTP Strict-Transport-Security","file":"hsts"},"ichigojam":{"title":"IchigoJam","file":"ichigojam"},"icon":{"title":"Icon","file":"icon"},"ignore":{"title":".ignore","file":"ignore"},"gitignore":{"title":".gitignore","file":"ignore"},"hgignore":{"title":".hgignore","file":"ignore"},"npmignore":{"title":".npmignore","file":"ignore"},"inform7":{"title":"Inform 7","file":"inform7"},"ini":{"title":"Ini","file":"ini"},"io":{"title":"Io","file":"io"},"j":{"title":"J","file":"j"},"java":{"title":"Java","file":"java"},"javadoc":{"title":"JavaDoc","file":"javadoc"},"javadoclike":{"title":"JavaDoc-like","file":"javadoclike"},"javastacktrace":{"title":"Java stack trace","file":"javastacktrace"},"jolie":{"title":"Jolie","file":"jolie"},"jq":{"title":"JQ","file":"jq"},"jsdoc":{"title":"JSDoc","file":"jsdoc"},"js-extras":{"title":"JS Extras","file":"js-extras"},"json":{"title":"JSON","file":"json"},"json5":{"title":"JSON5","file":"json5"},"jsonp":{"title":"JSONP","file":"jsonp"},"jsstacktrace":{"title":"JS stack trace","file":"jsstacktrace"},"js-templates":{"title":"JS Templates","file":"js-templates"},"julia":{"title":"Julia","file":"julia"},"keyman":{"title":"Keyman","file":"keyman"},"kotlin":{"title":"Kotlin","file":"kotlin"},"kts":{"title":"Kotlin Script","file":"kotlin"},"latex":{"title":"LaTeX","file":"latex"},"tex":{"title":"TeX","file":"latex"},"context":{"title":"ConTeXt","file":"latex"},"latte":{"title":"Latte","file":"latte"},"less":{"title":"Less","file":"less"},"lilypond":{"title":"LilyPond","file":"lilypond"},"liquid":{"title":"Liquid","file":"liquid"},"lisp":{"title":"Lisp","file":"lisp"},"livescript":{"title":"LiveScript","file":"livescript"},"llvm":{"title":"LLVM IR","file":"llvm"},"lolcode":{"title":"LOLCODE","file":"lolcode"},"lua":{"title":"Lua","file":"lua"},"makefile":{"title":"Makefile","file":"makefile"},"markdown":{"title":"Markdown","file":"markdown"},"markup-templating":{"title":"Markup templating","file":"markup-templating"},"matlab":{"title":"MATLAB","file":"matlab"},"mel":{"title":"MEL","file":"mel"},"mizar":{"title":"Mizar","file":"mizar"},"monkey":{"title":"Monkey","file":"monkey"},"moonscript":{"title":"MoonScript","file":"moonscript"},"n1ql":{"title":"N1QL","file":"n1ql"},"n4js":{"title":"N4JS","file":"n4js"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","file":"nand2tetris-hdl"},"nasm":{"title":"NASM","file":"nasm"},"neon":{"title":"NEON","file":"neon"},"nginx":{"title":"nginx","file":"nginx"},"nim":{"title":"Nim","file":"nim"},"nix":{"title":"Nix","file":"nix"},"nsis":{"title":"NSIS","file":"nsis"},"objectivec":{"title":"Objective-C","file":"objectivec"},"ocaml":{"title":"OCaml","file":"ocaml"},"opencl":{"title":"OpenCL","file":"opencl"},"oz":{"title":"Oz","file":"oz"},"parigp":{"title":"PARI/GP","file":"parigp"},"parser":{"title":"Parser","file":"parser"},"pascal":{"title":"Pascal","file":"pascal"},"pascaligo":{"title":"Pascaligo","file":"pascaligo"},"pcaxis":{"title":"PC-Axis","file":"pcaxis"},"peoplecode":{"title":"PeopleCode","file":"peoplecode"},"perl":{"title":"Perl","file":"perl"},"php":{"title":"PHP","file":"php"},"phpdoc":{"title":"PHPDoc","file":"phpdoc"},"php-extras":{"title":"PHP Extras","file":"php-extras"},"plsql":{"title":"PL/SQL","file":"plsql"},"powerquery":{"title":"PowerQuery","file":"powerquery"},"powershell":{"title":"PowerShell","file":"powershell"},"processing":{"title":"Processing","file":"processing"},"prolog":{"title":"Prolog","file":"prolog"},"properties":{"title":".properties","file":"properties"},"protobuf":{"title":"Protocol Buffers","file":"protobuf"},"pug":{"title":"Pug","file":"pug"},"puppet":{"title":"Puppet","file":"puppet"},"pure":{"title":"Pure","file":"pure"},"purebasic":{"title":"PureBasic","file":"purebasic"},"python":{"title":"Python","file":"python"},"q":{"title":"Q (kdb+ database)","file":"q"},"qml":{"title":"QML","file":"qml"},"qore":{"title":"Qore","file":"qore"},"r":{"title":"R","file":"r"},"racket":{"title":"Racket","file":"racket"},"jsx":{"title":"React JSX","file":"jsx"},"tsx":{"title":"React TSX","file":"tsx"},"reason":{"title":"Reason","file":"reason"},"regex":{"title":"Regex","file":"regex"},"renpy":{"title":"Ren'py","file":"renpy"},"rest":{"title":"reST (reStructuredText)","file":"rest"},"rip":{"title":"Rip","file":"rip"},"roboconf":{"title":"Roboconf","file":"roboconf"},"robotframework":{"title":"Robot Framework","file":"robotframework"},"ruby":{"title":"Ruby","file":"ruby"},"rust":{"title":"Rust","file":"rust"},"sas":{"title":"SAS","file":"sas"},"sass":{"title":"Sass (Sass)","file":"sass"},"scss":{"title":"Sass (Scss)","file":"scss"},"scala":{"title":"Scala","file":"scala"},"scheme":{"title":"Scheme","file":"scheme"},"shell-session":{"title":"Shell session","file":"shell-session"},"smali":{"title":"Smali","file":"smali"},"smalltalk":{"title":"Smalltalk","file":"smalltalk"},"smarty":{"title":"Smarty","file":"smarty"},"solidity":{"title":"Solidity (Ethereum)","file":"solidity"},"solution-file":{"title":"Solution file","file":"solution-file"},"soy":{"title":"Soy (Closure Template)","file":"soy"},"sparql":{"title":"SPARQL","file":"sparql"},"splunk-spl":{"title":"Splunk SPL","file":"splunk-spl"},"sqf":{"title":"SQF: Status Quo Function (Arma 3)","file":"sqf"},"sql":{"title":"SQL","file":"sql"},"iecst":{"title":"Structured Text (IEC 61131-3)","file":"iecst"},"stylus":{"title":"Stylus","file":"stylus"},"swift":{"title":"Swift","file":"swift"},"t4-templating":{"title":"T4 templating","file":"t4-templating"},"t4-cs":{"title":"T4 Text Templates (C#)","file":"t4-cs"},"t4-vb":{"title":"T4 Text Templates (VB)","file":"t4-vb"},"tap":{"title":"TAP","file":"tap"},"tcl":{"title":"Tcl","file":"tcl"},"tt2":{"title":"Template Toolkit 2","file":"tt2"},"textile":{"title":"Textile","file":"textile"},"toml":{"title":"TOML","file":"toml"},"turtle":{"title":"Turtle","file":"turtle"},"twig":{"title":"Twig","file":"twig"},"typescript":{"title":"TypeScript","file":"typescript"},"unrealscript":{"title":"UnrealScript","file":"unrealscript"},"vala":{"title":"Vala","file":"vala"},"vbnet":{"title":"VB.Net","file":"vbnet"},"velocity":{"title":"Velocity","file":"velocity"},"verilog":{"title":"Verilog","file":"verilog"},"vhdl":{"title":"VHDL","file":"vhdl"},"vim":{"title":"vim","file":"vim"},"visual-basic":{"title":"Visual Basic","file":"visual-basic"},"vba":{"title":"VBA","file":"visual-basic"},"warpscript":{"title":"WarpScript","file":"warpscript"},"wasm":{"title":"WebAssembly","file":"wasm"},"wiki":{"title":"Wiki markup","file":"wiki"},"xeora":{"title":"Xeora","file":"xeora"},"xml-doc":{"title":"XML doc (.net)","file":"xml-doc"},"xojo":{"title":"Xojo (REALbasic)","file":"xojo"},"xquery":{"title":"XQuery","file":"xquery"},"yaml":{"title":"YAML","file":"yaml"},"yang":{"title":"YANG","file":"yang"},"zig":{"title":"Zig","file":"zig"}}/*END*/;});
\ No newline at end of file
Begin prism-core.js
********************************************** */
+/// <reference lib="WebWorker"/>
+
var _self = (typeof window !== 'undefined')
? window // if in browser
: (
/**
* Prism: Lightweight, robust, elegant syntax highlighting
- * MIT license http://www.opensource.org/licenses/mit-license.php/
- * @author Lea Verou http://lea.verou.me
+ *
+ * @license MIT <https://opensource.org/licenses/MIT>
+ * @author Lea Verou <https://lea.verou.me>
+ * @namespace
+ * @public
*/
-
var Prism = (function (_self){
// Private helper vars
var _ = {
+ /**
+ * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
+ * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
+ * additional languages or plugins yourself.
+ *
+ * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
+ *
+ * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
+ * empty Prism object into the global scope before loading the Prism script like this:
+ *
+ * ```js
+ * window.Prism = window.Prism || {};
+ * Prism.manual = true;
+ * // add a new <script> to load Prism's script
+ * ```
+ *
+ * @default false
+ * @type {boolean}
+ * @memberof Prism
+ * @public
+ */
manual: _self.Prism && _self.Prism.manual,
disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
+
+ /**
+ * A namespace for utility methods.
+ *
+ * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
+ * change or disappear at any time.
+ *
+ * @namespace
+ * @memberof Prism
+ */
util: {
encode: function encode(tokens) {
if (tokens instanceof Token) {
}
},
+ /**
+ * Returns the name of the type of the given value.
+ *
+ * @param {any} o
+ * @returns {string}
+ * @example
+ * type(null) === 'Null'
+ * type(undefined) === 'Undefined'
+ * type(123) === 'Number'
+ * type('foo') === 'String'
+ * type(true) === 'Boolean'
+ * type([1, 2]) === 'Array'
+ * type({}) === 'Object'
+ * type(String) === 'Function'
+ * type(/abc+/) === 'RegExp'
+ */
type: function (o) {
return Object.prototype.toString.call(o).slice(8, -1);
},
+ /**
+ * Returns a unique number for the given object. Later calls will still return the same number.
+ *
+ * @param {Object} obj
+ * @returns {number}
+ */
objId: function (obj) {
if (!obj['__id']) {
Object.defineProperty(obj, '__id', { value: ++uniqueId });
return obj['__id'];
},
- // Deep clone a language definition (e.g. to extend it)
+ /**
+ * Creates a deep clone of the given object.
+ *
+ * The main intended use of this function is to clone language definitions.
+ *
+ * @param {T} o
+ * @param {Record<number, any>} [visited]
+ * @returns {T}
+ * @template T
+ */
clone: function deepClone(o, visited) {
- var clone, id, type = _.util.type(o);
visited = visited || {};
- switch (type) {
+ var clone, id;
+ switch (_.util.type(o)) {
case 'Object':
id = _.util.objId(o);
if (visited[id]) {
return visited[id];
}
- clone = {};
+ clone = /** @type {Record<string, any>} */ ({});
visited[id] = clone;
for (var key in o) {
}
}
- return clone;
+ return /** @type {any} */ (clone);
case 'Array':
id = _.util.objId(o);
clone = [];
visited[id] = clone;
- o.forEach(function (v, i) {
+ (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
clone[i] = deepClone(v, visited);
});
- return clone;
+ return /** @type {any} */ (clone);
default:
return o;
if (typeof document === 'undefined') {
return null;
}
- if ('currentScript' in document) {
- return document.currentScript;
+ if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
+ return /** @type {any} */ (document.currentScript);
}
// IE11 workaround
}
return null;
}
+ },
+
+ /**
+ * Returns whether a given class is active for `element`.
+ *
+ * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
+ * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
+ * given class is just the given class with a `no-` prefix.
+ *
+ * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
+ * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
+ * ancestors have the given class or the negated version of it, then the default activation will be returned.
+ *
+ * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
+ * version of it, the class is considered active.
+ *
+ * @param {Element} element
+ * @param {string} className
+ * @param {boolean} [defaultActivation=false]
+ * @returns {boolean}
+ */
+ isActive: function (element, className, defaultActivation) {
+ var no = 'no-' + className;
+
+ while (element) {
+ var classList = element.classList;
+ if (classList.contains(className)) {
+ return true;
+ }
+ if (classList.contains(no)) {
+ return false;
+ }
+ element = element.parentElement;
+ }
+ return !!defaultActivation;
}
},
+ /**
+ * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
+ *
+ * @namespace
+ * @memberof Prism
+ * @public
+ */
languages: {
+ /**
+ * Creates a deep copy of the language with the given id and appends the given tokens.
+ *
+ * If a token in `redef` also appears in the copied language, then the existing token in the copied language
+ * will be overwritten at its original position.
+ *
+ * ## Best practices
+ *
+ * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
+ * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
+ * understand the language definition because, normally, the order of tokens matters in Prism grammars.
+ *
+ * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
+ * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
+ *
+ * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
+ * @param {Grammar} redef The new tokens to append.
+ * @returns {Grammar} The new language created.
+ * @public
+ * @example
+ * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
+ * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
+ * // at its original position
+ * 'comment': { ... },
+ * // CSS doesn't have a 'color' token, so this token will be appended
+ * 'color': /\b(?:red|green|blue)\b/
+ * });
+ */
extend: function (id, redef) {
var lang = _.util.clone(_.languages[id]);
},
/**
- * Insert a token before another token in a language literal
- * As this needs to recreate the object (we cannot actually insert before keys in object literals),
- * we cannot just provide an object, we need an object and a key.
- * @param inside The key (or language id) of the parent
- * @param before The key to insert before.
- * @param insert Object with the key/value pairs to insert
- * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
+ * Inserts tokens _before_ another token in a language definition or any other grammar.
+ *
+ * ## Usage
+ *
+ * This helper method makes it easy to modify existing languages. For example, the CSS language definition
+ * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
+ * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
+ * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
+ * this:
+ *
+ * ```js
+ * Prism.languages.markup.style = {
+ * // token
+ * };
+ * ```
+ *
+ * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
+ * before existing tokens. For the CSS example above, you would use it like this:
+ *
+ * ```js
+ * Prism.languages.insertBefore('markup', 'cdata', {
+ * 'style': {
+ * // token
+ * }
+ * });
+ * ```
+ *
+ * ## Special cases
+ *
+ * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
+ * will be ignored.
+ *
+ * This behavior can be used to insert tokens after `before`:
+ *
+ * ```js
+ * Prism.languages.insertBefore('markup', 'comment', {
+ * 'comment': Prism.languages.markup.comment,
+ * // tokens after 'comment'
+ * });
+ * ```
+ *
+ * ## Limitations
+ *
+ * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
+ * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
+ * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
+ * deleting properties which is necessary to insert at arbitrary positions.
+ *
+ * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
+ * Instead, it will create a new object and replace all references to the target object with the new one. This
+ * can be done without temporarily deleting properties, so the iteration order is well-defined.
+ *
+ * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
+ * you hold the target object in a variable, then the value of the variable will not change.
+ *
+ * ```js
+ * var oldMarkup = Prism.languages.markup;
+ * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
+ *
+ * assert(oldMarkup !== Prism.languages.markup);
+ * assert(newMarkup === Prism.languages.markup);
+ * ```
+ *
+ * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
+ * object to be modified.
+ * @param {string} before The key to insert before.
+ * @param {Grammar} insert An object containing the key-value pairs to be inserted.
+ * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
+ * object to be modified.
+ *
+ * Defaults to `Prism.languages`.
+ * @returns {Grammar} The new grammar object.
+ * @public
*/
insertBefore: function (inside, before, insert, root) {
- root = root || _.languages;
+ root = root || /** @type {any} */ (_.languages);
var grammar = root[inside];
+ /** @type {Grammar} */
var ret = {};
for (var token in grammar) {
}
}
},
+
plugins: {},
+ /**
+ * This is the most high-level function in Prism’s API.
+ * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
+ * each one of them.
+ *
+ * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
+ *
+ * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
+ * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
+ * @memberof Prism
+ * @public
+ */
highlightAll: function(async, callback) {
_.highlightAllUnder(document, async, callback);
},
+ /**
+ * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
+ * {@link Prism.highlightElement} on each one of them.
+ *
+ * The following hooks will be run:
+ * 1. `before-highlightall`
+ * 2. All hooks of {@link Prism.highlightElement} for each element.
+ *
+ * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
+ * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
+ * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
+ * @memberof Prism
+ * @public
+ */
highlightAllUnder: function(container, async, callback) {
var env = {
callback: callback,
}
},
+ /**
+ * Highlights the code inside a single element.
+ *
+ * The following hooks will be run:
+ * 1. `before-sanity-check`
+ * 2. `before-highlight`
+ * 3. All hooks of {@link Prism.highlight}. These hooks will only be run by the current worker if `async` is `true`.
+ * 4. `before-insert`
+ * 5. `after-highlight`
+ * 6. `complete`
+ *
+ * @param {Element} element The element containing the code.
+ * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
+ * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
+ * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
+ * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
+ *
+ * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
+ * asynchronous highlighting to work. You can build your own bundle on the
+ * [Download page](https://prismjs.com/download.html).
+ * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
+ * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
+ * @memberof Prism
+ * @public
+ */
highlightElement: function(element, async, callback) {
// Find language
var language = _.util.getLanguage(element);
element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
// Set language on the parent, for styling
- var parent = element.parentNode;
+ var parent = element.parentElement;
if (parent && parent.nodeName.toLowerCase() === 'pre') {
parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
}
}
},
+ /**
+ * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
+ * and the language definitions to use, and returns a string with the HTML produced.
+ *
+ * The following hooks will be run:
+ * 1. `before-tokenize`
+ * 2. `after-tokenize`
+ * 3. `wrap`: On each {@link Token}.
+ *
+ * @param {string} text A string with the code to be highlighted.
+ * @param {Grammar} grammar An object containing the tokens to use.
+ *
+ * Usually a language definition like `Prism.languages.markup`.
+ * @param {string} language The name of the language definition passed to `grammar`.
+ * @returns {string} The highlighted HTML.
+ * @memberof Prism
+ * @public
+ * @example
+ * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
+ */
highlight: function (text, grammar, language) {
var env = {
code: text,
return Token.stringify(_.util.encode(env.tokens), env.language);
},
+ /**
+ * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
+ * and the language definitions to use, and returns an array with the tokenized code.
+ *
+ * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
+ *
+ * This method could be useful in other contexts as well, as a very crude parser.
+ *
+ * @param {string} text A string with the code to be highlighted.
+ * @param {Grammar} grammar An object containing the tokens to use.
+ *
+ * Usually a language definition like `Prism.languages.markup`.
+ * @returns {TokenStream} An array of strings and tokens, a token stream.
+ * @memberof Prism
+ * @public
+ * @example
+ * let code = `var foo = 0;`;
+ * let tokens = Prism.tokenize(code, Prism.languages.javascript);
+ * tokens.forEach(token => {
+ * if (token instanceof Prism.Token && token.type === 'number') {
+ * console.log(`Found numeric literal: ${token.content}`);
+ * }
+ * });
+ */
tokenize: function(text, grammar) {
var rest = grammar.rest;
if (rest) {
return toArray(tokenList);
},
+ /**
+ * @namespace
+ * @memberof Prism
+ * @public
+ */
hooks: {
all: {},
+ /**
+ * Adds the given callback to the list of callbacks for the given hook.
+ *
+ * The callback will be invoked when the hook it is registered for is run.
+ * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
+ *
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
+ *
+ * @param {string} name The name of the hook.
+ * @param {HookCallback} callback The callback function which is given environment variables.
+ * @public
+ */
add: function (name, callback) {
var hooks = _.hooks.all;
hooks[name].push(callback);
},
+ /**
+ * Runs a hook invoking all registered callbacks with the given environment variables.
+ *
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
+ *
+ * @param {string} name The name of the hook.
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
+ * @public
+ */
run: function (name, env) {
var callbacks = _.hooks.all[name];
Token: Token
};
-
_self.Prism = _;
-function Token(type, content, alias, matchedStr, greedy) {
+
+// Typescript note:
+// The following can be used to import the Token type in JSDoc:
+//
+// @typedef {InstanceType<import("./prism-core")["Token"]>} Token
+
+/**
+ * Creates a new token.
+ *
+ * @param {string} type See {@link Token#type type}
+ * @param {string | TokenStream} content See {@link Token#content content}
+ * @param {string|string[]} [alias] The alias(es) of the token.
+ * @param {string} [matchedStr=""] A copy of the full string this token was created from.
+ * @class
+ * @global
+ * @public
+ */
+function Token(type, content, alias, matchedStr) {
+ /**
+ * The type of the token.
+ *
+ * This is usually the key of a pattern in a {@link Grammar}.
+ *
+ * @type {string}
+ * @see GrammarToken
+ * @public
+ */
this.type = type;
+ /**
+ * The strings or tokens contained by this token.
+ *
+ * This will be a token stream if the pattern matched also defined an `inside` grammar.
+ *
+ * @type {string | TokenStream}
+ * @public
+ */
this.content = content;
+ /**
+ * The alias(es) of the token.
+ *
+ * @type {string|string[]}
+ * @see GrammarToken
+ * @public
+ */
this.alias = alias;
// Copy of the full string this token was created from
- this.length = (matchedStr || '').length|0;
- this.greedy = !!greedy;
+ this.length = (matchedStr || '').length | 0;
}
+/**
+ * A token stream is an array of strings and {@link Token Token} objects.
+ *
+ * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
+ * them.
+ *
+ * 1. No adjacent strings.
+ * 2. No empty strings.
+ *
+ * The only exception here is the token stream that only contains the empty string and nothing else.
+ *
+ * @typedef {Array<string | Token>} TokenStream
+ * @global
+ * @public
+ */
+
+/**
+ * Converts the given token or token stream to an HTML representation.
+ *
+ * The following hooks will be run:
+ * 1. `wrap`: On each {@link Token}.
+ *
+ * @param {string | Token | TokenStream} o The token or token stream to be converted.
+ * @param {string} language The name of current language.
+ * @returns {string} The HTML representation of the token or token stream.
+ * @memberof Token
+ * @static
+ */
Token.stringify = function stringify(o, language) {
if (typeof o == 'string') {
return o;
* @param {any} grammar
* @param {LinkedListNode<string | Token>} startNode
* @param {number} startPos
- * @param {boolean} [oneshot=false]
- * @param {string} [target]
+ * @param {RematchOptions} [rematch]
+ * @returns {void}
+ * @private
+ *
+ * @typedef RematchOptions
+ * @property {string} cause
+ * @property {number} reach
*/
-function matchGrammar(text, tokenList, grammar, startNode, startPos, oneshot, target) {
+function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
for (var token in grammar) {
if (!grammar.hasOwnProperty(token) || !grammar[token]) {
continue;
patterns = Array.isArray(patterns) ? patterns : [patterns];
for (var j = 0; j < patterns.length; ++j) {
- if (target && target == token + ',' + j) {
+ if (rematch && rematch.cause == token + ',' + j) {
return;
}
- var pattern = patterns[j],
- inside = pattern.inside,
- lookbehind = !!pattern.lookbehind,
- greedy = !!pattern.greedy,
+ var patternObj = patterns[j],
+ inside = patternObj.inside,
+ lookbehind = !!patternObj.lookbehind,
+ greedy = !!patternObj.greedy,
lookbehindLength = 0,
- alias = pattern.alias;
+ alias = patternObj.alias;
- if (greedy && !pattern.pattern.global) {
+ if (greedy && !patternObj.pattern.global) {
// Without the global flag, lastIndex won't work
- var flags = pattern.pattern.toString().match(/[imsuy]*$/)[0];
- pattern.pattern = RegExp(pattern.pattern.source, flags + 'g');
+ var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
+ patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
}
- pattern = pattern.pattern || pattern;
+ /** @type {RegExp} */
+ var pattern = patternObj.pattern || patternObj;
for ( // iterate the token list and keep track of the current token/string position
var currentNode = startNode.next, pos = startPos;
pos += currentNode.value.length, currentNode = currentNode.next
) {
+ if (rematch && pos >= rematch.reach) {
+ break;
+ }
+
var str = currentNode.value;
if (tokenList.length > text.length) {
// find the last node which is affected by this match
for (
var k = currentNode;
- k !== tokenList.tail && (p < to || (typeof k.value === 'string' && !k.prev.value.greedy));
+ k !== tokenList.tail && (p < to || typeof k.value === 'string');
k = k.next
) {
removeCount++;
}
if (!match) {
- if (oneshot) {
- break;
- }
-
continue;
}
}
var from = match.index + lookbehindLength,
- match = match[0].slice(lookbehindLength),
- to = from + match.length,
+ matchStr = match[0].slice(lookbehindLength),
+ to = from + matchStr.length,
before = str.slice(0, from),
after = str.slice(to);
+ var reach = pos + str.length;
+ if (rematch && reach > rematch.reach) {
+ rematch.reach = reach;
+ }
+
var removeFrom = currentNode.prev;
if (before) {
removeRange(tokenList, removeFrom, removeCount);
- var wrapped = new Token(token, inside ? _.tokenize(match, inside) : match, alias, match, greedy);
+ var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
currentNode = addAfter(tokenList, removeFrom, wrapped);
if (after) {
addAfter(tokenList, currentNode, after);
}
-
- if (removeCount > 1)
- matchGrammar(text, tokenList, grammar, currentNode.prev, pos, true, token + ',' + j);
-
- if (oneshot)
- break;
+ if (removeCount > 1) {
+ // at least one Token object was removed, so we have to do some rematching
+ // this can only happen if the current pattern is greedy
+ matchGrammar(text, tokenList, grammar, currentNode.prev, pos, {
+ cause: token + ',' + j,
+ reach: reach
+ });
+ }
}
}
}
* @property {LinkedListNode<T> | null} prev The previous node.
* @property {LinkedListNode<T> | null} next The next node.
* @template T
+ * @private
*/
/**
* @template T
+ * @private
*/
function LinkedList() {
/** @type {LinkedListNode<T>} */
return _;
}
-//Get current script and highlight
+// Get current script and highlight
var script = _.util.currentScript();
if (script) {
if (typeof global !== 'undefined') {
global.Prism = Prism;
}
+
+// some additional documentation/types
+
+/**
+ * The expansion of a simple `RegExp` literal to support additional properties.
+ *
+ * @typedef GrammarToken
+ * @property {RegExp} pattern The regular expression of the token.
+ * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
+ * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
+ * @property {boolean} [greedy=false] Whether the token is greedy.
+ * @property {string|string[]} [alias] An optional alias or list of aliases.
+ * @property {Grammar} [inside] The nested grammar of this token.
+ *
+ * The `inside` grammar will be used to tokenize the text value of each token of this kind.
+ *
+ * This can be used to make nested and even recursive language definitions.
+ *
+ * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
+ * each another.
+ * @global
+ * @public
+*/
+
+/**
+ * @typedef Grammar
+ * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
+ * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
+ * @global
+ * @public
+ */
+
+/**
+ * A function which will invoked after an element was successfully highlighted.
+ *
+ * @callback HighlightCallback
+ * @param {Element} element The element successfully highlighted.
+ * @returns {void}
+ * @global
+ * @public
+*/
+
+/**
+ * @callback HookCallback
+ * @param {Object<string, any>} env The environment variables of the hook.
+ * @returns {void}
+ * @global
+ * @public
+ */