├── .gitignore ├── .linguist.yml ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── examples ├── AdvPL │ └── JSONTest.prw ├── Brain │ └── human_jump.brain ├── Brainfuck │ └── hellbox.bf ├── BrazukaScript │ └── wesley_safadao.bra ├── C │ └── io.c ├── Capybara │ └── helloworld.capy ├── Headache │ └── func.ha ├── Monga │ └── bf.monga ├── Moon │ └── _examples_.moon ├── Quack │ ├── fn_stmt.qk │ └── quack.qtest ├── Siren │ └── 100-doors.siren └── Test │ └── test.test ├── img ├── brain_change.gif ├── changing_test.gif ├── linguist-unknown-icon-128.png ├── linguist-unknown-icon-16.png ├── linguist-unknown-icon-48.png ├── linguist-unknown-icon.png ├── linguist-unknown.png ├── linguist-unknown.svg └── on_off.gif ├── manifest.json ├── package.json ├── src ├── css │ ├── linguist_style.css │ └── style.css ├── scripts-min │ ├── js-yaml.min.js │ ├── linguist-bootstrap-chrome.min.js │ ├── linguist.min.js │ └── popup.min.js ├── scripts │ ├── ling-bootstrap.js │ ├── ling-highlighter.js │ ├── ling-loader.js │ └── popup.js └── views │ └── popup.html └── test ├── mocha.opts ├── test-download.js ├── test-highlighter.js ├── test-lexer.js ├── test-match-url.js ├── test-token.js └── test-utilities.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | node_modules/ 4 | -------------------------------------------------------------------------------- /.linguist.yml: -------------------------------------------------------------------------------- 1 | --- 2 | AdvPL: 3 | extensions: 4 | - ".prw" 5 | - ".apw" 6 | - ".aph" 7 | - ".ch" 8 | 9 | identifier: 10 | color: "#55B4D4" 11 | 12 | string: 13 | color: "#86B300" 14 | 15 | number: 16 | color: "#A37ACC" 17 | 18 | comment: 19 | color: "#969896" 20 | single_line: "//" 21 | begin_multiline: "/*" 22 | end_multiline: "*/" 23 | 24 | group: 25 | - color: "#86B300" 26 | operators: 27 | - "#" 28 | keywords: 29 | - "include" 30 | 31 | - color: "#FA6E32" 32 | keywords: 33 | - "Static" 34 | - "Function" 35 | - "Local" 36 | - "Return" 37 | - "If" 38 | - "Else" 39 | - "EndIf" 40 | 41 | - color: "#6E7580" 42 | operators: 43 | - "@" 44 | - "==" 45 | - ":=" 46 | - ":" 47 | - "(" 48 | - ")" 49 | - "[" 50 | - "]" 51 | 52 | # Including a complete new language 53 | Brain: 54 | extensions: 55 | - ".br" 56 | - ".brain" 57 | 58 | default: 59 | color: "#969896" 60 | 61 | group: 62 | - color: "#a71d5d" 63 | operators: 64 | - ">" 65 | - "<" 66 | - "^" 67 | - "<" 68 | - ">" 69 | 70 | - color: "#333333" 71 | operators: 72 | - "[" 73 | - "]" 74 | - "{" 75 | - "}" 76 | - "?" 77 | - ":" 78 | - ";" 79 | - "!" 80 | 81 | - color: "#0086b3" 82 | operators: 83 | - "+" 84 | - "-" 85 | - "*" 86 | - "/" 87 | - "%" 88 | - "_" 89 | 90 | - color: "#795da3" 91 | operators: 92 | - "." 93 | - "," 94 | - "$" 95 | - "#" 96 | 97 | # Overwriting BF - Testing GitHub known languages 98 | Brainfuck: 99 | extensions: 100 | - ".bf" 101 | 102 | group: 103 | - color: "#BF211E" 104 | operators: 105 | - ">" 106 | - "<" 107 | - "<" 108 | - ">" 109 | 110 | - color: "#B744B8" 111 | operators: 112 | - "[" 113 | - "]" 114 | 115 | - color: "#69A197" 116 | operators: 117 | - "+" 118 | - "-" 119 | 120 | - color: "#F9DC5C" 121 | operators: 122 | - "." 123 | - "," 124 | 125 | BrazukaScript: 126 | extensions: 127 | - ".bra" 128 | 129 | default: 130 | color: "#ccb100" 131 | 132 | string: 133 | color: "#002776" 134 | 135 | number: 136 | color: "#002776" 137 | 138 | comment: 139 | color: "#969896" 140 | begin_multiline: "/*" 141 | end_multiline: "*/" 142 | 143 | group: 144 | - color: "#009c3b" 145 | keywords: 146 | - "funcao" 147 | - "real" 148 | - "inteiro" 149 | - "retorna" 150 | - "se" 151 | - "senao" 152 | 153 | # Testing overwriting C colors 154 | C: 155 | extensions: 156 | - ".c" 157 | 158 | default: 159 | color: "#24292e" 160 | 161 | identifier: 162 | color: "#7b9c0e" 163 | 164 | number: 165 | color: "#745296" 166 | 167 | string: 168 | color: "#8B9EB7" 169 | 170 | comment: 171 | color: "#969896" 172 | single_line: "//" 173 | begin_multiline: "/*" 174 | end_multiline: "*/" 175 | 176 | group: 177 | - color: "#a71d5d" 178 | keywords: 179 | - "include" 180 | - "void" 181 | - "int" 182 | - "float" 183 | 184 | - color: "#FF1053" 185 | keywords: 186 | - "printf" 187 | - "putchar" 188 | - "getchar" 189 | 190 | Capybara: 191 | extensions: 192 | - ".capy" 193 | 194 | default: 195 | color: "#5A0001" 196 | 197 | number: 198 | color: "#F45B69" 199 | 200 | group: 201 | - color: "#F13030" 202 | keywords: 203 | - "Module" 204 | - "Import" 205 | - "Export" 206 | - "Declare" 207 | 208 | - color: "#F45B69" 209 | operators: 210 | - "::" 211 | - ":=" 212 | - "#" 213 | 214 | - color: "#F45B69" 215 | regexes: 216 | - regex: "{:.*:}" 217 | modifier: "" 218 | 219 | Headache: 220 | extensions: 221 | - ".ha" 222 | 223 | default: 224 | color: "#3185FC" 225 | 226 | string: 227 | color: "#D6B62A" 228 | 229 | group: 230 | - color: "#D6B62A" 231 | operators: 232 | - "@" 233 | keywords: 234 | - "as" 235 | - "main" 236 | 237 | - color: "#E84855" 238 | keywords: 239 | - "return" 240 | - "void" 241 | - "byte" 242 | 243 | Monga: 244 | extensions: 245 | - ".monga" 246 | 247 | default: 248 | color: "#DBB4AD" 249 | 250 | identifier: 251 | color: "#9B785B" 252 | 253 | number: 254 | color: "#A2AD91" 255 | 256 | string: 257 | color: "#A2AD91" 258 | 259 | comment: 260 | color: "#BAA5A0" 261 | single_line: "//" 262 | begin_multiline: "/*" 263 | end_multiline: "*/" 264 | 265 | group: 266 | - color: "#876974" 267 | operators: 268 | - ";" 269 | - "[" 270 | - "]" 271 | - "{" 272 | - "}" 273 | - "(" 274 | - ")" 275 | - "==" 276 | - "=" 277 | - "<" 278 | - ">" 279 | - "@" 280 | 281 | - color: "#D30C7B" 282 | keywords: 283 | - "void" 284 | - "char" 285 | - "int" 286 | - "return" 287 | - "while" 288 | - "if" 289 | - "else" 290 | - "new" 291 | 292 | Moon: 293 | extensions: 294 | - ".moon" 295 | 296 | default: 297 | color: "#3C6D4E" 298 | 299 | identifier: 300 | color: "#59564F" 301 | 302 | comment: 303 | color: "#969896" 304 | single_line: "//" 305 | 306 | string: 307 | color: "#8367C7" 308 | 309 | number: 310 | color: "#8367C7" 311 | 312 | group: 313 | - color: "#5603AD" 314 | keywords: 315 | - "do" 316 | - "if" 317 | 318 | - color: "#d73a49" 319 | operators: 320 | - ">" 321 | - "=>" 322 | - "=<" 323 | - "|" 324 | - "=" 325 | 326 | Quack: 327 | extensions: 328 | - ".qk" 329 | - ".qkt" 330 | - ".qtest" 331 | 332 | default: 333 | color: "#1F437C" 334 | 335 | identifier: 336 | color: "#0D7CA8" 337 | 338 | number: 339 | color: "#0D7CA8" 340 | 341 | string: 342 | color: "#0B5F63" 343 | 344 | group: 345 | - color: "#0D7CA8" 346 | keywords: 347 | - "true" 348 | - "false" 349 | 350 | - color: "#892525" 351 | regexes: 352 | - regex: "%%.*" 353 | modifier: "" 354 | 355 | - color: "#630A53" 356 | operators: 357 | - "^" 358 | - "=" 359 | - ":-" 360 | keywords: 361 | - "let" 362 | - "fn" 363 | - "do" 364 | - "end" 365 | - "when" 366 | - "unless" 367 | - "if" 368 | - "or" 369 | - "else" 370 | - "then" 371 | - "for" 372 | - "from" 373 | - "to" 374 | 375 | Siren: 376 | extensions: 377 | - ".siren" 378 | 379 | default: 380 | color: "#d33682" 381 | 382 | string: 383 | color: "#dc322f" 384 | 385 | number: 386 | color: "#2aa198" 387 | 388 | identifier: 389 | color: "#b58900" 390 | 391 | comment: 392 | color: "#969896" 393 | single_line: "#" 394 | 395 | group: 396 | - color: "#268bd2" 397 | keywords: 398 | - "True" 399 | - "False" 400 | 401 | - color: "#002b36" 402 | keywords: 403 | - "def" 404 | - "let" 405 | 406 | - color: "#FF8272" 407 | keywords: 408 | - "self" 409 | regexes: 410 | - regex: "@(lazy)" 411 | modifier: "" 412 | - regex: "\\$siren\/\\d+" 413 | modifier: "" 414 | 415 | - color: "#dc322f" 416 | multiline: 417 | - begin: "\"\"\"" 418 | end: "\"\"\"" 419 | 420 | # Testing Regex and others 421 | Test: 422 | extensions: 423 | - ".test" 424 | 425 | default: 426 | color: "#FF8272" 427 | 428 | identifier: 429 | color: "#FF99FF" 430 | 431 | number: 432 | color: "#FF6600" 433 | 434 | string: 435 | color: "#333300" 436 | 437 | comment: 438 | color: "#969896" 439 | single_line: "//" 440 | begin_multiline: "/*" 441 | end_multiline: "*/" 442 | 443 | group: 444 | - color: "#72EEBB" 445 | keywords: 446 | - "for" 447 | - "while" 448 | regexes: 449 | - regex: "(&|amp;)\/[^\/]*\/[gmixXsuUAJD]*" 450 | modifier: "" 451 | 452 | - color: "#FF00FF" 453 | keywords: 454 | - "if" 455 | - "else" 456 | - "switch" 457 | - "let" 458 | 459 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "7" 4 | - "6" 5 | 6 | # JSDOM does not run on versions 5 and 4 :( 7 | # - "5" 8 | # - "4" 9 | 10 | cache: 11 | directories: 12 | - "node_modules" 13 | 14 | before_script: 15 | - "npm install mocha" 16 | - "npm install should" 17 | - "npm install xmlhttprequest" 18 | - "npm install jsdom" 19 | 20 | script: 21 | - "npm test" 22 | 23 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ### Table of Contents 4 | 5 | - [Reporting a bug](#reporting-a-bug) 6 | - [Bug fixing or Adding a new feature](#bug-fixing-or-adding-a-new-feature) 7 | - [Branches](#branches) 8 | - [License](#license) 9 | 10 | ### Reporting a bug 11 | 12 | 1. Look for any related issues [here](https://github.com/github-aux/linguist-unknown/issues). 13 | 2. If you find an issue that seems related, please comment there instead of creating a new issue. If it is determined to be a unique bug, we will let you know that a new issue can be created. 14 | 3. If you find no related issue, create a new issue by clicking [here](https://github.com/github-aux/linguist-unknown/issues/new). 15 | If we find an issue that's related, we will reference it and close your issue, showing you where to follow the bug. 16 | 4. Tell us important details like what webbrowser you are using. 17 | 5. Include any errors that may be displayed. 18 | 6. Update us if you have any new info, or if the problem resolves itself! 19 | 20 | ### Bug fixing or adding a new feature 21 | 22 | 1. Fork it! 23 | 2. Create your feature branch: `git checkout -b my-new-feature` 24 | 3. Our project uses the [Airbnb Javascript Style Guide](https://github.com/airbnb/javascript). Thus, it is a __must__ to read, understand and write Airbnb-guide-compliant code. 25 | 4. Commit your changes: `git commit -m 'Add some feature'` 26 | 5. Push to the branch: `git push origin my-new-feature` 27 | 6. Submit a pull request in one of our [`dev` branches](#branches) :) 28 | 29 | ### Branches 30 | - `chrome`: Stable code for the Linguist Unknown Google Chrome extension. 31 | - `development`: Development code for the _chrome branch_. 32 | 33 | #### In the future: 34 | - `firefox`: Stable code for the Linguist Unknown Mozilla Firefox extension/add-on. 35 | - `firefox-dev`: Development code for the _firefox branch_. 36 | 37 | ### License 38 | 39 | [Linguist Unknown](https://github.com/github-aux/linguist-unknown) is distributed under the GNU General Public License, version 3, [available in this repository](LICENSE). All contributions are assumed to be also licensed under the GPLv3. 40 | 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Brain Logo 3 |

