mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-10-31 15:12:12 +00:00 
			
		
		
		
	Add JQ syntax highlighting
This commit is contained in:
		
							
								
								
									
										60
									
								
								tests/syntax-tests/highlighted/JQ/sample.jq
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								tests/syntax-tests/highlighted/JQ/sample.jq
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,60 @@ | ||||
| [38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m../imported-file[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242m;[0m | ||||
|  | ||||
| [38;2;117;113;94m#[0m[38;2;117;113;94m With Comments ![0m | ||||
| [38;2;249;38;114mdef[0m[38;2;248;248;242m [0m[38;2;166;226;46mweird[0m[38;2;248;248;242m([0m[3;38;2;253;151;31m$a[0m[38;2;248;248;242m; [0m[3;38;2;253;151;31m$b[0m[38;2;248;248;242m; [0m[3;38;2;253;151;31m$c[0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242m[ [0m[38;2;255;255;255m$a[0m[38;2;248;248;242m, [0m[38;2;255;255;255m$b[0m[38;2;248;248;242m, [0m[38;2;255;255;255m$c[0m[38;2;248;248;242m ][0m[38;2;248;248;242m | [0m[38;2;102;217;239mtranspose[0m[38;2;248;248;242m | [0m[38;2;249;38;114mreduce[0m[38;2;248;248;242m .[0m[38;2;248;248;242m[][0m[38;2;248;248;242m[][0m[38;2;248;248;242m [0m[38;2;249;38;114mas[0m[38;2;248;248;242m [0m[38;2;255;255;255m$item[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m | ||||
| [38;2;248;248;242m		[0m[38;2;248;248;242m[][0m[38;2;248;248;242m;[0m | ||||
| [38;2;248;248;242m		. + [0m[38;2;255;255;255m$item[0m[38;2;248;248;242m.property[0m | ||||
| [38;2;248;248;242m	)[0m | ||||
| [38;2;248;248;242m;[0m | ||||
|  | ||||
| [38;2;248;248;242m. | weird [0m[38;2;248;248;242m(.a; .b; .c)[0m[38;2;248;248;242m |[0m | ||||
|  | ||||
| [38;2;248;248;242m([0m | ||||
|  | ||||
| [38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;248;248;242m(. | [0m[38;2;102;217;239mcontains[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mnever[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m )[0m[38;2;248;248;242m [0m[38;2;249;38;114mthen[0m | ||||
| [38;2;248;248;242m	[0m[38;2;230;219;116m"[0m[38;2;230;219;116mWhy yes[0m[38;2;230;219;116m"[0m | ||||
| [38;2;249;38;114melse[0m | ||||
| [38;2;248;248;242m	[0m[38;2;190;132;255m12.23[0m | ||||
| [38;2;249;38;114mend[0m | ||||
|  | ||||
| [38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114mas[0m[38;2;248;248;242m [0m[38;2;255;255;255m$never[0m[38;2;248;248;242m |[0m | ||||
|  | ||||
| [38;2;248;248;242m{[0m | ||||
| [38;2;248;248;242m	[0m[38;2;166;226;46mhello[0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m	[0m[38;2;166;226;46mwhy[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mbecause[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m	[0m[38;2;166;226;46mhello[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m( weird | [0m[38;2;102;217;239mascii_upcase[0m[38;2;248;248;242m )[0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m	[0m[38;2;166;226;46mformat_eg[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m( . | [0m[38;2;190;132;255m@json[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mMy json string [0m[38;2;190;132;255m\([0m[38;2;248;248;242m . | this | part | just | white | ascii_upcase | transpose[0m[38;2;190;132;255m)[0m[38;2;230;219;116m"[0m[38;2;248;248;242m )[0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m	[0m[38;2;166;226;46mnever[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;255;255;255m$never[0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m	[0m[38;2;230;219;116m"[0m[38;2;230;219;116mliteral_key[0m[38;2;230;219;116m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m literal_value[0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m	[0m[38;2;230;219;116m"[0m[38;2;230;219;116mthis[0m[38;2;230;219;116m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;190;132;255m12.1e12[0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m	[0m[38;2;230;219;116m"[0m[38;2;230;219;116mpart[0m[38;2;230;219;116m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116malmost[0m[38;2;230;219;116m"[0m | ||||
| [38;2;248;248;242m	[0m[38;2;230;219;116m"[0m[38;2;230;219;116mlike[0m[38;2;230;219;116m"[0m[38;2;248;248;242m: [0m[38;2;248;248;242m[[0m | ||||
| [38;2;248;248;242m		[0m[38;2;190;132;255m12[0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m		[0m[38;2;190;132;255m2[0m | ||||
| [38;2;248;248;242m		[0m[38;2;230;219;116m"[0m[38;2;230;219;116mjson[0m[38;2;230;219;116m"[0m | ||||
| [38;2;248;248;242m		[0m[38;2;248;248;242m{[0m | ||||
| [38;2;248;248;242m			[0m[38;2;230;219;116m"[0m[38;2;230;219;116mquite[0m[38;2;230;219;116m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m | ||||
| [38;2;248;248;242m				[0m[38;2;166;226;46msimilar[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mbut not quite[0m[38;2;230;219;116m"[0m | ||||
| [38;2;248;248;242m			[0m[38;2;248;248;242m}[0m | ||||
| [38;2;248;248;242m		[0m[38;2;248;248;242m}[0m | ||||
| [38;2;248;248;242m	][0m[38;2;248;248;242m,[0m | ||||
| [38;2;248;248;242m}[0m[38;2;248;248;242m | [0m[38;2;248;248;242m([0m | ||||
| [38;2;248;248;242m	[0m | ||||
| [38;2;248;248;242m	[0m[38;2;117;113;94m#[0m[38;2;117;113;94m And with very basic brace matching[0m | ||||
| [38;2;248;248;242m	[0m | ||||
| [38;2;248;248;242m	[0m[38;2;117;113;94m#[0m[38;2;117;113;94m Invalid End[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;240m][0m[38;2;248;248;242m	[0m | ||||
| [38;2;248;248;242m	[0m | ||||
| [38;2;248;248;242m	[0m[38;2;117;113;94m#[0m[38;2;117;113;94m Other invalid ends[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242m( [0m[38;2;248;248;242m[ [0m[38;2;248;248;240m}[0m[38;2;248;248;242m [0m[38;2;248;248;240m][0m[38;2;248;248;242m )[0m | ||||
|  | ||||
| [38;2;248;248;242m	[0m[38;2;117;113;94m#[0m[38;2;117;113;94m A "valid" sequence[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242m( [0m[38;2;248;248;242m[  [0m[38;2;248;248;242m{ [0m[38;2;166;226;46mkey[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m()[0m[38;2;248;248;242m [0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;166;226;46mother_key[0m[38;2;248;248;242m:[0m[38;2;248;248;242m( [0m[38;2;248;248;242m[ [0m[38;2;248;248;242m[][0m[38;2;248;248;242m  [0m[38;2;248;248;242m[[0m[38;2;248;248;242m[][0m[38;2;248;248;242m][0m[38;2;248;248;242m ][0m[38;2;248;248;242m  )[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;166;226;46mgaga[0m[38;2;248;248;242m }[0m[38;2;248;248;242m  ][0m[38;2;248;248;242m )[0m | ||||
|  | ||||
| [38;2;248;248;242m	[0m[38;2;117;113;94m#[0m[38;2;117;113;94m A "invalid" sequence[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242m( [0m[38;2;248;248;242m[  [0m[38;2;248;248;242m{ [0m[38;2;166;226;46mkey[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m()[0m[38;2;248;248;242m [0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;166;226;46mother_key[0m[38;2;248;248;242m:[0m[38;2;248;248;242m( [0m[38;2;248;248;242m[ [0m[38;2;248;248;242m[][0m[38;2;248;248;242m  [0m[38;2;248;248;242m[[0m[38;2;248;248;242m[][0m[38;2;248;248;242m ][0m[38;2;248;248;242m  [0m[38;2;248;248;240m)[0m[38;2;248;248;242m, gaga [0m[38;2;248;248;240m}[0m[38;2;248;248;242m  ] )[0m | ||||
|  | ||||
| [38;2;248;248;242m	[0m[38;2;230;219;116m"[0m[38;2;230;219;116mA string[0m[38;2;190;132;255m\[0m[38;2;190;132;255mn[0m[38;2;230;219;116m whith escaped characters [0m[38;2;190;132;255m\[0m[38;2;190;132;255m"[0m[38;2;230;219;116m because we can[0m[38;2;230;219;116m"[0m | ||||
| [38;2;248;248;242m)[0m | ||||
|  | ||||
							
								
								
									
										25
									
								
								tests/syntax-tests/source/JQ/LICENSE.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								tests/syntax-tests/source/JQ/LICENSE.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| The `sample.jq` file was taken from [SublimeJQ] under the following license: | ||||
|  | ||||
| [SublimeJQ]: https://github.com/zogwarg/SublimeJQ | ||||
|  | ||||
| MIT License | ||||
|  | ||||
| Copyright (c) 2017 Thomas Buick | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| in the Software without restriction, including without limitation the rights | ||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| copies of the Software, and to permit persons to whom the Software is | ||||
| furnished to do so, subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| SOFTWARE. | ||||
							
								
								
									
										60
									
								
								tests/syntax-tests/source/JQ/sample.jq
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								tests/syntax-tests/source/JQ/sample.jq
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,60 @@ | ||||
| import "../imported-file" ; | ||||
|  | ||||
| # With Comments ! | ||||
| def weird($a; $b; $c): | ||||
| 	[ $a, $b, $c ] | transpose | reduce .[][] as $item ( | ||||
| 		[]; | ||||
| 		. + $item.property | ||||
| 	) | ||||
| ; | ||||
|  | ||||
| . | weird (.a; .b; .c) | | ||||
|  | ||||
| ( | ||||
|  | ||||
| if (. | contains("never") ) then | ||||
| 	"Why yes" | ||||
| else | ||||
| 	12.23 | ||||
| end | ||||
|  | ||||
| ) as $never | | ||||
|  | ||||
| { | ||||
| 	hello, | ||||
| 	why: "because", | ||||
| 	hello: ( weird | ascii_upcase ), | ||||
| 	format_eg: ( . | @json "My json string \( . | this | part | just | white | ascii_upcase | transpose)" ), | ||||
| 	never: $never, | ||||
| 	"literal_key": literal_value, | ||||
| 	"this": 12.1e12, | ||||
| 	"part": "almost" | ||||
| 	"like": [ | ||||
| 		12, | ||||
| 		2 | ||||
| 		"json" | ||||
| 		{ | ||||
| 			"quite": { | ||||
| 				similar: "but not quite" | ||||
| 			} | ||||
| 		} | ||||
| 	], | ||||
| } | ( | ||||
| 	 | ||||
| 	# And with very basic brace matching | ||||
| 	 | ||||
| 	# Invalid End | ||||
| 	]	 | ||||
| 	 | ||||
| 	# Other invalid ends | ||||
| 	( [ } ] ) | ||||
|  | ||||
| 	# A "valid" sequence | ||||
| 	( [  { key: () , other_key:( [ []  [[]] ]  ), gaga }  ] ) | ||||
|  | ||||
| 	# A "invalid" sequence | ||||
| 	( [  { key: () , other_key:( [ []  [[] ]  ), gaga }  ] ) | ||||
|  | ||||
| 	"A string\n whith escaped characters \" because we can" | ||||
| ) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user