4 | 5 |

6 | Open Source 7 | Travis 8 | Badges 9 | GPL 10 |

11 | 12 | # Linguist Unknown 13 | > This repository is used as a Web Browser extension for the website GitHub.com in order to detect and highlight unknown, lost or new programming languages. Oh! And you are as well able to overwrite syntax highlighting of known languages such as C, Javascript and many others! 14 | 15 | See [`CONTRIBUTING.md`](CONTRIBUTING.md) before creating a pull request. 16 | 17 | # table of contents 18 | 19 | - [Why](#why-should-you-download-it) 20 | - [Download](#how-can-i-download-and-use-it) 21 | - [Highlighting a new language](#how-to-highlight-my-languages) 22 | - [Examples](#examples) 23 | - [Check if Linguist Unknown works](#how-do-i-know-if-it-works) 24 | - [Check if your yaml is valid](#how-do-i-know-my-yaml-is-valid) 25 | - [Documentation](#documentation) 26 | - [Multiple Languages](#multiple-languages-in-same-repo) 27 | - [extensions](#extensions) 28 | - [default](#default) 29 | - [color](#defaultcolor) 30 | - [identifier](#identifier) 31 | - [color](#identifiercolor) 32 | - [number](#number) 33 | - [color](#numbercolor) 34 | - [string](#string) 35 | - [color](#stringcolor) 36 | - [comment](#comment) 37 | - [color](#commentcolor) 38 | - [single_line](#commentsingle_line) 39 | - [begin_multiline](#commentbegin_multiline) 40 | - [end_multiline](#commentend_multiline) 41 | - [group](#group) 42 | - [color](#groupcolor) 43 | - [keywords](#groupkeywords) 44 | - [operators](#groupoperators) 45 | - [regexes](#groupregexes) 46 | - [multiline](#groupmultiline) 47 | - [Contributing](#contributing) 48 | - [License](#license) 49 | 50 | ### Why should you download it? 51 | There are numerous cool languages out there whose syntaxes are not being highlighted on `GitHub`. That happens because the [Linguist Project](https://github.com/github/linguist) targets only the main existent programming languages. 52 | 53 | Because of that, most of the time it is frustrating to see a new-or-unknown-language source code. `Linguist Unknown` is a project that helps new, lost or unknown languages to be visualized on GitHub. It helps you to do what you already do on your favorite Text Editor. 54 | 55 | We believe that all languages should be highlighted on GitHub; just the way it should always be. :) There is an ocean of programming languages out there and by downloading `Linguist Unknown` you're making every drop of this ocean count! 56 | 57 | ### How can I download and use it? 58 | __Two Simple Steps__: 59 | - Install the [Google Chrome Plugin](https://chrome.google.com/webstore/detail/linguist-unknown/oohlobhfikieeeldgalkkkaojcaebclk) or the Firefox Plugin (still in __TODO__, [accepting pull requests](CONTRIBUTING.md)). 60 | - Make sure it is active. 61 | 62 | On/Off 63 | 64 | ### How to highlight my language(s)? 65 | 1. [Download](#how-can-i-download-and-use-it) and install `Linguist Unknown`. 66 | 2. Add a file named `.linguist.yml` into the root of your GitHub repository to tell `Linguist Unknown` your language(s) grammar(s). 67 | 3. Write your grammar(s) rules. The example below tells `Linguist Unknown` that you have a programming language called `Foo` whose extensions are `.foo` and `.bar`. It also tells that `Foo`'s single linge comment is defined by `//`, whereas its multiline comments are defined by `/*` and `*/`. Last but not least, it defines the color of your tokens i.e. __identifier.color__, __number.color__. It also helps you to define the color groups of your grammar's `keywords`, `operators` and customizable `regexes` 68 | ```YAML 69 | Foo: 70 | extensions: 71 | - ".foo" 72 | - ".bar" 73 | 74 | default: 75 | color: "#808A9F" 76 | 77 | identifier: 78 | color: "#333333" 79 | 80 | number: 81 | color: "#FF6600" 82 | 83 | string: 84 | color: "#333300" 85 | 86 | comment: 87 | color: "#CCF5AC" 88 | single_line: "//" 89 | begin_multiline: "/*" 90 | end_multiline: "*/" 91 | 92 | group: 93 | - color: "#72EEBB" 94 | operators: 95 | - "===" 96 | - ">=" 97 | keywords: 98 | - "int" 99 | - "float" 100 | regexes: 101 | - regex: "&(amp;)\/[^\/]*\/([\\S]?)*" 102 | modifier: "" 103 | 104 | - color: "#FF00FF" 105 | keywords: 106 | - "if" 107 | - "else" 108 | - "switch" 109 | - "let" 110 | 111 | - color: "#000000" 112 | multiline: 113 | - begin: "\"\"\"" 114 | end: "\"\"\"" 115 | 116 | ``` 117 | 4. Test it. Go to `https://github.com/your/repository/path/to/file.foo` or `https://github.com/your/repository/path/to/file.bar` and check if is highlighted! Simple as that! 118 | 119 | _// Obs.: Make sure you refresh your browser's cached data._ 120 | 121 | ### Examples 122 | 123 | ##### Brain Language 124 | 125 | ```YAML 126 | Brain: 127 | extensions: 128 | - ".br" 129 | - ".brain" 130 | 131 | default: 132 | color: "#969896" 133 | 134 | group: 135 | - color: "#a71d5d" 136 | operators: 137 | - ">" 138 | - "<" 139 | - "^" 140 | - "<" 141 | - ">" 142 | 143 | - color: "#333333" 144 | operators: 145 | - "[" 146 | - "]" 147 | - "{" 148 | - "}" 149 | - "?" 150 | - ":" 151 | - ";" 152 | - "!" 153 | 154 | - color: "#0086b3" 155 | operators: 156 | - "+" 157 | - "-" 158 | - "*" 159 | - "/" 160 | - "%" 161 | - "_" 162 | 163 | - color: "#795da3" 164 | operators: 165 | - "." 166 | - "," 167 | - "$" 168 | - "#" 169 | 170 | ``` 171 | 172 | ###### Output 173 | 174 |

175 | Brain 176 |

177 | 178 | ##### Test 179 | 180 | ```YAML 181 | Test: 182 | extensions: 183 | - ".test" 184 | 185 | default: 186 | color: "#FF8272" 187 | 188 | identifier: 189 | color: "#FF99FF" 190 | 191 | number: 192 | color: "#FF6600" 193 | 194 | string: 195 | color: "#333300" 196 | 197 | comment: 198 | color: "#969896" 199 | single_line: "//" 200 | begin_multiline: "/*" 201 | end_multiline: "*/" 202 | 203 | group: 204 | - color: "#72EEBB" 205 | keywords: 206 | - "for" 207 | - "while" 208 | regexes: 209 | - regex: "&(amp;)\/[^\/]*\/([\\S]?)*" 210 | modifier: "" 211 | 212 | - color: "#FF00FF" 213 | keywords: 214 | - "if" 215 | - "else" 216 | - "switch" 217 | - "let" 218 | ``` 219 | 220 | ##### Output 221 | 222 |

223 | Test 224 |

225 | 226 | ### How do I know if it works? 227 | After [downloading and installing it](#how-can-i-download-and-use-it), visit one (or all) of the cool languages we have gathered in this repository: 228 | 229 | | Language | GitHub (or info) Repository | URL to test | Test file written by | 230 | | :-----------: | :-------------------------: | :---------- | :-------------- | 231 | | AdvPL | [AdvPL repo](https://github.com/nginformatica/prelude-advpl) | [./examples/AdvPL/JSONTest.prw](https://github.com/github-aux/linguist-unknown/blob/development/examples/AdvPL/JSONTest.prw) | [haskellcamargo](https://github.com/haskellcamargo) | 232 | | Brain | [Brain repo](https://github.com/brain-labs/brain) | [./examples/Brain/human_jump.brain](https://github.com/github-aux/linguist-unknown/blob/chrome/examples/Brain/human_jump.brain) | [luizperes](https://github.com/luizperes) | 233 | | Brainfuck | [Brainfuck (Wikipedia)](https://en.wikipedia.org/wiki/Brainfuck) | [./examples/Brainfuck/hellbox.bf](https://github.com/github-aux/linguist-unknown/blob/chrome/examples/Brainfuck/hellbox.bf) | Robert de Bath | 234 | | BrazukaScript | [BrazukaScript repo](https://github.com/brazuka-script/brazuka-script) | [./examples/BrazukaScript/wesley_safadao.bra](https://github.com/github-aux/linguist-unknown/blob/development/examples/BrazukaScript/wesley_safadao.bra) | [luizperes](https://github.com/luizperes) | 235 | | C | [C (Wikipedia)](https://en.wikipedia.org/wiki/C_(programming_language)) | [./examples/C/io.c](https://github.com/github-aux/linguist-unknown/blob/chrome/examples/C/io.c) | [luizperes](https://github.com/luizperes) | 236 | | Capybara | [Capybara repo](https://github.com/capybara-language/compiler) | [./examples/Capybara/helloworld.capy](https://github.com/github-aux/linguist-unknown/blob/development/examples/Capybara/helloworld.capy) | [haskellcamargo](https://github.com/haskellcamargo) | 237 | | Headache | [Headache repo](https://github.com/LucasMW/Headache) | [./examples/Headache/func.ha](https://github.com/github-aux/linguist-unknown/blob/development/examples/Headache/func.ha) | [LucasMW](https://github.com/LucasMW) | 238 | | Monga | [Monga repo](https://github.com/LucasMW/mongaComp) | [./examples/Monga/bf.monga](https://github.com/github-aux/linguist-unknown/blob/development/examples/Monga/bf.monga) | [LucasMW](https://github.com/LucasMW) | 239 | | Moon | [Moon repo](https://github.com/MaiaVictor/moon-lang) | [./examples/Moon/_examples_.moon](https://github.com/github-aux/linguist-unknown/blob/development/examples/Moon/_examples_.moon) | [MaiaVictor](https://github.com/MaiaVictor) | 240 | | Quack | [Quack repo](https://github.com/quack/quack) | [./examples/Quack/fn_stmt.qk](https://github.com/github-aux/linguist-unknown/blob/development/examples/Quack/fn_stmt.qk) | [luizperes](https://github.com/luizperes) | 241 | | Siren | [Siren repo](https://github.com/siren-lang) | [./examples/Siren/100-doors.siren](https://github.com/github-aux/linguist-unknown/blob/development/examples/Siren/100-doors.siren) | [robotlolita](https://github.com/robotlolita) | 242 | | Test | -- | [./examples/Test/test.test](https://github.com/github-aux/linguist-unknown/blob/chrome/examples/Test/test.test) | [luizperes](https://github.com/luizperes) | 243 | 244 | __If__ they're `highlighted`, you're good to go! 245 | 246 | #### How do I know my YAML is valid? 247 | Please read the [documentation](#documentation) and check if your YAML is valid [here](https://nodeca.github.io/js-yaml/) 248 | 249 | ### Documentation 250 | 251 | ##### Multiple languages in same repo 252 | It's simple, in your `.linguist.yml`: 253 | ```YAML 254 | Foo: 255 | extensions: 256 | - ".foo" 257 | # ... other rules 258 | 259 | Bar: 260 | extensions: 261 | - ".bar" 262 | # ... other rules 263 | ``` 264 | 265 | ##### extensions 266 | List of extensions for your language. 267 | ```YAML 268 | extensions: 269 | - ".ext1" 270 | - ".ext2" 271 | ``` 272 | 273 | ##### default 274 | The default configurations for your language. 275 | 276 | ###### default.color 277 | All tokens with `undefined` color will have this color. If this color is not defined, it will use `GitHub`'s default color: `#24292e`. 278 | ```YAML 279 | default: 280 | color: "#F00BAF" 281 | ``` 282 | 283 | ##### identifier 284 | The rules for `identifiers` in your language. 285 | _// Obs.: Right now we only have the property color, but we may add other properties later such as custom identifiers._ 286 | 287 | ###### identifier.color 288 | The color for your language's `identifiers`. If this color is `undefined`, it will user the property `default.color` instead. 289 | ```YAML 290 | identifier: 291 | color: "#F00BAF" 292 | ``` 293 | 294 | ##### number 295 | The rules for `numbers` in your language. 296 | _// Obs.: Right now we only have the property color, but we may add other properties later such as custom numbers._ 297 | 298 | ###### number.color 299 | The color for your language's `numbers`. If this color is `undefined`, it will user the property `default.color` instead. 300 | ```YAML 301 | number: 302 | color: "#F00BAF" 303 | ``` 304 | 305 | ##### string 306 | The rules for `strings` in your language. 307 | _// Obs.: Right now we only have the property color, but we may add other properties later such as custom strings._ 308 | 309 | ###### string.color 310 | The color for your language's `strings`. If this color is `undefined`, it will user the property `default.color` instead. 311 | ```YAML 312 | string: 313 | color: "#F00BAF" 314 | ``` 315 | #### comment 316 | Group of __lexemes__ related to your comment tokens. 317 | 318 | ##### comment.color 319 | The color for your language's `comments`. If this color is `undefined`, it will user the property `default.color` instead. 320 | ```YAML 321 | comment: 322 | color: "#F00BAF" 323 | ... 324 | ``` 325 | 326 | ##### single\_line 327 | The __lexeme__ for your single line comments, such as `//`, `#` and others 328 | ```YAML 329 | comment: 330 | single_line: "//" 331 | # ... other rules 332 | ``` 333 | 334 | ##### begin\_multiline 335 | The __lexeme__ for the begin of your multiline comments, such as `/*`, `{` and others 336 | ```YAML 337 | comment: 338 | begin_multiline: "/*" 339 | # ... other rules 340 | ``` 341 | 342 | ##### end\_multiline 343 | The __lexeme__ for the end of your multiline comments, such as `*/`, `}` and others 344 | ```YAML 345 | comment: 346 | end_multiline: "*/" 347 | ``` 348 | 349 | ##### group 350 | Represents a list of color rules for your `keywords`, `operators` and others. Example 351 | ```YAML 352 | group: 353 | - color: "#F00BAF" 354 | keywords: 355 | - "if" 356 | - "while" 357 | - "for" 358 | - color: "#333333" 359 | keywords: 360 | - "int" 361 | - "float" 362 | operators: 363 | - "===" 364 | - "!==" 365 | - "==" 366 | multiline: 367 | - begin: "" 368 | - end: "" 369 | - color: "FF0000" 370 | regexes: 371 | - regex: "&(amp;)\/[^\/]*\/([\\S]?)*" 372 | modifier: "" 373 | - regex: "^#(?:[0-9a-fA-F]{3}){1,2}" 374 | modifier: "i" 375 | ``` 376 | 377 | ###### group.color 378 | Defines the `color group` for your `keywords`, `operators` and others (such as `regexes`). If `undefined`, it will user the property default.color instead. 379 | ```YAML 380 | group: 381 | - color: "#F00BAF" 382 | 383 | # ... other rules 384 | ``` 385 | 386 | ###### group.keywords 387 | Defines a list of `keywords` for a color group. 388 | ```YAML 389 | group: 390 | - color: "#F00BAF" 391 | keywords: 392 | - "if" 393 | - "else" 394 | 395 | # ... other rules 396 | ``` 397 | 398 | ###### group.operators 399 | Defines a list of `operators` for color group. 400 | ```YAML 401 | group: 402 | - color: "#F00BAF" 403 | operators: 404 | - "==" 405 | - "!=" 406 | - ">" 407 | 408 | # ... other rules 409 | ``` 410 | 411 | ###### group.regexes 412 | Defines a list of `regexes` for a color group. The `regexes` properties can be used as a property that may identify custom `lexemes` not included by `Linguist Unknown`. For example, imagine that `#FFFFFF` is a valid lexeme in your language, to highlight it with red color, you would most likely do: 413 | ```YAML 414 | group: 415 | - color: "#FF0000" 416 | regexes: 417 | - regex: "^#(?:[0-9a-fA-F]{3}){1,2}" 418 | modifiers: "" 419 | 420 | # ... other rules 421 | ``` 422 | 423 | ###### group.multiline 424 | Defines a list of multiline `lexemes` for a color group. It is very useful when you have a lexeme that takes multiple lines (not intended to be used for comments). 425 | ```YAML 426 | group: 427 | - color: "#FF00FF" 428 | multiline: 429 | - begin: "" 430 | end: "
" 431 | 432 | # ... other rules 433 | ``` 434 | 435 | ### Contributing 436 | Feel free to send your pull requests. Read our [CONTRIBUTING.md](CONTRIBUTING.md) file :) 437 | 438 | ### LICENSE 439 | This project extends [GNU GPL v. 3](http://www.gnu.org/licenses/gpl-3.0.en.html), so be aware of that, regarding copying, modifying and (re)destributing. 440 | 441 | -------------------------------------------------------------------------------- /examples/AdvPL/JSONTest.prw: -------------------------------------------------------------------------------- 1 | #include 'json.ch' 2 | 3 | User Function RunTest 4 | //TestMinify() 5 | //TestParse() 6 | TestFile() 7 | TestStringify() 8 | //TestImpParse() 9 | 10 | Return 11 | 12 | /** 13 | * BEGIN SECTION TEST 14 | */ 15 | Static Function TestMinify 16 | Local cJSON := '{ "some": true, [ "big", 1 ] }' 17 | Local cMinified := JSON():New( cJSON ) 18 | 19 | cMinified := cMinified:Minify() 20 | 21 | Console( cMinified == '{"some":true,["big",1]}' ) 22 | Return 23 | 24 | Static Function TestParse 25 | Local oParser := JSON():New( '{ "data": [ { "name": "Marcelo", "age": 19 } ] }' ) 26 | Local oResult 27 | oParser := oParser:Parse() 28 | 29 | If oParser:IsJSON() 30 | oResult := oParser:Object() 31 | Console( oResult[#'data'][ 1 ][#'name'] == "Marcelo" ) 32 | Console( oResult[#'data'][ 1 ][#'age'] == 19 ) 33 | Else 34 | Console( oParser:Error() ) 35 | EndIf 36 | Return 37 | 38 | Static Function TestFile() 39 | Local oParser := JSON():New( 'C:\hb30\bin\json\main.json' ) 40 | oParser := oParser:File():Parse() 41 | 42 | If oParser:IsJSON() 43 | Console( oParser:Object()[#'children'][ 1 ][#'children'][ 1 ][#'description'] == 'Corretiva' ) 44 | Else 45 | Console( oParser ) 46 | EndIf 47 | Return 48 | 49 | Static Function TestStringify() 50 | Local oJSON := JSONObject():New() 51 | 52 | oJSON[#'data'] := { JSONObject():New() } 53 | oJSON[#'data'][ 1 ][#'name'] := "Marcelo" 54 | oJSON[#'sub' ] := 12.4 55 | 56 | oJSON := JSON():New( oJSON ) 57 | oJSON := oJSON:Stringify(.T.) 58 | 59 | Console( oJSON == '{"data":[{"name":"Marcelo"}],"sub":12.4}' ) 60 | Return 61 | 62 | Static Function TestImpParse() 63 | Local cJSON := '{"n": 1}' 64 | Local oJSON 65 | 66 | If ParseJSON( cJSON, @oJSON ) 67 | Console( oJSON[#'n'] == 1 ) 68 | Else 69 | Console( .F. ) 70 | EndIf 71 | 72 | Return 73 | 74 | -------------------------------------------------------------------------------- /examples/Brain/human_jump.brain: -------------------------------------------------------------------------------- 1 | setup 2 | >>>>>>>?:++; we will only have two sprites at cell 7 3 | build values for distant cells for later jump 4 | >?<<<<<:++++++++>+*>+*>+++++++*<--*<---*<<<<<<; 5 | 6 | ?->>>>>>^>>>+<<<<^:<<; if btn DOWN add Y of human object 7 | ?->>>>>>>>^>>>-<<<<^; if btn UP subtract Y of human object 8 | 9 | player 10 | >>>>>>>>^?:++; make number two if cell 41 is empty 11 | <> go to cell 38 and make it 6 if empty 12 | >+% add 1 to cell 42 and take it mod 2 because of the sprite number 13 | <>>>>>>>>^?:++; go to cell 48 and make number two if cell 48 is empty 17 | >+%++ add 1 to cell 49 and take it mod 2 and add 2 because of monster sprite 18 | >?--:++>_%<++++++++++++; if cell 16 is equal to 0 then we reset it to 15 19 | 20 | ?: if cell 50 is equal to zero 21 | > go to cell 51 22 | ? check if it is different from zero 23 | <<<<<<<< go to cell 43 24 | ?<<<<<^?:+;; if cell 43 different from zero then game over 25 | : if cell 51 equal to zero 26 | <<<<<<<< go to cell 43 27 | ?:<<<<<^?:+;; if cell equal to zero then game over 28 | ; 29 | ; 30 | -------------------------------------------------------------------------------- /examples/Brainfuck/hellbox.bf: -------------------------------------------------------------------------------- 1 | 1 []><[][]><[][]><[][]><[][]><[][]><[][]><[][]><[][]><[][]><[] 2 | 2 []>+>+>++>++<[>[->++++<<+++>]<<]>----.>->+.+++++++..+++.<+[] 3 | 3 [ This is hellbox, a 104 command Hello World ] 4 | 4 [ >+>+>++>++<[>[->++++<<+++>]<<]>----.>>+.+++++++..+++ ] 5 | 5 [ .>.<<<+++++++++++++++.>>.+++.------.--------.>+.>++. ] 6 | 6 [ -- Robert de Bath -- 2014 ] 7 | 7 []>>.<<<+++++++++++++++.>>.+++.------.--------.>+.+>++.<<<[] 8 | 8 []><[][]><[][]><[][]><[][]><[][]><[][]><[][]><[][]><[][]><[] 9 | 10 | -------------------------------------------------------------------------------- /examples/BrazukaScript/wesley_safadao.bra: -------------------------------------------------------------------------------- 1 | /* 2 | * Programa: Wesley Safad�o 3 | * Desenvolvido por : Luiz Peres 4 | * E sim, eu estava escutando a musica 5 | */ 6 | 7 | funcao principal() 8 | { 9 | inteiro dia = 12; 10 | inteiro mes = 11; 11 | inteiro ano = 89; 12 | 13 | real safado = getSafadeza(dia, mes, ano); 14 | real anjo = getAnjo(safado); 15 | escreva("Voce e` %f safado e %f anjo \n", safado, anjo); 16 | } 17 | 18 | funcao real somatorio(real n) 19 | { 20 | se (n == 1) { 21 | retorna 1; 22 | } senao { 23 | retorna n + somatorio(n-1); 24 | } 25 | } 26 | 27 | funcao real getSafadeza (real d, real m, real a) 28 | { 29 | retorna somatorio(m) + (a/100) * (50 - d); 30 | } 31 | 32 | funcao real getAnjo(real saf) 33 | { 34 | retorna 100 - saf; 35 | } 36 | -------------------------------------------------------------------------------- /examples/C/io.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // you can overwrite those functions! :) 4 | 5 | void b_getchar(int idx, int *cells) { 6 | cells[idx] = getchar(); 7 | } 8 | 9 | void b_putchar(int idx, int *cells) { 10 | putchar(cells[idx]); 11 | } 12 | 13 | void b_float_print(int idx, int *cells) { 14 | float value = cells[idx] / 100.0; 15 | printf("%.2f", value); 16 | } 17 | 18 | void b_debug(int idx, int *cells) { 19 | printf( 20 | "Index Pointer: %d Value at Index Pointer: %d\n", 21 | idx, 22 | cells[idx] 23 | ); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /examples/Capybara/helloworld.capy: -------------------------------------------------------------------------------- 1 | Module HelloWorld. 2 | Import StdPrint { field, font, label }. 3 | 4 | Declare text :: String 5 | := {:Hello World!:}. 6 | 7 | Export Block main 8 | label#begin, 9 | field#origin [ 20, 10 ], 10 | font#sizing [ 90, 50 ], 11 | field#data [ text ], 12 | field#sep, 13 | label#end. 14 | 15 | -------------------------------------------------------------------------------- /examples/Headache/func.ha: -------------------------------------------------------------------------------- 1 | byte add(byte a,byte b) { 2 | return (a+b) as byte; 3 | } 4 | 5 | void main() { 6 | byte a; 7 | @"Hello\n"; 8 | a = add(1 as byte,2 as byte); 9 | @a; 10 | } 11 | -------------------------------------------------------------------------------- /examples/Monga/bf.monga: -------------------------------------------------------------------------------- 1 | 2 | /* BF INTERPRETER IN MONGA 3 | Copyright 25/10/16 4 | Modified 17/12/16 5 | Lucas Menezes */ 6 | 7 | int sleep(int t); 8 | int exit(int number); 9 | char getchar(); 10 | void putchar(int c); 11 | 12 | char[] readFile(char[] filename); 13 | 14 | 15 | char[] newCharArrayZeroed(int n) { 16 | int i; 17 | char[] array; 18 | array = new char[n]; 19 | i=0; 20 | while(i') { 65 | memIdx = memIdx + 1; 66 | if(memIdx >= 30000) 67 | error("Access Violation, no cell 30000",-1); 68 | } 69 | else if(program[prgIdx] == '<') { 70 | memIdx = memIdx - 1; 71 | if(memIdx < 0) 72 | error("Access Violation, no cell zero",-1); 73 | } 74 | else if(program[prgIdx] == '+') { 75 | memory[memIdx] = (memory[memIdx] as int) + 1; 76 | } 77 | else if(program[prgIdx] == '-') { 78 | memory[memIdx] = (memory[memIdx] as int) - 1; 79 | } 80 | else if(program[prgIdx] == ',') { 81 | memory[memIdx] = getchar(); 82 | } 83 | else if(program[prgIdx] == '.') { 84 | @ memory[memIdx]; 85 | } 86 | else if(program[prgIdx] == '[') { 87 | 88 | /*@"Will begin loop? "; 89 | @memory[memIdx] as int; @"\n";*/ 90 | if(memory[memIdx]){ 91 | /*@"Entered Loop\n";*/ 92 | stackIdx = stackIdx + 1; 93 | loopStack[stackIdx] = prgIdx; 94 | /*@stackIdx; @"\n";*/ 95 | } 96 | else { 97 | /*jump to next ]*/ 98 | /*@"Won't enter loop\n";*/ 99 | prgIdx = prgIdx + 1; 100 | internalLoopCount = 0; 101 | while(!(program[prgIdx] == ']' && 102 | internalLoopCount == 0)) 103 | /*@"Inside While: "; 104 | @"memIdx "; @memIdx; 105 | @"\n"; */ 106 | /* while not match stop requirements*/ 107 | { 108 | if(program[prgIdx] == '[') 109 | { 110 | internalLoopCount = internalLoopCount + 1; 111 | } 112 | else if(program[prgIdx] == ']') 113 | { 114 | internalLoopCount = internalLoopCount - 1; 115 | 116 | } 117 | prgIdx = prgIdx + 1; 118 | } 119 | 120 | } 121 | } 122 | else if(program[prgIdx] == ']') { 123 | 124 | /*@"Will exit loop? "; 125 | @memory[memIdx] as int; 126 | @"\n";*/ 127 | if(memory[memIdx]) { 128 | /*@"continue looping\n";*/ 129 | prgIdx = loopStack[stackIdx]; 130 | } 131 | else { 132 | /*@"exit loop\n";*/ 133 | stackIdx = stackIdx - 1; 134 | /*@stackIdx; @"\n";*/ 135 | } 136 | } else { 137 | 138 | } 139 | prgIdx = prgIdx + 1; 140 | /*@"prgIdx "; @prgIdx; @"\n";*/ 141 | } 142 | 143 | } 144 | void main (int argc, char[][] argv) { 145 | char[] programStr; 146 | if(argc == 2) { 147 | programStr = readFile(argv[1]); 148 | } 149 | else { 150 | programStr = ">+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-]<.#>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]>++++++++[<++++>-]<+.[-]++++++++++."; 151 | } 152 | execute(programStr); 153 | } 154 | 155 | -------------------------------------------------------------------------------- /examples/Moon/_examples_.moon: -------------------------------------------------------------------------------- 1 | // Test this with `moon runIO _examples_` 2 | 3 | do = zb2rhkLJtRQwHz9e5GjiQkBtjL2SzZZByogr1uNZFyzJGA9dX 4 | 5 | askPowerLevel = loop@ lazy => 6 | | power =< (do "prompt" "What is your power level? ") 7 | (if (gtn (stn power) 9000) 8 | | (do "print" "No, it is not.")> 9 | (loop 0) 10 | | (do "print" "Ah, that's cute!")> 11 | (do "stop")) 12 | 13 | (askPowerLevel 0) 14 | -------------------------------------------------------------------------------- /examples/Quack/fn_stmt.qk: -------------------------------------------------------------------------------- 1 | fn quack() :- console.write("Quack Quack!") 2 | 3 | fn fib(n) 4 | if n = 0 or n = 1 ^ n 5 | else 6 | ^ fib(n - 1) + fib(n - 2) 7 | end 8 | end 9 | 10 | fn fact(n) -> number 11 | let fact :- 1 12 | for i from 1 to n 13 | do fact :- fact * i 14 | end 15 | ^ fact 16 | end 17 | 18 | fn fact(n) 19 | ^ n = 0 then 1 else n * fact(n - 1) 20 | end 21 | -------------------------------------------------------------------------------- /examples/Quack/quack.qtest: -------------------------------------------------------------------------------- 1 | %%describe 2 | Supports formatting post conditional statements 3 | %%source 4 | fn test(n) 5 | ^ n unless n = 0 6 | end 7 | 8 | let jaca :- true 9 | do console.write("Jaca is true") when jaca 10 | %%expect 11 | fn test(n) 12 | ^ n unless n = 0 13 | end 14 | let jaca :- true 15 | do console.write("Jaca is true") when jaca 16 | -------------------------------------------------------------------------------- /examples/Siren/100-doors.siren: -------------------------------------------------------------------------------- 1 | $siren/1 2 | 3 | Console write-line!: """ 4 | You have 100 doors in a row that are all initially closed. 5 | 6 | You make 100 passes by the doors. The first time through, 7 | you visit every door and toggle the door (if the door is closed, 8 | you open it; if it is open, you close it). The second time you 9 | only visit every 2nd door (door #2, #4, #6, ...). 10 | The third time, every 3rd door (door #3, #6, #9, ...), 11 | etc, until you only visit the 100th door. 12 | """. 13 | 14 | 15 | # So, first, we need to have a Door, in order to be able to talk about them. A 16 | # door is something that can be either open or closed, and also has an 17 | # associated index. 18 | let Door = { 19 | def self new: index 20 | # Constructs a new Door. New objects are constructed just by cloning 21 | # existing objects, and giving them new behaviours. In this case we're 22 | # cloning the target of this message and giving it an `index` behaviour, 23 | # which will answer where that door is located at. 24 | self { def_ index = index }. 25 | 26 | 27 | # Conventionally, Siren uses a suffix `?` for predicates 28 | def self open? 29 | # Whether the door is open. 30 | False. 31 | 32 | def self closed? 33 | # Whether the door is closed. 34 | False. 35 | }. 36 | 37 | # Now that we have our base door, we can define the states it can be in. 38 | # Our door can be either in the Open or Closed state, and each of these 39 | # states have different representations. They also respond differently to 40 | # the `open?` and `closed?` messages. 41 | let Open-Door = Door { 42 | def self description 43 | # A textual representation of this door. 44 | "Door ", self index as-string, " is open.". 45 | 46 | def self as-emoji 47 | # An emoji representation of this door. 48 | "_". 49 | 50 | def open? 51 | # Open doors are, of course, open. 52 | True. 53 | 54 | # We don't need to re-define `new:` and `closed?`, since they're inherited 55 | # from the base `Door` object. 56 | }. 57 | 58 | let Closed-Door = Door { 59 | def self description 60 | # A textual representation of this door. 61 | "Door ", self index as-string, " is closed.". 62 | 63 | def self as-emoji 64 | # An emoji representation of this door. 65 | "🚪". 66 | 67 | def self closed? 68 | # Closed doors are, of course, closed. 69 | True. 70 | }. 71 | 72 | 73 | # At last, we can define the problem. It asks us three questions: 74 | # 75 | # - Which state the doors are in? 76 | # - Which ones are closed? 77 | # - Which ones are open? 78 | # 79 | # So we're going to define behaviours that respond to those questions 80 | # accordingly. 81 | let Doors = { 82 | @lazy # This is a pure function so we can memoise its result 83 | def self state 84 | # Returns an array of Doors with the correct states. 85 | (1 to: 100) # A range that goes from 1 to 100, inclusive 86 | as-array # Converted to an array 87 | map: { i | (i square-root === i square-root round) then: { Open-Door new: i } 88 | else: { Closed-Door new: i } } 89 | # Then transformed such that each index holds a door's state 90 | 91 | def self open 92 | # Returns an array of the indexes where doors are open. 93 | self state filter: _ open?; # We only want the doors that are Open 94 | map: _ index # And while we're at it, only their indexes 95 | 96 | def self closed 97 | # Returns an array of the indexes where the doors are closed. 98 | self state filter: _ closed?; # We only want the doors that are Closed 99 | map: _ index # And while we're at it, only their indexes 100 | }. 101 | 102 | # Finally, we can start answering the questions posed to us: 103 | Console write-line!: "\n". 104 | Console write-line!: "What state are the doors in after the last pass?". 105 | Console write-line!: (Doors state map: _ as-emoji; join: ""). 106 | 107 | 108 | Console write-line!: "\n". 109 | Console write-line!: "Which are open?". 110 | Console write-line!: (Doors open join: ", "). 111 | 112 | Console write-line!: "\n". 113 | Console write-line!: "Which are closed?". 114 | Console write-line!: (Doors closed join: ", ") 115 | 116 | -------------------------------------------------------------------------------- /examples/Test/test.test: -------------------------------------------------------------------------------- 1 | // single comment 2 | 3 | /**/ 4 | 5 | /* 6 | 7 | */ 8 | 9 | === // brau 10 | 11 | let jaca = 1 12 | for jaca - 1 ... 2 { ddsds 13 | if jaca == 0 { 14 | continue 15 | } else { 16 | break 17 | } 18 | } 19 | 20 | if jaca ~= &/\w+/i 21 | 22 | let jaca2 = "hi brous 'jaca' hahaha" 23 | let jaca3 = 'ihuuu' 24 | let n = 2.500 25 | 26 | /* multiline comment 27 | * 28 | * if jaca { 29 | * print(dope) 30 | * } 31 | * 32 | */ 33 | 34 | // the code below is the reflect of my mind 35 | ==== if huhdufd let fdjijfdf == !!!!! while for let for for for rfrereer === 36 | -------------------------------------------------------------------------------- /img/brain_change.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-aux/linguist-unknown/597732c1c6b84344e25f33902c9ef10cf0f74cb0/img/brain_change.gif -------------------------------------------------------------------------------- /img/changing_test.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-aux/linguist-unknown/597732c1c6b84344e25f33902c9ef10cf0f74cb0/img/changing_test.gif -------------------------------------------------------------------------------- /img/linguist-unknown-icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-aux/linguist-unknown/597732c1c6b84344e25f33902c9ef10cf0f74cb0/img/linguist-unknown-icon-128.png -------------------------------------------------------------------------------- /img/linguist-unknown-icon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-aux/linguist-unknown/597732c1c6b84344e25f33902c9ef10cf0f74cb0/img/linguist-unknown-icon-16.png -------------------------------------------------------------------------------- /img/linguist-unknown-icon-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-aux/linguist-unknown/597732c1c6b84344e25f33902c9ef10cf0f74cb0/img/linguist-unknown-icon-48.png -------------------------------------------------------------------------------- /img/linguist-unknown-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-aux/linguist-unknown/597732c1c6b84344e25f33902c9ef10cf0f74cb0/img/linguist-unknown-icon.png -------------------------------------------------------------------------------- /img/linguist-unknown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-aux/linguist-unknown/597732c1c6b84344e25f33902c9ef10cf0f74cb0/img/linguist-unknown.png -------------------------------------------------------------------------------- /img/linguist-unknown.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 21 | 23 | image/svg+xml 24 | 26 | 27 | 28 | 29 | 30 | 32 | 53 | 63 | 68 | 72 | 79 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /img/on_off.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-aux/linguist-unknown/597732c1c6b84344e25f33902c9ef10cf0f74cb0/img/on_off.gif -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | 4 | "name": "Linguist Unknown", 5 | "description": "Language Savant for unknown, lost or new programming languages on GitHub.", 6 | "version": "1.0.7.1", 7 | "browser_action": { 8 | "default_icon": "./img/linguist-unknown-icon.png", 9 | "default_popup": "./src/views/popup.html" 10 | }, 11 | "icons": { 12 | "16": "./img/linguist-unknown-icon-16.png", 13 | "48": "./img/linguist-unknown-icon-48.png", 14 | "128": "./img/linguist-unknown-icon-128.png" 15 | }, 16 | "permissions": [ 17 | "tabs", 18 | "notifications", 19 | "http://*/", 20 | "https://*/", 21 | "activeTab", 22 | "storage" 23 | ], 24 | "content_scripts": [ 25 | { 26 | "matches": ["http://www.github.com/*", 27 | "https://www.github.com/*", 28 | "http://github.com/*", 29 | "https://github.com/*"], 30 | "css": ["./src/css/linguist_style.css"], 31 | "js": ["./src/scripts-min/js-yaml.min.js", 32 | "./src/scripts-min/linguist-bootstrap-chrome.min.js", 33 | "./src/scripts-min/linguist.min.js"], 34 | "run_at": "document_start" 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "linguist-unknown", 3 | "version": "0.0.1", 4 | "description": "Language Savant for unknown, lost or new programming languages. Use it if your repo's language is not included on GitHub Linguist", 5 | "scripts": { 6 | "test": "node_modules/.bin/mocha" 7 | }, 8 | "license": "GPL-3.0", 9 | "devDependencies": { 10 | "mocha": "^3.4.2", 11 | "should": ">= 0.0.1", 12 | "xmlhttprequest": ">= 1.8.0", 13 | "jsdom": ">= 11.0.0" 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /src/css/linguist_style.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-aux/linguist-unknown/597732c1c6b84344e25f33902c9ef10cf0f74cb0/src/css/linguist_style.css -------------------------------------------------------------------------------- /src/css/style.css: -------------------------------------------------------------------------------- 1 | .switch { 2 | position: relative; 3 | display: inline-block; 4 | width: 60px; 5 | height: 34px; 6 | } 7 | 8 | .switch input {display:none;} 9 | 10 | .slider { 11 | position: absolute; 12 | cursor: pointer; 13 | top: 0; 14 | left: 0; 15 | right: 0; 16 | bottom: 0; 17 | background-color: #ccc; 18 | -webkit-transition: .4s; 19 | transition: .4s; 20 | } 21 | 22 | .slider:before { 23 | position: absolute; 24 | content: ""; 25 | height: 26px; 26 | width: 26px; 27 | left: 4px; 28 | bottom: 4px; 29 | background-color: white; 30 | -webkit-transition: .4s; 31 | transition: .4s; 32 | } 33 | 34 | input:checked + .slider { 35 | background-color: #5BC236; 36 | } 37 | 38 | input:focus + .slider { 39 | box-shadow: 0 0 1px #5BC236; 40 | } 41 | 42 | input:checked + .slider:before { 43 | -webkit-transform: translateX(26px); 44 | -ms-transform: translateX(26px); 45 | transform: translateX(26px); 46 | } 47 | 48 | /* Rounded sliders */ 49 | .slider.round { 50 | border-radius: 34px; 51 | } 52 | 53 | .slider.round:before { 54 | border-radius: 50%; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/scripts-min/js-yaml.min.js: -------------------------------------------------------------------------------- 1 | /* js-yaml 3.7.0 https://github.com/nodeca/js-yaml */ 2 | !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.jsyaml=e()}}(function(){return function e(t,n,i){function r(a,s){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[a]={exports:{}};t[a][0].call(l.exports,function(e){var n=t[a][1][e];return r(n?n:e)},l,l.exports,e,t,n,i)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;ai&&" "!==e[h+1],h=o);else if(!l(a))return le;m=m&&p(a)}c=c||d&&o-h-1>i&&" "!==e[h+1]}return s||c?" "===e[0]&&n>9?le:c?ue:ce:m&&!r(e)?ae:se}function h(e,t,n,i){e.dump=function(){function r(t){return c(e,t)}if(0===t.length)return"''";if(!e.noCompatMode&&oe.indexOf(t)!==-1)return"'"+t+"'";var o=e.indent*Math.max(1,n),s=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),u=i||e.flowLevel>-1&&n>=e.flowLevel;switch(d(t,u,e.indent,s,r)){case ae:return t;case se:return"'"+t.replace(/'/g,"''")+"'";case ce:return"|"+m(t,e.indent)+g(a(t,o));case ue:return">"+m(t,e.indent)+g(a(y(t,s),o));case le:return'"'+v(t,s)+'"';default:throw new N("impossible error: invalid scalar style")}}()}function m(e,t){var n=" "===e[0]?String(t):"",i="\n"===e[e.length-1],r=i&&("\n"===e[e.length-2]||"\n"===e),o=r?"+":i?"":"-";return n+o+"\n"}function g(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function y(e,t){for(var n,i,r=/(\n+)([^\n]*)/g,o=function(){var n=e.indexOf("\n");return n=n!==-1?n:e.length,r.lastIndex=n,x(e.slice(0,n),t)}(),a="\n"===e[0]||" "===e[0];i=r.exec(e);){var s=i[1],c=i[2];n=" "===c[0],o+=s+(a||n||""===c?"":"\n")+x(c,t),a=n}return o}function x(e,t){if(""===e||" "===e[0])return e;for(var n,i,r=/ [^ ]/g,o=0,a=0,s=0,c="";n=r.exec(e);)s=n.index,s-o>t&&(i=a>o?a:s,c+="\n"+e.slice(o,i),o=i+1),a=s;return c+="\n",c+=e.length-o>t&&a>o?e.slice(o,a)+"\n"+e.slice(a+1):e.slice(o),c.slice(1)}function v(e){for(var t,n,i="",o=0;o1024&&(s+="? "),s+=e.dump+": ",j(e,t,a,!1,!1)&&(s+=e.dump,c+=s));e.tag=u,e.dump="{"+c+"}"}function C(e,t,n,i){var r,o,a,c,u,l,p="",f=e.tag,d=Object.keys(n);if(e.sortKeys===!0)d.sort();else if("function"==typeof e.sortKeys)d.sort(e.sortKeys);else if(e.sortKeys)throw new N("sortKeys must be a boolean or a function");for(r=0,o=d.length;r1024,u&&(l+=e.dump&&U===e.dump.charCodeAt(0)?"?":"? "),l+=e.dump,u&&(l+=s(e,t)),j(e,t+1,c,!0,u)&&(l+=e.dump&&U===e.dump.charCodeAt(0)?":":": ",l+=e.dump,p+=l));e.tag=f,e.dump=p||"{}"}function k(e,t,n){var i,r,o,a,s,c;for(r=n?e.explicitTypes:e.implicitTypes,o=0,a=r.length;o tag resolver accepts not "'+c+'" style');i=s.represent[c](t,c)}e.dump=i}return!0}return!1}function j(e,t,n,i,r,o){e.tag=null,e.dump=n,k(e,n,!1)||k(e,n,!0);var a=T.call(e.dump);i&&(i=e.flowLevel<0||e.flowLevel>t);var s,c,u="[object Object]"===a||"[object Array]"===a;if(u&&(s=e.duplicates.indexOf(n),c=s!==-1),(null!==e.tag&&"?"!==e.tag||c||2!==e.indent&&t>0)&&(r=!1),c&&e.usedDuplicates[s])e.dump="*ref_"+s;else{if(u&&c&&!e.usedDuplicates[s]&&(e.usedDuplicates[s]=!0),"[object Object]"===a)i&&0!==Object.keys(e.dump).length?(C(e,t,e.dump,r),c&&(e.dump="&ref_"+s+e.dump)):(w(e,t,e.dump),c&&(e.dump="&ref_"+s+" "+e.dump));else if("[object Array]"===a)i&&0!==e.dump.length?(b(e,t,e.dump,r),c&&(e.dump="&ref_"+s+e.dump)):(A(e,t,e.dump),c&&(e.dump="&ref_"+s+" "+e.dump));else{if("[object String]"!==a){if(e.skipInvalid)return!1;throw new N("unacceptable kind of an object to dump "+a)}"?"!==e.tag&&h(e,e.dump,t,o)}null!==e.tag&&"?"!==e.tag&&(e.dump="!<"+e.tag+"> "+e.dump)}return!0}function I(e,t){var n,i,r=[],o=[];for(S(e,r,o),n=0,i=o.length;n>10)+55296,(e-65536&1023)+56320)}function f(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||K,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[]}function d(e,t){return new P(t,new W(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function h(e,t){throw d(e,t)}function m(e,t){e.onWarning&&e.onWarning.call(null,d(e,t))}function g(e,t,n,i){var r,o,a,s;if(t1&&(e.result+=R.repeat("\n",t-1))}function C(e,t,n){var s,c,u,l,p,f,d,h,m,y=e.kind,x=e.result;if(m=e.input.charCodeAt(e.position),o(m)||a(m)||35===m||38===m||42===m||33===m||124===m||62===m||39===m||34===m||37===m||64===m||96===m)return!1;if((63===m||45===m)&&(c=e.input.charCodeAt(e.position+1),o(c)||n&&a(c)))return!1;for(e.kind="scalar",e.result="",u=l=e.position,p=!1;0!==m;){if(58===m){if(c=e.input.charCodeAt(e.position+1),o(c)||n&&a(c))break}else if(35===m){if(s=e.input.charCodeAt(e.position-1),o(s))break}else{if(e.position===e.lineStart&&b(e)||n&&a(m))break;if(i(m)){if(f=e.line,d=e.lineStart,h=e.lineIndent,A(e,!1,-1),e.lineIndent>=t){p=!0,m=e.input.charCodeAt(e.position);continue}e.position=l,e.line=f,e.lineStart=d,e.lineIndent=h;break}}p&&(g(e,u,l,!1),w(e,e.line-f),u=l=e.position,p=!1),r(m)||(l=e.position+1),m=e.input.charCodeAt(++e.position)}return g(e,u,l,!1),!!e.result||(e.kind=y,e.result=x,!1)}function k(e,t){var n,r,o;if(n=e.input.charCodeAt(e.position),39!==n)return!1;for(e.kind="scalar",e.result="",e.position++,r=o=e.position;0!==(n=e.input.charCodeAt(e.position));)if(39===n){if(g(e,r,e.position,!0),n=e.input.charCodeAt(++e.position),39!==n)return!0;r=e.position,e.position++,o=e.position}else i(n)?(g(e,r,o,!0),w(e,A(e,!1,t)),r=o=e.position):e.position===e.lineStart&&b(e)?h(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);h(e,"unexpected end of the stream within a single quoted scalar")}function j(e,t){var n,r,o,a,u,l;if(l=e.input.charCodeAt(e.position),34!==l)return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;0!==(l=e.input.charCodeAt(e.position));){if(34===l)return g(e,n,e.position,!0),e.position++,!0;if(92===l){if(g(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),i(l))A(e,!1,t);else if(l<256&&re[l])e.result+=oe[l],e.position++;else if((u=c(l))>0){for(o=u,a=0;o>0;o--)l=e.input.charCodeAt(++e.position),(u=s(l))>=0?a=(a<<4)+u:h(e,"expected hexadecimal character");e.result+=p(a),e.position++}else h(e,"unknown escape sequence");n=r=e.position}else i(l)?(g(e,n,r,!0),w(e,A(e,!1,t)),n=r=e.position):e.position===e.lineStart&&b(e)?h(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}h(e,"unexpected end of the stream within a double quoted scalar")}function I(e,t){var n,i,r,a,s,c,u,l,p,f,d,m=!0,g=e.tag,y=e.anchor,v={};if(d=e.input.charCodeAt(e.position),91===d)a=93,u=!1,i=[];else{if(123!==d)return!1;a=125,u=!0,i={}}for(null!==e.anchor&&(e.anchorMap[e.anchor]=i),d=e.input.charCodeAt(++e.position);0!==d;){if(A(e,!0,t),d=e.input.charCodeAt(e.position),d===a)return e.position++,e.tag=g,e.anchor=y,e.kind=u?"mapping":"sequence",e.result=i,!0;m||h(e,"missed comma between flow collection entries"),p=l=f=null,s=c=!1,63===d&&(r=e.input.charCodeAt(e.position+1),o(r)&&(s=c=!0,e.position++,A(e,!0,t))),n=e.line,_(e,t,H,!1,!0),p=e.tag,l=e.result,A(e,!0,t),d=e.input.charCodeAt(e.position),!c&&e.line!==n||58!==d||(s=!0,d=e.input.charCodeAt(++e.position),A(e,!0,t),_(e,t,H,!1,!0),f=e.result),u?x(e,i,v,p,l,f):s?i.push(x(e,null,v,p,l,f)):i.push(l),A(e,!0,t),d=e.input.charCodeAt(e.position),44===d?(m=!0,d=e.input.charCodeAt(++e.position)):m=!1}h(e,"unexpected end of the stream within a flow collection")}function S(e,t){var n,o,a,s,c=z,l=!1,p=!1,f=t,d=0,m=!1;if(s=e.input.charCodeAt(e.position),124===s)o=!1;else{if(62!==s)return!1;o=!0}for(e.kind="scalar",e.result="";0!==s;)if(s=e.input.charCodeAt(++e.position),43===s||45===s)z===c?c=43===s?Q:J:h(e,"repeat of a chomping mode identifier");else{if(!((a=u(s))>=0))break;0===a?h(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):p?h(e,"repeat of an indentation width identifier"):(f=t+a-1,p=!0)}if(r(s)){do s=e.input.charCodeAt(++e.position);while(r(s));if(35===s)do s=e.input.charCodeAt(++e.position);while(!i(s)&&0!==s)}for(;0!==s;){for(v(e),e.lineIndent=0,s=e.input.charCodeAt(e.position);(!p||e.lineIndentf&&(f=e.lineIndent),i(s))d++;else{if(e.lineIndentt)&&0!==r)h(e,"bad indentation of a sequence entry");else if(e.lineIndentt)&&(_(e,t,Z,!0,a)&&(y?m=e.result:g=e.result),y||(x(e,p,f,d,m,g),d=m=g=null),A(e,!0,-1),c=e.input.charCodeAt(e.position)),e.lineIndent>t&&0!==c)h(e,"bad indentation of a mapping entry");else if(e.lineIndentt?d=1:e.lineIndent===t?d=0:e.lineIndentt?d=1:e.lineIndent===t?d=0:e.lineIndent tag; it should be "'+l.kind+'", not "'+e.kind+'"'),l.resolve(e.result)?(e.result=l.construct(e.result),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):h(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):h(e,"unknown tag !<"+e.tag+">");return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||g}function T(e){var t,n,a,s,c=e.position,u=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};0!==(s=e.input.charCodeAt(e.position))&&(A(e,!0,-1),s=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==s));){for(u=!0,s=e.input.charCodeAt(++e.position),t=e.position;0!==s&&!o(s);)s=e.input.charCodeAt(++e.position);for(n=e.input.slice(t,e.position),a=[],n.length<1&&h(e,"directive name must not be less than one character in length");0!==s;){for(;r(s);)s=e.input.charCodeAt(++e.position);if(35===s){do s=e.input.charCodeAt(++e.position);while(0!==s&&!i(s));break}if(i(s))break;for(t=e.position;0!==s&&!o(s);)s=e.input.charCodeAt(++e.position);a.push(e.input.slice(t,e.position))}0!==s&&v(e),$.call(se,n)?se[n](e,n,a):m(e,'unknown document directive "'+n+'"')}return A(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,A(e,!0,-1)):u&&h(e,"directives end mark is expected"),_(e,e.lineIndent-1,Z,!1,!0),A(e,!0,-1),e.checkLineBreaks&&ee.test(e.input.slice(c,e.position))&&m(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&b(e)?void(46===e.input.charCodeAt(e.position)&&(e.position+=3,A(e,!0,-1))):void(e.position0&&"\0\r\n…\u2028\u2029".indexOf(this.buffer.charAt(i-1))===-1;)if(i-=1,this.position-i>t/2-1){n=" ... ",i+=5;break}for(o="",a=this.position;at/2-1){o=" ... ",a-=5;break}return s=this.buffer.slice(i,a),r.repeat(" ",e)+n+s+o+"\n"+r.repeat(" ",e+this.position-i+n.length)+"^"},i.prototype.toString=function(e){var t,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),e||(t=this.getSnippet(),t&&(n+=":\n"+t)),n},t.exports=i},{"./common":2}],7:[function(e,t,n){"use strict";function i(e,t,n){var r=[];return e.include.forEach(function(e){n=i(e,t,n)}),e[t].forEach(function(e){n.forEach(function(t,n){t.tag===e.tag&&t.kind===e.kind&&r.push(n)}),n.push(e)}),n.filter(function(e,t){return r.indexOf(t)===-1})}function r(){function e(e){i[e.kind][e.tag]=i.fallback[e.tag]=e}var t,n,i={scalar:{},sequence:{},mapping:{},fallback:{}};for(t=0,n=arguments.length;t64)){if(t<0)return!1;i+=6}return i%8===0}function r(e){var t,n,i=e.replace(/[\r\n=]/g,""),r=i.length,o=l,a=0,c=[];for(t=0;t>16&255),c.push(a>>8&255),c.push(255&a)),a=a<<6|o.indexOf(i.charAt(t));return n=r%4*6,0===n?(c.push(a>>16&255),c.push(a>>8&255),c.push(255&a)):18===n?(c.push(a>>10&255),c.push(a>>2&255)):12===n&&c.push(a>>4&255),s?new s(c):c}function o(e){var t,n,i="",r=0,o=e.length,a=l;for(t=0;t>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]),r=(r<<8)+e[t];return n=o%3,0===n?(i+=a[r>>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]):2===n?(i+=a[r>>10&63],i+=a[r>>4&63], 3 | i+=a[r<<2&63],i+=a[64]):1===n&&(i+=a[r>>2&63],i+=a[r<<4&63],i+=a[64],i+=a[64]),i}function a(e){return s&&s.isBuffer(e)}var s;try{var c=e;s=c("buffer").Buffer}catch(e){}var u=e("../type"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";t.exports=new u("tag:yaml.org,2002:binary",{kind:"scalar",resolve:i,construct:r,predicate:a,represent:o})},{"../type":13}],15:[function(e,t,n){"use strict";function i(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)}function r(e){return"true"===e||"True"===e||"TRUE"===e}function o(e){return"[object Boolean]"===Object.prototype.toString.call(e)}var a=e("../type");t.exports=new a("tag:yaml.org,2002:bool",{kind:"scalar",resolve:i,construct:r,predicate:o,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})},{"../type":13}],16:[function(e,t,n){"use strict";function i(e){return null!==e&&!!u.test(e)}function r(e){var t,n,i,r;return t=e.replace(/_/g,"").toLowerCase(),n="-"===t[0]?-1:1,r=[],"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:t.indexOf(":")>=0?(t.split(":").forEach(function(e){r.unshift(parseFloat(e,10))}),t=0,i=1,r.forEach(function(e){t+=e*i,i*=60}),n*t):n*parseFloat(t,10)}function o(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(s.isNegativeZero(e))return"-0.0";return n=e.toString(10),l.test(n)?n.replace("e",".e"):n}function a(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!==0||s.isNegativeZero(e))}var s=e("../common"),c=e("../type"),u=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?|\\.[0-9_]+(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),l=/^[-+]?[0-9]+e/;t.exports=new c("tag:yaml.org,2002:float",{kind:"scalar",resolve:i,construct:r,predicate:a,represent:o,defaultStyle:"lowercase"})},{"../common":2,"../type":13}],17:[function(e,t,n){"use strict";function i(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function r(e){return 48<=e&&e<=55}function o(e){return 48<=e&&e<=57}function a(e){if(null===e)return!1;var t,n=e.length,a=0,s=!1;if(!n)return!1;if(t=e[a],"-"!==t&&"+"!==t||(t=e[++a]),"0"===t){if(a+1===n)return!0;if(t=e[++a],"b"===t){for(a++;a3)return!1;if("/"!==t[t.length-i.length-1])return!1}return!0}function r(e){var t=e,n=/\/([gim]*)$/.exec(e),i="";return"/"===t[0]&&(n&&(i=n[1]),t=t.slice(1,t.length-i.length-1)),new RegExp(t,i)}function o(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}function a(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var s=e("../../type");t.exports=new s("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:i,construct:r,predicate:a,represent:o})},{"../../type":13}],20:[function(e,t,n){"use strict";function i(){return!0}function r(){}function o(){return""}function a(e){return"undefined"==typeof e}var s=e("../../type");t.exports=new s("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:i,construct:r,predicate:a,represent:o})},{"../../type":13}],21:[function(e,t,n){"use strict";var i=e("../type");t.exports=new i("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}})},{"../type":13}],22:[function(e,t,n){"use strict";function i(e){return"<<"===e||null===e}var r=e("../type");t.exports=new r("tag:yaml.org,2002:merge",{kind:"scalar",resolve:i})},{"../type":13}],23:[function(e,t,n){"use strict";function i(e){if(null===e)return!0;var t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)}function r(){return null}function o(e){return null===e}var a=e("../type");t.exports=new a("tag:yaml.org,2002:null",{kind:"scalar",resolve:i,construct:r,predicate:o,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})},{"../type":13}],24:[function(e,t,n){"use strict";function i(e){if(null===e)return!0;var t,n,i,r,o,c=[],u=e;for(t=0,n=u.length;t"},g.prototype.closeSpan=function(){return""},g.prototype.getSpan=function(h,j){return this.openSpan(j)+h+this.closeSpan()},g.prototype.isId=function(h,j){return"a"<=h&&"z">=h||"A"<=h&&"Z">=h||"_"===h||!j&&this.isNumber(h)},g.prototype.isNumber=function(h){return"0"<=h&&"9">=h},g.prototype.isLiteralString=function(h){return"\""===h||"'"===h},g.prototype.isMultiline=function(h,j){var k=this.langObj.valueForKeyPath("comment.begin_multiline"),m=this.langObj.valueForKeyPath("comment.end_multiline"),n=this.langObj.default.color;if(void 0!==k&&this.startsWith(k,h,j))return void 0!==this.langObj.valueForKeyPath("comment.color")&&(n=this.langObj.comment.color),void 0===m&&(m=""),this.multilineObj={active:!0,color:n,begin_token:k,end_token:m},!0;var p=!0,q=this;return this.langObj.group.every(function(r){return void 0!==r.multiline&&(void 0!==r.color&&(n=r.color),r.multiline.every(function(s){var t=s.valueForKeyPath("begin"),u=s.valueForKeyPath("end");return void 0===t||(q.startsWith(t,h,j)?(void 0===u&&(u=""),q.multilineObj={active:!0,color:n,begin_token:t,end_token:u},p=!1,!1):p)})),p}),!p},g.prototype.startsWith=function(h,j,k){return void 0!==h&&j.substring(k,j.length).startsWith(h)},g.prototype.matchRegex=function(h,j,k,m){if(void 0===h)return null;h.startsWith("^")||(h="^"+h),void 0===j&&(j="");var n=new RegExp(h,j);return k.substring(m,k.length).match(n)},g.prototype.getId=function(h,j,k){var m=j,n=h[j];for(j++;j'; 126 | }; 127 | 128 | highlighter.prototype.closeSpan = function() { 129 | return ''; 130 | }; 131 | 132 | highlighter.prototype.getSpan = function (value, color) { 133 | return this.openSpan(color) + value + this.closeSpan(); 134 | }; 135 | 136 | highlighter.prototype.isId = function(char, beginningId) { 137 | return (char >= 'a' && char <= 'z') 138 | || (char >= 'A' && char <= 'Z') 139 | || char === '_' 140 | || (!beginningId && this.isNumber(char)); 141 | }; 142 | 143 | highlighter.prototype.isNumber = function(char) { 144 | return char >= '0' && char <= '9'; 145 | }; 146 | 147 | highlighter.prototype.isLiteralString = function(char) { 148 | return char === "\"" || char === "'"; 149 | }; 150 | 151 | highlighter.prototype.isMultiline = function(code, idx) { 152 | var begin_multiline_comment = this.langObj.valueForKeyPath('comment.begin_multiline'); 153 | var end_multiline_comment = this.langObj.valueForKeyPath('comment.end_multiline'); 154 | 155 | var color_multiline = this.langObj.default.color; 156 | 157 | if (begin_multiline_comment !== undefined && 158 | this.startsWith(begin_multiline_comment, code, idx)) { 159 | if (this.langObj.valueForKeyPath('comment.color') !== undefined) { 160 | color_multiline = this.langObj.comment.color; 161 | } 162 | 163 | if (end_multiline_comment === undefined) { 164 | end_multiline_comment = ""; 165 | } 166 | 167 | this.multilineObj = { 168 | active: true, 169 | color: color_multiline, 170 | begin_token: begin_multiline_comment, 171 | end_token: end_multiline_comment 172 | }; 173 | 174 | return true; 175 | } 176 | 177 | var still_looking_for = true; 178 | var highlighter = this; 179 | // check if it is operator or match any multiline definition 180 | this.langObj.group.every(function(obj){ 181 | if (obj.multiline !== undefined) { 182 | if (obj.color !== undefined) { 183 | color_multiline = obj.color; 184 | } 185 | 186 | obj.multiline.every(function(multiline_obj){ 187 | var begin_multiline = multiline_obj.valueForKeyPath('begin'); 188 | var end_multiline = multiline_obj.valueForKeyPath('end'); 189 | 190 | if (begin_multiline === undefined) { 191 | return true; 192 | } 193 | 194 | if (highlighter.startsWith(begin_multiline, code, idx)) { 195 | if (end_multiline === undefined) { 196 | end_multiline = ""; 197 | } 198 | 199 | highlighter.multilineObj = { 200 | active: true, 201 | color: color_multiline, 202 | begin_token: begin_multiline, 203 | end_token: end_multiline 204 | }; 205 | 206 | still_looking_for = false; 207 | return false; 208 | } 209 | 210 | return still_looking_for; 211 | }); 212 | } 213 | 214 | return still_looking_for; 215 | }); 216 | 217 | return !still_looking_for; 218 | }; 219 | 220 | highlighter.prototype.startsWith = function(lexeme, code, idx) { 221 | return lexeme !== undefined && 222 | code.substring(idx, code.length).startsWith(lexeme); 223 | }; 224 | 225 | highlighter.prototype.matchRegex = function(regex, modifier, code, idx) { 226 | if (regex === undefined) { 227 | return null; 228 | } 229 | 230 | if (!regex.startsWith("^")) { 231 | regex = "^" + regex; 232 | } 233 | 234 | if (modifier === undefined) { 235 | modifier = ""; 236 | } 237 | 238 | var regex_obj = new RegExp(regex, modifier); 239 | return code.substring(idx, code.length).match(regex_obj); 240 | }; 241 | 242 | highlighter.prototype.getId = function(code, idx, callback) { 243 | var pos_id = idx; 244 | var id = code[idx]; 245 | idx++; 246 | while(idx < code.length && this.isId(code[idx], false)) { 247 | id += code[idx]; 248 | idx++; 249 | } 250 | 251 | callback(id, pos_id, this.langObj); 252 | }; 253 | 254 | highlighter.prototype.getNumber = function(code, idx, callback) { 255 | var pos_id = idx; 256 | var number = code[idx]; 257 | idx++; 258 | var next_int = this.getNextInt(code, idx); 259 | number += next_int.value; 260 | idx = next_int.idx; 261 | 262 | if (idx + 1 < code.length 263 | && code[idx] === '.' 264 | && this.isNumber(code[idx+1])) { 265 | number += code[idx]; 266 | number += code[idx+1]; 267 | idx += 2; 268 | next_int = this.getNextInt(code, idx); 269 | number += next_int.value; 270 | idx = next_int.idx; 271 | } 272 | 273 | if (idx < code.length && code[idx] === 'e') { 274 | if (idx + 1 < code.length && this.isNumber(code[idx+1])) { 275 | number += code[idx]; 276 | number += code[idx+1]; 277 | idx += 2; 278 | next_int = this.getNextInt(code, idx); 279 | number += next_int.value; 280 | idx = next_int.idx; 281 | } else if (idx + 2 < code.length 282 | && (code[idx+1] === '+' || code[idx+1] === '-') 283 | && this.isNumber(code[idx+2])) { 284 | number += code[idx]; 285 | number += code[idx+1]; 286 | number += code[idx+2]; 287 | idx += 3; 288 | next_int = this.getNextInt(code, idx); 289 | number += next_int.value; 290 | idx = next_int.idx; 291 | } 292 | } 293 | 294 | callback(number, pos_id, this.langObj); 295 | }; 296 | 297 | highlighter.prototype.getNextInt = function(code, idx) { 298 | var number = ""; 299 | while (idx < code.length && this.isNumber(code[idx])) { 300 | number += code[idx]; 301 | idx++; 302 | } 303 | 304 | return { value: number, idx: idx }; 305 | }; 306 | 307 | highlighter.prototype.getLiteralString = function(code, idx, callback) { 308 | var pos_str = idx; 309 | var str = code[idx++]; 310 | while (idx < code.length && code[idx] !== code[pos_str]) { 311 | str += code[idx++]; 312 | } 313 | 314 | if (!code[idx]) { 315 | return false; 316 | } 317 | 318 | str += code[idx]; 319 | 320 | callback(str, pos_str, this.langObj); 321 | }; 322 | 323 | highlighter.prototype.getMultiline = function(obj, code, idx, callback) { 324 | var pos = idx; 325 | idx += obj.begin_token.length; 326 | var still_looking_for = true; 327 | var lexeme = code.substring(pos, idx); 328 | while(idx < code.length && 329 | !code.substring(idx, code.length).startsWith(obj.end_token)) { 330 | lexeme += code[idx]; 331 | idx++; 332 | } 333 | 334 | if (idx < code.length) { 335 | lexeme += obj.end_token; 336 | still_looking_for = false; 337 | } 338 | 339 | callback(lexeme, pos, still_looking_for, this); 340 | }; 341 | 342 | highlighter.prototype.lexer = function(code) { 343 | var single_line_comment = this.langObj.valueForKeyPath('comment.single_line'); 344 | 345 | var tokens = Array(); 346 | var i = 0; 347 | while (i < code.length) { 348 | if (code[i] === ' ' || code[i] === '\t' || code[i] === '\n'){ 349 | i++; 350 | continue; 351 | } 352 | else if (this.multilineObj.active || this.isMultiline(code, i)) { 353 | this.multilineObj.active = true; 354 | this.getMultiline( 355 | this.multilineObj, 356 | code, 357 | i, 358 | function(mult, pos, lookingFor, highlighter) { 359 | highlighter.multilineObj.active = lookingFor; 360 | // reset begin token 361 | highlighter.multilineObj.begin_token = ""; 362 | var color = highlighter.multilineObj.color; 363 | 364 | tokens.push(new Token(mult, 365 | pos, mult.length, color)); 366 | i += mult.length; 367 | } 368 | ); 369 | } else if (this.startsWith(single_line_comment, code, i)) { 370 | var comment = code.substring(i, code.length); 371 | var color_comment = this.langObj.default.color; 372 | if (this.langObj.valueForKeyPath('comment.color') !== undefined) { 373 | color_comment = this.langObj.comment.color; 374 | } 375 | 376 | tokens.push(new Token(comment, i, comment.length, color_comment)); 377 | i += comment.length; 378 | } else if (this.isId(code[i], true)) { 379 | this.getId(code, i, function(id, pos, langObj){ 380 | var color_id = langObj.default.color; 381 | var not_found = true; 382 | langObj.group.every(function(keys) { 383 | if (keys.keywords !== undefined) { 384 | keys.keywords.every(function(keyObj) { 385 | if (keyObj.valueOf() === id.valueOf()) { 386 | color_id = keys.color; 387 | not_found = false; 388 | return false; 389 | } 390 | 391 | return true; 392 | }); 393 | } 394 | 395 | // false stops the "loop" 396 | return not_found; 397 | }); 398 | 399 | if (not_found && langObj.valueForKeyPath('identifier.color') !== undefined) { 400 | color_id = langObj.identifier.color; 401 | } 402 | 403 | tokens.push(new Token(id, pos, id.length, color_id)); 404 | i += id.length; 405 | }); 406 | } else if (this.isLiteralString(code[i]) 407 | && this.getLiteralString(code, i, function(str, pos, langObj){ 408 | var color_string = langObj.default.color; 409 | if (langObj.valueForKeyPath('string.color') !== undefined) { 410 | color_string = langObj.string.color; 411 | } 412 | 413 | tokens.push(new Token(str, pos, str.length, color_string)); 414 | i += str.length; 415 | })){ 416 | /*do nothing*/ 417 | } else if (this.isNumber(code[i])) { 418 | this.getNumber(code, i, function(number, pos, langObj){ 419 | var color_number = langObj.default.color; 420 | if (langObj.valueForKeyPath('number.color') !== undefined) { 421 | color_number = langObj.number.color; 422 | } 423 | 424 | tokens.push(new Token(number, 425 | pos, 426 | number.length, 427 | color_number)); 428 | i += number.length; 429 | }); 430 | } else { 431 | var still_looking_for = true; 432 | var highlighter = this; 433 | // check if it is operator or match any regex 434 | this.langObj.group.every(function(obj){ 435 | if (obj.operators !== undefined) { 436 | obj.operators.every(function(operator){ 437 | if (highlighter.startsWith(operator, 438 | code, 439 | i)) { 440 | tokens.push(new Token(operator, 441 | i, 442 | operator.length, 443 | obj.color)); 444 | i += operator.length; 445 | still_looking_for = false; 446 | return false; 447 | } 448 | 449 | return true; 450 | }); 451 | } 452 | 453 | if (still_looking_for && obj.regexes !== undefined) { 454 | obj.regexes.every(function(regexObj){ 455 | var matched_regex = highlighter.matchRegex( 456 | regexObj.regex, 457 | regexObj.modifier, 458 | code, 459 | i 460 | ); 461 | 462 | if (matched_regex !== null) { 463 | tokens.push(new Token(matched_regex[0], 464 | i, 465 | matched_regex[0].length, 466 | obj.color)); 467 | i += matched_regex[0].length; 468 | still_looking_for = false; 469 | return false; 470 | } 471 | 472 | return true; 473 | }); 474 | } 475 | 476 | return still_looking_for; 477 | }); 478 | 479 | // we don't have any grammar or group for this object, 480 | // so we ignore it and go to the next one 481 | if (still_looking_for) { 482 | i++; 483 | } 484 | } 485 | } 486 | 487 | return tokens; 488 | }; 489 | 490 | return highlighter; 491 | }()); 492 | 493 | return { 494 | Highlighter: Highlighter, 495 | Token: Token 496 | }; 497 | }()); 498 | 499 | exports.LinguistHighlighter = LinguistHighlighter; 500 | -------------------------------------------------------------------------------- /src/scripts/ling-loader.js: -------------------------------------------------------------------------------- 1 | var LinguistLoader = (function() { 2 | 'use strict'; 3 | 4 | const GITHUB_HOST = "github.com"; 5 | const GITHUB_URL_FILE = "blob/"; 6 | const GITHUB_RAW = "https://raw.githubusercontent.com"; 7 | const FILENAME = ".linguist.yml"; 8 | 9 | var linguistObj = null; 10 | var current_url = ""; 11 | 12 | var DownloadHelper = (function() { 13 | var DownloadHelper = function() { }; 14 | DownloadHelper.prototype.load = function(url, callback) { 15 | var xhr = new XMLHttpRequest(); 16 | xhr.open("GET", url, true); 17 | xhr.onload = function () { 18 | try { 19 | if (xhr.status === 404) { 20 | return; // ignore if file is not found 21 | } 22 | 23 | var resp = jsyaml.load(xhr.responseText); 24 | callback(resp); 25 | } catch(e) { 26 | console.error(e); 27 | } 28 | }; 29 | 30 | xhr.setRequestHeader("Content-Type", "*/*"); 31 | xhr.send(); 32 | }; 33 | 34 | return DownloadHelper; 35 | }()); 36 | 37 | var Utilities = (function() { 38 | var Utilities = function() { }; 39 | 40 | Utilities.prototype.tryMatchUrlExtension = function(url, objs, successCallback) { 41 | var keys = Object.keys(objs); 42 | var i = 0; 43 | var still_looking_for = true; 44 | var lang; 45 | 46 | // Don't make a function within a loop 47 | var extFunc = function(extension) { 48 | if (url.endsWith(extension)) { 49 | successCallback(lang); 50 | still_looking_for = false; 51 | return false; 52 | } 53 | 54 | return true; 55 | }; 56 | 57 | var langKey = null; 58 | while ((langKey = keys[i++]) && still_looking_for) { 59 | lang = objs[langKey]; 60 | lang.extensions.every(extFunc); 61 | } 62 | }; 63 | 64 | Utilities.prototype.isGithub = function(l) { 65 | return l.hostname === GITHUB_HOST && l.href.includes(GITHUB_URL_FILE); 66 | }; 67 | 68 | Utilities.prototype.getPossibleFilepath = function(l) { 69 | var uri = l.pathname.split(GITHUB_URL_FILE); 70 | return GITHUB_RAW + uri[0] + uri[1].split('/')[0] + '/' + FILENAME; 71 | }; 72 | 73 | Utilities.prototype.refresh = function(location, callback) { 74 | var new_url = location.href; 75 | 76 | if (new_url === current_url || !this.isGithub(location)) { 77 | return; 78 | } 79 | 80 | current_url = new_url; 81 | if (linguistObj === null) { 82 | linguistObj = { 83 | path: this.getPossibleFilepath(location) 84 | }; 85 | } 86 | 87 | setTimeout(function() { 88 | var downloadHelper = new DownloadHelper(); 89 | downloadHelper.load(linguistObj.path, function(objs){ 90 | this.tryMatchUrlExtension(current_url, objs, function(langObj){ 91 | var table = document.getElementsByClassName("blob-wrapper")[0] 92 | .getElementsByTagName("table")[0]; 93 | new LinguistHighlighter.Highlighter(langObj).draw(table); 94 | 95 | // callback for tests purposes only 96 | if (callback) { 97 | callback(langObj, table); 98 | } 99 | }); 100 | }.bind(this)); 101 | }.bind(this), 100); 102 | }; 103 | 104 | return Utilities; 105 | }()); 106 | 107 | return { 108 | Utilities: Utilities, 109 | DownloadHelper: DownloadHelper 110 | }; 111 | }()); 112 | 113 | exports.LinguistLoader = LinguistLoader; 114 | -------------------------------------------------------------------------------- /src/scripts/popup.js: -------------------------------------------------------------------------------- 1 | (function(doc, browser){ 2 | 'use strict'; 3 | 4 | function save_options() { 5 | var active = doc.getElementById('main-checkbox').checked; 6 | browser.storage.sync.set({ 'shouldWork': active }, function() {}); 7 | 8 | // refresh page 9 | browser.tabs.query({ active: true, currentWindow: true }, function(tabs) { 10 | var code = 'window.location.reload();'; 11 | browser.tabs.executeScript(tabs[0].id, { code: code }); 12 | }); 13 | } 14 | 15 | function restore_options() { 16 | browser.storage.sync.get('shouldWork', function(items) { 17 | var checkbox = doc.getElementById('main-checkbox'); 18 | if (checkbox) { 19 | checkbox.checked = items.shouldWork; 20 | } 21 | }); 22 | } 23 | 24 | doc.addEventListener('DOMContentLoaded', function() { 25 | restore_options(); 26 | doc.getElementById('main-checkbox').addEventListener('change', 27 | save_options, 28 | false 29 | ); 30 | }); 31 | }(document, chrome)); 32 | -------------------------------------------------------------------------------- /src/views/popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Linguist Unknown 5 | 6 | 7 | 8 | 9 |

Active

10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/mocha.opts: -------------------------------------------------------------------------------- 1 | --require should 2 | --require jsdom 3 | --require xmlhttprequest 4 | -R spec 5 | --ui bdd 6 | --recursive 7 | 8 | -------------------------------------------------------------------------------- /test/test-download.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | global.XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; 4 | global.jsyaml = require('../src/scripts-min/js-yaml.min.js'); 5 | var LinguistLoader = require('../src/scripts/ling-loader.js').LinguistLoader; 6 | 7 | describe('DownloadHelper', function () { 8 | it('should download and parse the YAML file properly', function (done) { 9 | var downloadHelper = new LinguistLoader.DownloadHelper(); 10 | downloadHelper.load("https://raw.githubusercontent.com/github-aux/linguist-unknown/chrome/.linguist.yml", function(objs){ 11 | objs.should.have.property('Brain').which.is.an.Object(); 12 | objs.should.have.property('C').which.is.an.Object(); 13 | objs.should.have.property('Brainfuck').which.is.an.Object(); 14 | objs.should.have.property('Test').which.is.an.Object(); 15 | 16 | objs.Brain.should.have.property('extensions'); 17 | objs.Brain.extensions.should.containDeep([".brain", ".br"]); 18 | objs.Brain.should.have.property('default'); 19 | objs.Brain.should.have.property('group'); 20 | objs.Brain.group.should.matchEach(function(obj) { 21 | obj.should.have.property('color'); 22 | obj.should.have.property('operators'); 23 | }); 24 | 25 | objs.Brainfuck.should.have.property('extensions'); 26 | objs.Brainfuck.extensions.should.containDeep([".bf"]); 27 | // We are testing Brainfuck without the default, thus, the test below was wrong 28 | // objs.Brainfuck.should.have.property('default'); 29 | objs.Brainfuck.should.have.property('group'); 30 | 31 | objs.C.should.have.property('extensions'); 32 | objs.C.extensions.should.containDeep([".c"]); 33 | objs.C.should.have.property('default'); 34 | objs.C.should.have.property('group'); 35 | 36 | objs.Test.should.have.property('extensions'); 37 | objs.Test.extensions.should.containDeep([".test"]); 38 | objs.Test.should.have.property('default'); 39 | objs.Test.should.have.property('group'); 40 | 41 | objs.Test.group.should.matchAny(function(obj) { 42 | obj.should.have.property('color'); 43 | obj.should.have.property('keywords'); 44 | }); 45 | 46 | objs.Test.group.should.matchAny(function(obj) { 47 | obj.should.have.property('color'); 48 | obj.should.have.property('regexes'); 49 | obj.regexes.should.matchEach(function(regexObj) { 50 | regexObj.should.have.property('regex'); 51 | regexObj.should.have.property('modifier'); 52 | }); 53 | }); 54 | 55 | done(); 56 | }); 57 | }); 58 | }); 59 | 60 | -------------------------------------------------------------------------------- /test/test-highlighter.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const jsdom = require("jsdom"); 4 | const { JSDOM } = jsdom; 5 | 6 | var should = require('should'); 7 | const { Highlighter } = require('../src/scripts/ling-highlighter.js').LinguistHighlighter; 8 | 9 | describe('HighLighter', function () { 10 | var highlighter = new Highlighter(); 11 | var langObjs = { 12 | C: 13 | { extensions: [ '.c' ], 14 | default: { color: '#24292e' } , 15 | identifier: { color: '#7b9c0e' }, 16 | number: { color: '#745296' }, 17 | string: { color: '#8B9EB7' }, 18 | comment: { 19 | color: '#969896', 20 | single_line: '//', 21 | begin_multiline: '/*', 22 | end_multiline: '*/' 23 | }, 24 | group: 25 | [ { color: '#a71d5d', 26 | keywords: [ 'include', 'void', 'int', 'float' ] }, 27 | { color: '#FF1053', 28 | keywords: [ 'printf', 'putchar', 'getchar' ] } ] }, 29 | Brain: 30 | { extensions: [ '.br', '.brain' ], 31 | default: { color: '#969896' }, 32 | group: 33 | [ { color: '#a71d5d', 34 | operators: [ '>', '<', '^', '<', '>' ] }, 35 | { color: '#333333', 36 | operators: [ '[', ']', '{', '}', '?', ':', ';', '!' ] }, 37 | { color: '#0086b3', 38 | operators: [ '+', '-', '*', '/', '%', '_' ] }, 39 | { color: '#795da3', operators: [ '.', ',', '$', '#' ] } ] }, 40 | Brainfuck: 41 | { extensions: [ '.bf' ], 42 | group: 43 | [ { color: '#BF211E', operators: [ '>', '<', '<', '>' ] }, 44 | { color: '#B744B8', operators: [ '[', ']' ] }, 45 | { color: '#69A197', operators: [ '+', '-' ] }, 46 | { color: '#F9DC5C', operators: [ '.', ',' ] } ] }, 47 | Test: 48 | { extensions: [ '.test' ], 49 | default: { color: '#FF8272' }, 50 | identifier: { color: '#FF99FF' }, 51 | number: { color: '#FF6600' }, 52 | string: { color: '#333300' }, 53 | comment: { 54 | color: '#969896', 55 | single_line: '//', 56 | begin_multiline: '/*', 57 | end_multiline: '*/' 58 | }, 59 | group: 60 | [ { color: '#72EEBB', 61 | keywords: [ 'for', 'while' ], 62 | regexes: [ { regex: '&(amp;)/[^/]*/([\\S]?)*', modifier: '' } ] }, 63 | { color: '#FF00FF', 64 | keywords: [ 'if', 'else', 'switch', 'let' ] } ] } 65 | }; 66 | 67 | describe('Span', function() { 68 | it('should get a partial span tag (opened) with color', function (done) { 69 | var span_tag = highlighter.openSpan("#FFFFFF"); 70 | span_tag.should.equal(""); 71 | done(); 72 | }); 73 | 74 | it('should get a partial span tag (closed)', function (done) { 75 | var span_tag = highlighter.closeSpan(); 76 | span_tag.should.equal(""); 77 | done(); 78 | }); 79 | 80 | it('should get a full span tag with value and color', function (done) { 81 | var span_tag = highlighter.getSpan("test", "#000000"); 82 | span_tag.should.equal("test"); 83 | done(); 84 | }); 85 | }); 86 | 87 | describe('Painting', function() { 88 | it('should create the right tokens according to the chosen language', function (done) { 89 | var tks1 = new Highlighter(langObjs.Brain).lexer("++ blah +#$ {!}"); 90 | tks1.should.containDeepOrdered([ 91 | { value: '+', pos: 0, size: 1, color: '#0086b3' }, 92 | { value: '+', pos: 1, size: 1, color: '#0086b3' }, 93 | { value: 'blah', pos: 3, size: 4, color: '#969896' }, 94 | { value: '+', pos: 8, size: 1, color: '#0086b3' }, 95 | { value: '#', pos: 9, size: 1, color: '#795da3' }, 96 | { value: '$', pos: 10, size: 1, color: '#795da3' }, 97 | { value: '{', pos: 12, size: 1, color: '#333333' }, 98 | { value: '!', pos: 13, size: 1, color: '#333333' }, 99 | { value: '}', pos: 14, size: 1, color: '#333333' } 100 | ]); 101 | 102 | var tks2 = new Highlighter(langObjs.Brainfuck).lexer("+[>+] blah blah blah"); 103 | tks2.should.containDeepOrdered([ 104 | { value: '+', pos: 0, size: 1, color: '#69A197' }, 105 | { value: '[', pos: 1, size: 1, color: '#B744B8' }, 106 | { value: '>', pos: 2, size: 1, color: '#BF211E' }, 107 | { value: '+', pos: 3, size: 1, color: '#69A197' }, 108 | { value: ']', pos: 4, size: 1, color: '#B744B8' }, 109 | { value: 'blah', pos: 6, size: 4, color: '#24292e' }, 110 | { value: 'blah', pos: 11, size: 4, color: '#24292e' }, 111 | { value: 'blah', pos: 16, size: 4, color: '#24292e' } 112 | ]); 113 | 114 | var tks3 = new Highlighter(langObjs.Test).lexer("/* comment */ ==== if huhdufd let fdjijfdf == !!!!! while for let for for for rfrereer ==="); 115 | tks3.should.containDeepOrdered([ 116 | { value: '/* comment */', pos: 0, size: 13, color: '#969896' }, 117 | { value: 'if', pos: 20, size: 2, color: '#FF00FF' }, 118 | { value: 'huhdufd', pos: 23, size: 7, color: '#FF99FF' }, 119 | { value: 'let', pos: 31, size: 3, color: '#FF00FF' }, 120 | { value: 'fdjijfdf', pos: 35, size: 8, color: '#FF99FF' }, 121 | { value: 'while', pos: 53, size: 5, color: '#72EEBB' }, 122 | { value: 'for', pos: 59, size: 3, color: '#72EEBB' }, 123 | { value: 'let', pos: 63, size: 3, color: '#FF00FF' }, 124 | { value: 'for', pos: 67, size: 3, color: '#72EEBB' }, 125 | { value: 'for', pos: 71, size: 3, color: '#72EEBB' }, 126 | { value: 'for', pos: 75, size: 3, color: '#72EEBB' }, 127 | { value: 'rfrereer', pos: 79, size: 8, color: '#FF99FF' } 128 | ]); 129 | 130 | var tks4 = new Highlighter(langObjs.Test).lexer("///* comment */ ==== if huhdufd let fdjijfdf == !!!!! while for let for for for rfrereer ==="); 131 | tks4.should.containDeepOrdered([{ 132 | value: '///* comment */ ==== if huhdufd let fdjijfdf == !!!!! while for let for for for rfrereer ===', 133 | pos: 0, 134 | size: 93, 135 | color: '#969896' 136 | }]); 137 | 138 | done(); 139 | }); 140 | 141 | it('should paint the tokens with spans', function(done) { 142 | var h = new Highlighter(langObjs.Test); 143 | var code = "/* comment */ ==== if huhdufd let fdjijfdf == !!!!! while for let for for for rfrereer ==="; 144 | var tks = h.lexer(code); 145 | h.paint(tks, code).should.equal('/* comment */ ==== if huhdufd let fdjijfdf == !!!!! while for let for for for rfrereer ==='); 146 | 147 | var h2 = new Highlighter(langObjs.C); 148 | var code2 = 'void b_debug(int idx, int *cells) {printf("Index Pointer: %d Value at Index Pointer: %d\n",idx,cells[idx]);'; 149 | var tks2 = h2.lexer(code2); 150 | h2.paint(tks2, code2).should.equal('void b_debug(int idx, int *cells) {printf("Index Pointer: %d Value at Index Pointer: %d\n",idx,cells[idx]);'); 151 | 152 | var h3 = new Highlighter(langObjs.Brain); 153 | var code3 = '++++>>>>{?Blah----:jaca;}#'; 154 | var tks3 = h3.lexer(code3); 155 | h3.paint(tks3, code3).should.equal('++++>>>>{?Blah----:jaca;}#'); 156 | done(); 157 | }); 158 | 159 | it('should draw on the table properly', function(done) { 160 | JSDOM.fromURL("https://github.com/github-aux/linguist-unknown/blob/chrome/examples/C/io.c").then(dom => { 161 | 162 | var o = Object.prototype; 163 | Object.defineProperty(o, "innerText", { 164 | get: function() { 165 | if (this.innerHTML === undefined) 166 | return ""; 167 | return this.innerHTML; 168 | }, 169 | set: function(value) { 170 | this.innerHTML = value; 171 | }, 172 | configurable: true 173 | }); 174 | 175 | global.document = dom.window.document.documentElement; 176 | var table = document.getElementsByClassName("blob-wrapper")[0] 177 | .getElementsByTagName("table")[0]; 178 | table.should.not.equal(null).and.should.not.equal(undefined); 179 | var cells = table.querySelectorAll('tbody td'); 180 | for (var i = 0; i < cells.length; i++) { 181 | var cell = cells[i]; 182 | if (cell.id.indexOf("LC") !== -1) { 183 | cell.innerText.should.not.containEql(' { 27 | 28 | var o = Object.prototype; 29 | Object.defineProperty(o, "innerText", { 30 | get: function() { 31 | if (this.innerHTML === undefined) 32 | return ""; 33 | return this.innerHTML; 34 | }, 35 | configurable: true 36 | }); 37 | 38 | global.document = dom.window.document.documentElement; 39 | // the comment below is a test for the innerText property 40 | /* var table = document.getElementsByClassName("blob-wrapper")[0] 41 | .getElementsByTagName("table")[0]; 42 | var cells = table.querySelectorAll('tbody td'); 43 | for (var i = 0; i < cells.length; i++) { 44 | var cell = cells[i]; 45 | if (cell.id.indexOf("LC") !== -1) { 46 | console.log(cell.innerText); // ignore GH spa 47 | } 48 | }*/ 49 | 50 | var location = { 51 | hostname: "github.com", 52 | href: "https://github.com/github-aux/linguist-unknown/blob/chrome/examples/Brain/human_jump.brain", 53 | pathname: "/github-aux/linguist-unknown/blob/chrome/examples/Brain/human_jump.brain" 54 | }; 55 | 56 | // check if it is not breaking 57 | utilities.refresh(location, function(langObj, table) { 58 | langObj.should.not.equal(null).and.should.not.equal(undefined); 59 | table.should.not.equal(null).and.should.not.equal(undefined); 60 | done(); 61 | }); 62 | }); 63 | }); 64 | }); 65 | }); 66 | 67 | --------------------------------------------------------------------------------