├── Procfile ├── .eslintignore ├── static ├── logo.png ├── robots.txt ├── favicon.ico ├── function-icons.png ├── hover-dropdown-tip.png ├── solarized_dark.css ├── index.html ├── application.css ├── application.min.js ├── application.js └── highlight.min.js ├── .gitignore ├── .dockerignore ├── docker-entrypoint.sh ├── about.md ├── docker-compose.yaml ├── .eslintrc.json ├── lib ├── key_generators │ ├── random.js │ ├── phonetic.js │ └── dictionary.js ├── document_stores │ ├── rethinkdb.js │ ├── amazon-s3.js │ ├── memcached.js │ ├── file.js │ ├── google-datastore.js │ ├── redis.js │ ├── postgres.js │ └── mongo.js └── document_handler.js ├── test ├── key_generators │ ├── random_spec.js │ ├── phonetic_spec.js │ └── dictionary_spec.js ├── document_handler_spec.js └── redis_document_store_spec.js ├── config.js ├── package.json ├── Dockerfile ├── docker-entrypoint.js ├── server.js └── README.md /Procfile: -------------------------------------------------------------------------------- 1 | web: node server.js 2 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | **/*.min.js 2 | config.js 3 | -------------------------------------------------------------------------------- /static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xditya/haste-server/master/static/logo.png -------------------------------------------------------------------------------- /static/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: /* 3 | Allow: /?okparam= 4 | Allow: /$ 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | npm-debug.log 2 | node_modules 3 | *.swp 4 | *.swo 5 | data 6 | *.DS_Store 7 | -------------------------------------------------------------------------------- /static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xditya/haste-server/master/static/favicon.ico -------------------------------------------------------------------------------- /static/function-icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xditya/haste-server/master/static/function-icons.png -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | .git 3 | npm-debug.log 4 | node_modules 5 | *.swp 6 | *.swo 7 | data 8 | *.DS_Store 9 | -------------------------------------------------------------------------------- /static/hover-dropdown-tip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xditya/haste-server/master/static/hover-dropdown-tip.png -------------------------------------------------------------------------------- /docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # We use this file to translate environmental variables to .env files used by the application 4 | 5 | set -e 6 | 7 | node ./docker-entrypoint.js > ./config.js 8 | 9 | exec "$@" 10 | -------------------------------------------------------------------------------- /about.md: -------------------------------------------------------------------------------- 1 | # About 2 | This is just a custom fork of hastebin-server. 3 | Credits to the original developers. 4 | 5 | ## Source 6 | 7 | Haste can easily be installed behind your network, and it's all open source! 8 | 9 | * [haste-client](https://github.com/seejohnrun/haste-client) 10 | * [haste-server](https://github.com/seejohnrun/haste-server) -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3.0' 2 | services: 3 | haste-server: 4 | build: . 5 | networks: 6 | - db-network 7 | environment: 8 | - STORAGE_TYPE=memcached 9 | - STORAGE_HOST=memcached 10 | - STORAGE_PORT=11211 11 | ports: 12 | - 7777:7777 13 | memcached: 14 | image: memcached:latest 15 | networks: 16 | - db-network 17 | 18 | networks: 19 | db-network: 20 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "es6": true, 4 | "node": true 5 | }, 6 | "extends": "eslint:recommended", 7 | "rules": { 8 | "indent": [ 9 | "error", 10 | 2 11 | ], 12 | "linebreak-style": [ 13 | "error", 14 | "unix" 15 | ], 16 | "quotes": [ 17 | "error", 18 | "single" 19 | ], 20 | "semi": [ 21 | "error", 22 | "always" 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/key_generators/random.js: -------------------------------------------------------------------------------- 1 | module.exports = class RandomKeyGenerator { 2 | 3 | // Initialize a new generator with the given keySpace 4 | constructor(options = {}) { 5 | this.keyspace = options.keyspace || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; 6 | } 7 | 8 | // Generate a key of the given length 9 | createKey(keyLength) { 10 | var text = ''; 11 | 12 | for (var i = 0; i < keyLength; i++) { 13 | const index = Math.floor(Math.random() * this.keyspace.length); 14 | text += this.keyspace.charAt(index); 15 | } 16 | 17 | return text; 18 | } 19 | 20 | }; 21 | -------------------------------------------------------------------------------- /test/key_generators/random_spec.js: -------------------------------------------------------------------------------- 1 | /* global describe, it */ 2 | 3 | const assert = require('assert'); 4 | 5 | const Generator = require('../../lib/key_generators/random'); 6 | 7 | describe('RandomKeyGenerator', () => { 8 | describe('randomKey', () => { 9 | it('should return a key of the proper length', () => { 10 | const gen = new Generator(); 11 | assert.equal(6, gen.createKey(6).length); 12 | }); 13 | 14 | it('should use a key from the given keyset if given', () => { 15 | const gen = new Generator({keyspace: 'A'}); 16 | assert.equal('AAAAAA', gen.createKey(6)); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "host": "0.0.0.0", 4 | "port": 7777, 5 | 6 | "keyLength": 10, 7 | 8 | "maxLength": 400000, 9 | 10 | "staticMaxAge": 86400, 11 | 12 | "recompressStaticAssets": true, 13 | 14 | "logging": [ 15 | { 16 | "level": "verbose", 17 | "type": "Console", 18 | "colorize": true 19 | } 20 | ], 21 | 22 | "keyGenerator": { 23 | "type": "phonetic" 24 | }, 25 | 26 | "rateLimits": { 27 | "categories": { 28 | "normal": { 29 | "totalRequests": 500, 30 | "every": 60000 31 | } 32 | } 33 | }, 34 | 35 | "storage": { 36 | "type": "file" 37 | }, 38 | 39 | "documents": { 40 | "about": "./about.md" 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /lib/key_generators/phonetic.js: -------------------------------------------------------------------------------- 1 | // Draws inspiration from pwgen and http://tools.arantius.com/password 2 | 3 | const randOf = (collection) => { 4 | return () => { 5 | return collection[Math.floor(Math.random() * collection.length)]; 6 | }; 7 | }; 8 | 9 | // Helper methods to get an random vowel or consonant 10 | const randVowel = randOf('aeiou'); 11 | const randConsonant = randOf('bcdfghjklmnpqrstvwxyz'); 12 | 13 | module.exports = class PhoneticKeyGenerator { 14 | 15 | // Generate a phonetic key of alternating consonant & vowel 16 | createKey(keyLength) { 17 | let text = ''; 18 | const start = Math.round(Math.random()); 19 | 20 | for (let i = 0; i < keyLength; i++) { 21 | text += (i % 2 == start) ? randConsonant() : randVowel(); 22 | } 23 | 24 | return text; 25 | } 26 | 27 | }; 28 | -------------------------------------------------------------------------------- /test/key_generators/phonetic_spec.js: -------------------------------------------------------------------------------- 1 | /* global describe, it */ 2 | 3 | const assert = require('assert'); 4 | 5 | const Generator = require('../../lib/key_generators/phonetic'); 6 | 7 | const vowels = 'aeiou'; 8 | const consonants = 'bcdfghjklmnpqrstvwxyz'; 9 | 10 | describe('RandomKeyGenerator', () => { 11 | describe('randomKey', () => { 12 | it('should return a key of the proper length', () => { 13 | const gen = new Generator(); 14 | assert.equal(6, gen.createKey(6).length); 15 | }); 16 | 17 | it('should alternate consonants and vowels', () => { 18 | const gen = new Generator(); 19 | 20 | const key = gen.createKey(3); 21 | 22 | assert.ok(consonants.includes(key[0])); 23 | assert.ok(consonants.includes(key[2])); 24 | assert.ok(vowels.includes(key[1])); 25 | }); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /test/document_handler_spec.js: -------------------------------------------------------------------------------- 1 | /* global describe, it */ 2 | 3 | var assert = require('assert'); 4 | 5 | var DocumentHandler = require('../lib/document_handler'); 6 | var Generator = require('../lib/key_generators/random'); 7 | 8 | describe('document_handler', function() { 9 | 10 | describe('randomKey', function() { 11 | 12 | it('should choose a key of the proper length', function() { 13 | var gen = new Generator(); 14 | var dh = new DocumentHandler({ keyLength: 6, keyGenerator: gen }); 15 | assert.equal(6, dh.acceptableKey().length); 16 | }); 17 | 18 | it('should choose a default key length', function() { 19 | var gen = new Generator(); 20 | var dh = new DocumentHandler({ keyGenerator: gen }); 21 | assert.equal(dh.keyLength, DocumentHandler.defaultKeyLength); 22 | }); 23 | 24 | }); 25 | 26 | }); 27 | -------------------------------------------------------------------------------- /lib/key_generators/dictionary.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | module.exports = class DictionaryGenerator { 4 | 5 | constructor(options, readyCallback) { 6 | // Check options format 7 | if (!options) throw Error('No options passed to generator'); 8 | if (!options.path) throw Error('No dictionary path specified in options'); 9 | 10 | // Load dictionary 11 | fs.readFile(options.path, 'utf8', (err, data) => { 12 | if (err) throw err; 13 | 14 | this.dictionary = data.split(/[\n\r]+/); 15 | 16 | if (readyCallback) readyCallback(); 17 | }); 18 | } 19 | 20 | // Generates a dictionary-based key, of keyLength words 21 | createKey(keyLength) { 22 | let text = ''; 23 | 24 | for (let i = 0; i < keyLength; i++) { 25 | const index = Math.floor(Math.random() * this.dictionary.length); 26 | text += this.dictionary[index]; 27 | } 28 | 29 | return text; 30 | } 31 | 32 | }; 33 | -------------------------------------------------------------------------------- /test/key_generators/dictionary_spec.js: -------------------------------------------------------------------------------- 1 | /* global describe, it */ 2 | 3 | const assert = require('assert'); 4 | 5 | const fs = require('fs'); 6 | 7 | const Generator = require('../../lib/key_generators/dictionary'); 8 | 9 | describe('RandomKeyGenerator', function() { 10 | describe('randomKey', function() { 11 | it('should throw an error if given no options', () => { 12 | assert.throws(() => { 13 | new Generator(); 14 | }, Error); 15 | }); 16 | 17 | it('should throw an error if given no path', () => { 18 | assert.throws(() => { 19 | new Generator({}); 20 | }, Error); 21 | }); 22 | 23 | it('should return a key of the proper number of words from the given dictionary', () => { 24 | const path = '/tmp/haste-server-test-dictionary'; 25 | const words = ['cat']; 26 | fs.writeFileSync(path, words.join('\n')); 27 | 28 | const gen = new Generator({path}, () => { 29 | assert.equal('catcatcat', gen.createKey(3)); 30 | }); 31 | }); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "haste", 3 | "version": "0.1.0", 4 | "private": true, 5 | "description": "Private Pastebin Server", 6 | "keywords": [ 7 | "paste", 8 | "pastebin" 9 | ], 10 | "author": { 11 | "name": "John Crepezzi", 12 | "email": "john.crepezzi@gmail.com", 13 | "url": "http://seejohncode.com/" 14 | }, 15 | "main": "haste", 16 | "dependencies": { 17 | "busboy": "0.2.4", 18 | "connect": "^3.7.0", 19 | "connect-ratelimit": "0.0.7", 20 | "connect-route": "0.1.5", 21 | "pg": "^8.0.0", 22 | "redis": "0.8.1", 23 | "redis-url": "0.1.0", 24 | "st": "^2.0.0", 25 | "uglify-js": "3.1.6", 26 | "winston": "^2.0.0" 27 | }, 28 | "devDependencies": { 29 | "mocha": "^8.1.3" 30 | }, 31 | "bundledDependencies": [], 32 | "bin": { 33 | "haste-server": "./server.js" 34 | }, 35 | "files": [ 36 | "server.js", 37 | "lib", 38 | "static" 39 | ], 40 | "directories": { 41 | "lib": "./lib" 42 | }, 43 | "scripts": { 44 | "start": "node server.js", 45 | "test": "mocha --recursive" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/document_stores/rethinkdb.js: -------------------------------------------------------------------------------- 1 | const crypto = require('crypto'); 2 | const rethink = require('rethinkdbdash'); 3 | const winston = require('winston'); 4 | 5 | const md5 = (str) => { 6 | const md5sum = crypto.createHash('md5'); 7 | md5sum.update(str); 8 | return md5sum.digest('hex'); 9 | }; 10 | 11 | class RethinkDBStore { 12 | constructor(options) { 13 | this.client = rethink({ 14 | silent: true, 15 | host: options.host || '127.0.0.1', 16 | port: options.port || 28015, 17 | db: options.db || 'haste', 18 | user: options.user || 'admin', 19 | password: options.password || '' 20 | }); 21 | } 22 | 23 | set(key, data, callback) { 24 | this.client.table('uploads').insert({ id: md5(key), data: data }).run((error) => { 25 | if (error) { 26 | callback(false); 27 | winston.error('failed to insert to table', error); 28 | return; 29 | } 30 | callback(true); 31 | }); 32 | } 33 | 34 | get(key, callback) { 35 | this.client.table('uploads').get(md5(key)).run((error, result) => { 36 | if (error || !result) { 37 | callback(false); 38 | if (error) winston.error('failed to insert to table', error); 39 | return; 40 | } 41 | callback(result.data); 42 | }); 43 | } 44 | } 45 | 46 | module.exports = RethinkDBStore; 47 | -------------------------------------------------------------------------------- /lib/document_stores/amazon-s3.js: -------------------------------------------------------------------------------- 1 | /*global require,module,process*/ 2 | 3 | var AWS = require('aws-sdk'); 4 | var winston = require('winston'); 5 | 6 | var AmazonS3DocumentStore = function(options) { 7 | this.expire = options.expire; 8 | this.bucket = options.bucket; 9 | this.client = new AWS.S3({region: options.region}); 10 | }; 11 | 12 | AmazonS3DocumentStore.prototype.get = function(key, callback, skipExpire) { 13 | var _this = this; 14 | 15 | var req = { 16 | Bucket: _this.bucket, 17 | Key: key 18 | }; 19 | 20 | _this.client.getObject(req, function(err, data) { 21 | if(err) { 22 | callback(false); 23 | } 24 | else { 25 | callback(data.Body.toString('utf-8')); 26 | if (_this.expire && !skipExpire) { 27 | winston.warn('amazon s3 store cannot set expirations on keys'); 28 | } 29 | } 30 | }); 31 | } 32 | 33 | AmazonS3DocumentStore.prototype.set = function(key, data, callback, skipExpire) { 34 | var _this = this; 35 | 36 | var req = { 37 | Bucket: _this.bucket, 38 | Key: key, 39 | Body: data, 40 | ContentType: 'text/plain' 41 | }; 42 | 43 | _this.client.putObject(req, function(err, data) { 44 | if (err) { 45 | callback(false); 46 | } 47 | else { 48 | callback(true); 49 | if (_this.expire && !skipExpire) { 50 | winston.warn('amazon s3 store cannot set expirations on keys'); 51 | } 52 | } 53 | }); 54 | } 55 | 56 | module.exports = AmazonS3DocumentStore; 57 | -------------------------------------------------------------------------------- /static/solarized_dark.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull 4 | 5 | */ 6 | 7 | .hljs { 8 | display: block; 9 | overflow-x: auto; 10 | padding: 0.5em; 11 | background: #002b36; 12 | color: #839496; 13 | } 14 | 15 | .hljs-comment, 16 | .hljs-quote { 17 | color: #586e75; 18 | } 19 | 20 | /* Solarized Green */ 21 | .hljs-keyword, 22 | .hljs-selector-tag, 23 | .hljs-addition { 24 | color: #859900; 25 | } 26 | 27 | /* Solarized Cyan */ 28 | .hljs-number, 29 | .hljs-string, 30 | .hljs-meta .hljs-meta-string, 31 | .hljs-literal, 32 | .hljs-doctag, 33 | .hljs-regexp { 34 | color: #2aa198; 35 | } 36 | 37 | /* Solarized Blue */ 38 | .hljs-title, 39 | .hljs-section, 40 | .hljs-name, 41 | .hljs-selector-id, 42 | .hljs-selector-class { 43 | color: #268bd2; 44 | } 45 | 46 | /* Solarized Yellow */ 47 | .hljs-attribute, 48 | .hljs-attr, 49 | .hljs-variable, 50 | .hljs-template-variable, 51 | .hljs-class .hljs-title, 52 | .hljs-type { 53 | color: #b58900; 54 | } 55 | 56 | /* Solarized Orange */ 57 | .hljs-symbol, 58 | .hljs-bullet, 59 | .hljs-subst, 60 | .hljs-meta, 61 | .hljs-meta .hljs-keyword, 62 | .hljs-selector-attr, 63 | .hljs-selector-pseudo, 64 | .hljs-link { 65 | color: #cb4b16; 66 | } 67 | 68 | /* Solarized Red */ 69 | .hljs-built_in, 70 | .hljs-deletion { 71 | color: #dc322f; 72 | } 73 | 74 | .hljs-formula { 75 | background: #073642; 76 | } 77 | 78 | .hljs-emphasis { 79 | font-style: italic; 80 | } 81 | 82 | .hljs-strong { 83 | font-weight: bold; 84 | } 85 | -------------------------------------------------------------------------------- /lib/document_stores/memcached.js: -------------------------------------------------------------------------------- 1 | const memcached = require('memcached'); 2 | const winston = require('winston'); 3 | 4 | class MemcachedDocumentStore { 5 | 6 | // Create a new store with options 7 | constructor(options) { 8 | this.expire = options.expire; 9 | 10 | const host = options.host || '127.0.0.1'; 11 | const port = options.port || 11211; 12 | const url = `${host}:${port}`; 13 | this.connect(url); 14 | } 15 | 16 | // Create a connection 17 | connect(url) { 18 | this.client = new memcached(url); 19 | 20 | winston.info(`connecting to memcached on ${url}`); 21 | 22 | this.client.on('failure', function(error) { 23 | winston.info('error connecting to memcached', {error}); 24 | }); 25 | } 26 | 27 | // Save file in a key 28 | set(key, data, callback, skipExpire) { 29 | this.client.set(key, data, skipExpire ? 0 : this.expire || 0, (error) => { 30 | callback(!error); 31 | }); 32 | } 33 | 34 | // Get a file from a key 35 | get(key, callback, skipExpire) { 36 | this.client.get(key, (error, data) => { 37 | const value = error ? false : data; 38 | 39 | callback(value); 40 | 41 | // Update the key so that the expiration is pushed forward 42 | if (value && !skipExpire) { 43 | this.set(key, data, (updateSucceeded) => { 44 | if (!updateSucceeded) { 45 | winston.error('failed to update expiration on GET', {key}); 46 | } 47 | }, skipExpire); 48 | } 49 | }); 50 | } 51 | 52 | } 53 | 54 | module.exports = MemcachedDocumentStore; 55 | -------------------------------------------------------------------------------- /test/redis_document_store_spec.js: -------------------------------------------------------------------------------- 1 | /* global it, describe, afterEach */ 2 | 3 | var assert = require('assert'); 4 | 5 | var winston = require('winston'); 6 | winston.remove(winston.transports.Console); 7 | 8 | var RedisDocumentStore = require('../lib/document_stores/redis'); 9 | 10 | describe('redis_document_store', function() { 11 | 12 | /* reconnect to redis on each test */ 13 | afterEach(function() { 14 | if (RedisDocumentStore.client) { 15 | RedisDocumentStore.client.quit(); 16 | RedisDocumentStore.client = false; 17 | } 18 | }); 19 | 20 | describe('set', function() { 21 | 22 | it('should be able to set a key and have an expiration set', function(done) { 23 | var store = new RedisDocumentStore({ expire: 10 }); 24 | store.set('hello1', 'world', function() { 25 | RedisDocumentStore.client.ttl('hello1', function(err, res) { 26 | assert.ok(res > 1); 27 | done(); 28 | }); 29 | }); 30 | }); 31 | 32 | it('should not set an expiration when told not to', function(done) { 33 | var store = new RedisDocumentStore({ expire: 10 }); 34 | store.set('hello2', 'world', function() { 35 | RedisDocumentStore.client.ttl('hello2', function(err, res) { 36 | assert.equal(-1, res); 37 | done(); 38 | }); 39 | }, true); 40 | }); 41 | 42 | it('should not set an expiration when expiration is off', function(done) { 43 | var store = new RedisDocumentStore({ expire: false }); 44 | store.set('hello3', 'world', function() { 45 | RedisDocumentStore.client.ttl('hello3', function(err, res) { 46 | assert.equal(-1, res); 47 | done(); 48 | }); 49 | }); 50 | }); 51 | 52 | }); 53 | 54 | }); 55 | -------------------------------------------------------------------------------- /lib/document_stores/file.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var crypto = require('crypto'); 3 | 4 | var winston = require('winston'); 5 | 6 | // For storing in files 7 | // options[type] = file 8 | // options[path] - Where to store 9 | 10 | var FileDocumentStore = function(options) { 11 | this.basePath = options.path || './data'; 12 | this.expire = options.expire; 13 | }; 14 | 15 | // Generate md5 of a string 16 | FileDocumentStore.md5 = function(str) { 17 | var md5sum = crypto.createHash('md5'); 18 | md5sum.update(str); 19 | return md5sum.digest('hex'); 20 | }; 21 | 22 | // Save data in a file, key as md5 - since we don't know what we could 23 | // be passed here 24 | FileDocumentStore.prototype.set = function(key, data, callback, skipExpire) { 25 | try { 26 | var _this = this; 27 | fs.mkdir(this.basePath, '700', function() { 28 | var fn = _this.basePath + '/' + FileDocumentStore.md5(key); 29 | fs.writeFile(fn, data, 'utf8', function(err) { 30 | if (err) { 31 | callback(false); 32 | } 33 | else { 34 | callback(true); 35 | if (_this.expire && !skipExpire) { 36 | winston.warn('file store cannot set expirations on keys'); 37 | } 38 | } 39 | }); 40 | }); 41 | } catch(err) { 42 | callback(false); 43 | } 44 | }; 45 | 46 | // Get data from a file from key 47 | FileDocumentStore.prototype.get = function(key, callback, skipExpire) { 48 | var _this = this; 49 | var fn = this.basePath + '/' + FileDocumentStore.md5(key); 50 | fs.readFile(fn, 'utf8', function(err, data) { 51 | if (err) { 52 | callback(false); 53 | } 54 | else { 55 | callback(data); 56 | if (_this.expire && !skipExpire) { 57 | winston.warn('file store cannot set expirations on keys'); 58 | } 59 | } 60 | }); 61 | }; 62 | 63 | module.exports = FileDocumentStore; 64 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:14.8.0-stretch 2 | 3 | RUN mkdir -p /usr/src/app && \ 4 | chown node:node /usr/src/app 5 | 6 | USER node:node 7 | 8 | WORKDIR /usr/src/app 9 | 10 | COPY --chown=node:node . . 11 | 12 | RUN npm install && \ 13 | npm install redis@0.8.1 && \ 14 | npm install pg@4.1.1 && \ 15 | npm install memcached@2.2.2 && \ 16 | npm install aws-sdk@2.738.0 && \ 17 | npm install rethinkdbdash@2.3.31 18 | 19 | ENV STORAGE_TYPE=memcached \ 20 | STORAGE_HOST=127.0.0.1 \ 21 | STORAGE_PORT=11211\ 22 | STORAGE_EXPIRE_SECONDS=2592000\ 23 | STORAGE_DB=2 \ 24 | STORAGE_AWS_BUCKET= \ 25 | STORAGE_AWS_REGION= \ 26 | STORAGE_USENAME= \ 27 | STORAGE_PASSWORD= \ 28 | STORAGE_FILEPATH= 29 | 30 | ENV LOGGING_LEVEL=verbose \ 31 | LOGGING_TYPE=Console \ 32 | LOGGING_COLORIZE=true 33 | 34 | ENV HOST=0.0.0.0\ 35 | PORT=7777\ 36 | KEY_LENGTH=10\ 37 | MAX_LENGTH=400000\ 38 | STATIC_MAX_AGE=86400\ 39 | RECOMPRESS_STATIC_ASSETS=true 40 | 41 | ENV KEYGENERATOR_TYPE=phonetic \ 42 | KEYGENERATOR_KEYSPACE= 43 | 44 | ENV RATELIMITS_NORMAL_TOTAL_REQUESTS=500\ 45 | RATELIMITS_NORMAL_EVERY_MILLISECONDS=60000 \ 46 | RATELIMITS_WHITELIST_TOTAL_REQUESTS= \ 47 | RATELIMITS_WHITELIST_EVERY_MILLISECONDS= \ 48 | # comma separated list for the whitelisted \ 49 | RATELIMITS_WHITELIST=example1.whitelist,example2.whitelist \ 50 | \ 51 | RATELIMITS_BLACKLIST_TOTAL_REQUESTS= \ 52 | RATELIMITS_BLACKLIST_EVERY_MILLISECONDS= \ 53 | # comma separated list for the blacklisted \ 54 | RATELIMITS_BLACKLIST=example1.blacklist,example2.blacklist 55 | ENV DOCUMENTS=about=./about.md 56 | 57 | EXPOSE ${PORT} 58 | STOPSIGNAL SIGINT 59 | ENTRYPOINT [ "bash", "docker-entrypoint.sh" ] 60 | 61 | HEALTHCHECK --interval=30s --timeout=30s --start-period=5s \ 62 | --retries=3 CMD [ "sh", "-c", "echo -n 'curl localhost:7777... '; \ 63 | (\ 64 | curl -sf localhost:7777 > /dev/null\ 65 | ) && echo OK || (\ 66 | echo Fail && exit 2\ 67 | )"] 68 | CMD ["npm", "start"] 69 | -------------------------------------------------------------------------------- /static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | hastebin 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
45 | 46 |
47 | 48 |
49 |
50 | 51 | 52 | 53 | 54 | 55 |
56 | 60 |
61 | 62 |
63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /lib/document_stores/google-datastore.js: -------------------------------------------------------------------------------- 1 | /*global require,module,process*/ 2 | 3 | const Datastore = require('@google-cloud/datastore'); 4 | const winston = require('winston'); 5 | 6 | class GoogleDatastoreDocumentStore { 7 | 8 | // Create a new store with options 9 | constructor(options) { 10 | this.kind = "Haste"; 11 | this.expire = options.expire; 12 | this.datastore = new Datastore(); 13 | } 14 | 15 | // Save file in a key 16 | set(key, data, callback, skipExpire) { 17 | var expireTime = (skipExpire || this.expire === undefined) ? null : new Date(Date.now() + this.expire * 1000); 18 | 19 | var taskKey = this.datastore.key([this.kind, key]) 20 | var task = { 21 | key: taskKey, 22 | data: [ 23 | { 24 | name: 'value', 25 | value: data, 26 | excludeFromIndexes: true 27 | }, 28 | { 29 | name: 'expiration', 30 | value: expireTime 31 | } 32 | ] 33 | }; 34 | 35 | this.datastore.insert(task).then(() => { 36 | callback(true); 37 | }) 38 | .catch(err => { 39 | callback(false); 40 | }); 41 | } 42 | 43 | // Get a file from a key 44 | get(key, callback, skipExpire) { 45 | var taskKey = this.datastore.key([this.kind, key]) 46 | 47 | this.datastore.get(taskKey).then((entity) => { 48 | if (skipExpire || entity[0]["expiration"] == null) { 49 | callback(entity[0]["value"]); 50 | } 51 | else { 52 | // check for expiry 53 | if (entity[0]["expiration"] < new Date()) { 54 | winston.info("document expired", {key: key, expiration: entity[0]["expiration"], check: new Date(null)}); 55 | callback(false); 56 | } 57 | else { 58 | // update expiry 59 | var task = { 60 | key: taskKey, 61 | data: [ 62 | { 63 | name: 'value', 64 | value: entity[0]["value"], 65 | excludeFromIndexes: true 66 | }, 67 | { 68 | name: 'expiration', 69 | value: new Date(Date.now() + this.expire * 1000) 70 | } 71 | ] 72 | }; 73 | this.datastore.update(task).then(() => { 74 | }) 75 | .catch(err => { 76 | winston.error("failed to update expiration", {error: err}); 77 | }); 78 | callback(entity[0]["value"]); 79 | } 80 | } 81 | }) 82 | .catch(err => { 83 | winston.error("Error retrieving value from Google Datastore", {error: err}); 84 | callback(false); 85 | }); 86 | } 87 | } 88 | 89 | module.exports = GoogleDatastoreDocumentStore; 90 | -------------------------------------------------------------------------------- /lib/document_stores/redis.js: -------------------------------------------------------------------------------- 1 | var redis = require('redis'); 2 | var winston = require('winston'); 3 | 4 | // For storing in redis 5 | // options[type] = redis 6 | // options[host] - The host to connect to (default localhost) 7 | // options[port] - The port to connect to (default 5379) 8 | // options[db] - The db to use (default 0) 9 | // options[expire] - The time to live for each key set (default never) 10 | 11 | var RedisDocumentStore = function(options, client) { 12 | this.expire = options.expire; 13 | if (client) { 14 | winston.info('using predefined redis client'); 15 | RedisDocumentStore.client = client; 16 | } else if (!RedisDocumentStore.client) { 17 | winston.info('configuring redis'); 18 | RedisDocumentStore.connect(options); 19 | } 20 | }; 21 | 22 | // Create a connection according to config 23 | RedisDocumentStore.connect = function(options) { 24 | var host = options.host || '127.0.0.1'; 25 | var port = options.port || 6379; 26 | var index = options.db || 0; 27 | RedisDocumentStore.client = redis.createClient(port, host); 28 | // authenticate if password is provided 29 | if (options.password) { 30 | RedisDocumentStore.client.auth(options.password); 31 | } 32 | 33 | RedisDocumentStore.client.on('error', function(err) { 34 | winston.error('redis disconnected', err); 35 | }); 36 | 37 | RedisDocumentStore.client.select(index, function(err) { 38 | if (err) { 39 | winston.error( 40 | 'error connecting to redis index ' + index, 41 | { error: err } 42 | ); 43 | process.exit(1); 44 | } 45 | else { 46 | winston.info('connected to redis on ' + host + ':' + port + '/' + index); 47 | } 48 | }); 49 | }; 50 | 51 | // Save file in a key 52 | RedisDocumentStore.prototype.set = function(key, data, callback, skipExpire) { 53 | var _this = this; 54 | RedisDocumentStore.client.set(key, data, function(err) { 55 | if (err) { 56 | callback(false); 57 | } 58 | else { 59 | if (!skipExpire) { 60 | _this.setExpiration(key); 61 | } 62 | callback(true); 63 | } 64 | }); 65 | }; 66 | 67 | // Expire a key in expire time if set 68 | RedisDocumentStore.prototype.setExpiration = function(key) { 69 | if (this.expire) { 70 | RedisDocumentStore.client.expire(key, this.expire, function(err) { 71 | if (err) { 72 | winston.error('failed to set expiry on key: ' + key); 73 | } 74 | }); 75 | } 76 | }; 77 | 78 | // Get a file from a key 79 | RedisDocumentStore.prototype.get = function(key, callback, skipExpire) { 80 | var _this = this; 81 | RedisDocumentStore.client.get(key, function(err, reply) { 82 | if (!err && !skipExpire) { 83 | _this.setExpiration(key); 84 | } 85 | callback(err ? false : reply); 86 | }); 87 | }; 88 | 89 | module.exports = RedisDocumentStore; 90 | -------------------------------------------------------------------------------- /lib/document_stores/postgres.js: -------------------------------------------------------------------------------- 1 | /*global require,module,process*/ 2 | 3 | var winston = require('winston'); 4 | const {Pool} = require('pg'); 5 | 6 | // create table entries (id serial primary key, key varchar(255) not null, value text not null, expiration int, unique(key)); 7 | 8 | // A postgres document store 9 | var PostgresDocumentStore = function (options) { 10 | this.expireJS = options.expire; 11 | 12 | const connectionString = process.env.DATABASE_URL || options.connectionUrl; 13 | this.pool = new Pool({connectionString}); 14 | }; 15 | 16 | PostgresDocumentStore.prototype = { 17 | 18 | // Set a given key 19 | set: function (key, data, callback, skipExpire) { 20 | var now = Math.floor(new Date().getTime() / 1000); 21 | var that = this; 22 | this.safeConnect(function (err, client, done) { 23 | if (err) { return callback(false); } 24 | client.query('INSERT INTO entries (key, value, expiration) VALUES ($1, $2, $3)', [ 25 | key, 26 | data, 27 | that.expireJS && !skipExpire ? that.expireJS + now : null 28 | ], function (err) { 29 | if (err) { 30 | winston.error('error persisting value to postgres', { error: err }); 31 | return callback(false); 32 | } 33 | callback(true); 34 | done(); 35 | }); 36 | }); 37 | }, 38 | 39 | // Get a given key's data 40 | get: function (key, callback, skipExpire) { 41 | var now = Math.floor(new Date().getTime() / 1000); 42 | var that = this; 43 | this.safeConnect(function (err, client, done) { 44 | if (err) { return callback(false); } 45 | client.query('SELECT id,value,expiration from entries where KEY = $1 and (expiration IS NULL or expiration > $2)', [key, now], function (err, result) { 46 | if (err) { 47 | winston.error('error retrieving value from postgres', { error: err }); 48 | return callback(false); 49 | } 50 | callback(result.rows.length ? result.rows[0].value : false); 51 | if (result.rows.length && that.expireJS && !skipExpire) { 52 | client.query('UPDATE entries SET expiration = $1 WHERE ID = $2', [ 53 | that.expireJS + now, 54 | result.rows[0].id 55 | ], function (err) { 56 | if (!err) { 57 | done(); 58 | } 59 | }); 60 | } else { 61 | done(); 62 | } 63 | }); 64 | }); 65 | }, 66 | 67 | // A connection wrapper 68 | safeConnect: function (callback) { 69 | this.pool.connect((error, client, done) => { 70 | if (error) { 71 | winston.error('error connecting to postgres', {error}); 72 | callback(error); 73 | } else { 74 | callback(undefined, client, done); 75 | } 76 | }); 77 | } 78 | }; 79 | 80 | module.exports = PostgresDocumentStore; 81 | -------------------------------------------------------------------------------- /lib/document_stores/mongo.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var MongoClient = require('mongodb').MongoClient, 4 | winston = require('winston'); 5 | 6 | var MongoDocumentStore = function (options) { 7 | this.expire = options.expire; 8 | this.connectionUrl = process.env.DATABASE_URl || options.connectionUrl; 9 | }; 10 | 11 | MongoDocumentStore.prototype.set = function (key, data, callback, skipExpire) { 12 | var now = Math.floor(new Date().getTime() / 1000), 13 | that = this; 14 | 15 | this.safeConnect(function (err, db) { 16 | if (err) 17 | return callback(false); 18 | 19 | db.collection('entries').update({ 20 | 'entry_id': key, 21 | $or: [ 22 | { expiration: -1 }, 23 | { expiration: { $gt: now } } 24 | ] 25 | }, { 26 | 'entry_id': key, 27 | 'value': data, 28 | 'expiration': that.expire && !skipExpire ? that.expire + now : -1 29 | }, { 30 | upsert: true 31 | }, function (err, existing) { 32 | if (err) { 33 | winston.error('error persisting value to mongodb', { error: err }); 34 | return callback(false); 35 | } 36 | 37 | callback(true); 38 | }); 39 | }); 40 | }; 41 | 42 | MongoDocumentStore.prototype.get = function (key, callback, skipExpire) { 43 | var now = Math.floor(new Date().getTime() / 1000), 44 | that = this; 45 | 46 | this.safeConnect(function (err, db) { 47 | if (err) 48 | return callback(false); 49 | 50 | db.collection('entries').findOne({ 51 | 'entry_id': key, 52 | $or: [ 53 | { expiration: -1 }, 54 | { expiration: { $gt: now } } 55 | ] 56 | }, function (err, entry) { 57 | if (err) { 58 | winston.error('error persisting value to mongodb', { error: err }); 59 | return callback(false); 60 | } 61 | 62 | callback(entry === null ? false : entry.value); 63 | 64 | if (entry !== null && entry.expiration !== -1 && that.expire && !skipExpire) { 65 | db.collection('entries').update({ 66 | 'entry_id': key 67 | }, { 68 | $set: { 69 | 'expiration': that.expire + now 70 | } 71 | }, function (err, result) { }); 72 | } 73 | }); 74 | }); 75 | }; 76 | 77 | MongoDocumentStore.prototype.safeConnect = function (callback) { 78 | MongoClient.connect(this.connectionUrl, function (err, db) { 79 | if (err) { 80 | winston.error('error connecting to mongodb', { error: err }); 81 | callback(err); 82 | } else { 83 | callback(undefined, db); 84 | } 85 | }); 86 | }; 87 | 88 | module.exports = MongoDocumentStore; 89 | -------------------------------------------------------------------------------- /docker-entrypoint.js: -------------------------------------------------------------------------------- 1 | const { 2 | HOST, 3 | PORT, 4 | KEY_LENGTH, 5 | MAX_LENGTH, 6 | STATIC_MAX_AGE, 7 | RECOMPRESS_STATIC_ASSETS, 8 | STORAGE_TYPE, 9 | STORAGE_HOST, 10 | STORAGE_PORT, 11 | STORAGE_EXPIRE_SECONDS, 12 | STORAGE_DB, 13 | STORAGE_AWS_BUCKET, 14 | STORAGE_AWS_REGION, 15 | STORAGE_PASSWORD, 16 | STORAGE_USERNAME, 17 | STORAGE_FILEPATH, 18 | LOGGING_LEVEL, 19 | LOGGING_TYPE, 20 | LOGGING_COLORIZE, 21 | KEYGENERATOR_TYPE, 22 | KEY_GENERATOR_KEYSPACE, 23 | RATE_LIMITS_NORMAL_TOTAL_REQUESTS, 24 | RATE_LIMITS_NORMAL_EVERY_MILLISECONDS, 25 | RATE_LIMITS_WHITELIST_TOTAL_REQUESTS, 26 | RATE_LIMITS_WHITELIST_EVERY_MILLISECONDS, 27 | RATE_LIMITS_WHITELIST, 28 | RATE_LIMITS_BLACKLIST_TOTAL_REQUESTS, 29 | RATE_LIMITS_BLACKLIST_EVERY_MILLISECONDS, 30 | RATE_LIMITS_BLACKLIST, 31 | DOCUMENTS, 32 | } = process.env; 33 | 34 | const config = { 35 | host: HOST, 36 | port: PORT, 37 | 38 | keyLength: KEY_LENGTH, 39 | 40 | maxLength: MAX_LENGTH, 41 | 42 | staticMaxAge: STATIC_MAX_AGE, 43 | 44 | recompressStaticAssets: RECOMPRESS_STATIC_ASSETS, 45 | 46 | logging: [ 47 | { 48 | level: LOGGING_LEVEL, 49 | type: LOGGING_TYPE, 50 | colorize: LOGGING_COLORIZE, 51 | }, 52 | ], 53 | 54 | keyGenerator: { 55 | type: KEYGENERATOR_TYPE, 56 | keyspace: KEY_GENERATOR_KEYSPACE, 57 | }, 58 | 59 | rateLimits: { 60 | whitelist: RATE_LIMITS_WHITELIST ? RATE_LIMITS_WHITELIST.split(",") : [], 61 | blacklist: RATE_LIMITS_BLACKLIST ? RATE_LIMITS_BLACKLIST.split(",") : [], 62 | categories: { 63 | normal: { 64 | totalRequests: RATE_LIMITS_NORMAL_TOTAL_REQUESTS, 65 | every: RATE_LIMITS_NORMAL_EVERY_MILLISECONDS, 66 | }, 67 | whitelist: 68 | RATE_LIMITS_WHITELIST_EVERY_MILLISECONDS || 69 | RATE_LIMITS_WHITELIST_TOTAL_REQUESTS 70 | ? { 71 | totalRequests: RATE_LIMITS_WHITELIST_TOTAL_REQUESTS, 72 | every: RATE_LIMITS_WHITELIST_EVERY_MILLISECONDS, 73 | } 74 | : null, 75 | blacklist: 76 | RATE_LIMITS_BLACKLIST_EVERY_MILLISECONDS || 77 | RATE_LIMITS_BLACKLIST_TOTAL_REQUESTS 78 | ? { 79 | totalRequests: RATE_LIMITS_WHITELIST_TOTAL_REQUESTS, 80 | every: RATE_LIMITS_BLACKLIST_EVERY_MILLISECONDS, 81 | } 82 | : null, 83 | }, 84 | }, 85 | 86 | storage: { 87 | type: STORAGE_TYPE, 88 | host: STORAGE_HOST, 89 | port: STORAGE_PORT, 90 | expire: STORAGE_EXPIRE_SECONDS, 91 | bucket: STORAGE_AWS_BUCKET, 92 | region: STORAGE_AWS_REGION, 93 | connectionUrl: `postgres://${STORAGE_USERNAME}:${STORAGE_PASSWORD}@${STORAGE_HOST}:${STORAGE_PORT}/${STORAGE_DB}`, 94 | db: STORAGE_DB, 95 | user: STORAGE_USERNAME, 96 | password: STORAGE_PASSWORD, 97 | path: STORAGE_FILEPATH, 98 | }, 99 | 100 | documents: DOCUMENTS 101 | ? DOCUMENTS.split(",").reduce((acc, item) => { 102 | const keyAndValueArray = item.replace(/\s/g, "").split("="); 103 | return { ...acc, [keyAndValueArray[0]]: keyAndValueArray[1] }; 104 | }, {}) 105 | : null, 106 | }; 107 | 108 | console.log(JSON.stringify(config)); 109 | -------------------------------------------------------------------------------- /static/application.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #002B36; 3 | padding: 20px 50px; 4 | margin: 0px; 5 | } 6 | 7 | /* textarea */ 8 | 9 | textarea { 10 | background: transparent; 11 | border: 0px; 12 | color: #fff; 13 | padding: 0px; 14 | width: 100%; 15 | height: 100%; 16 | font-family: monospace; 17 | outline: none; 18 | resize: none; 19 | font-size: 13px; 20 | margin-top: 0; 21 | margin-bottom: 0; 22 | } 23 | 24 | /* the line numbers */ 25 | 26 | #linenos { 27 | color: #7d7d7d; 28 | z-index: -1000; 29 | position: absolute; 30 | top: 20px; 31 | left: 0px; 32 | width: 30px; /* 30 to get 20 away from box */ 33 | font-size: 13px; 34 | font-family: monospace; 35 | text-align: right; 36 | user-select: none; 37 | } 38 | 39 | /* code box when locked */ 40 | 41 | #box { 42 | padding: 0px; 43 | margin: 0px; 44 | width: 100%; 45 | border: 0px; 46 | outline: none; 47 | font-size: 13px; 48 | overflow: inherit; 49 | } 50 | 51 | #box code { 52 | padding: 0px; 53 | background: transparent !important; /* don't hide hastebox */ 54 | } 55 | 56 | /* key */ 57 | 58 | #key { 59 | position: fixed; 60 | top: 0px; 61 | right: 0px; 62 | z-index: +1000; /* watch out */ 63 | } 64 | 65 | #box1 { 66 | padding: 5px; 67 | text-align: center; 68 | background: #00222b; 69 | } 70 | 71 | #box2 { 72 | background: #08323c; 73 | font-size: 0px; 74 | padding: 0px 5px; 75 | } 76 | 77 | #box1 a.logo, #box1 a.logo:visited { 78 | display: inline-block; 79 | background: url(logo.png); 80 | width: 126px; 81 | height: 42px; 82 | } 83 | 84 | #box1 a.logo:hover { 85 | background-position: 0 bottom; 86 | } 87 | 88 | #box2 .function { 89 | background: url(function-icons.png); 90 | width: 32px; 91 | height: 37px; 92 | display: inline-block; 93 | position: relative; 94 | } 95 | 96 | #box2 .link embed { 97 | vertical-align: bottom; /* fix for zeroClipboard style */ 98 | } 99 | 100 | #box2 .function.enabled:hover { 101 | cursor: hand; 102 | cursor: pointer; 103 | } 104 | 105 | #pointer { 106 | display: block; 107 | height: 5px; 108 | width: 10px; 109 | background: url(hover-dropdown-tip.png); 110 | bottom: 0px; 111 | position: absolute; 112 | margin: auto; 113 | left: 0px; 114 | right: 0px; 115 | } 116 | 117 | #box3, #messages li { 118 | background: #173e48; 119 | font-family: Helvetica, sans-serif; 120 | font-size: 12px; 121 | line-height: 14px; 122 | padding: 10px 15px; 123 | user-select: none; 124 | } 125 | 126 | #box3 .label, #messages li { 127 | color: #fff; 128 | font-weight: bold; 129 | } 130 | 131 | #box3 .shortcut { 132 | color: #c4dce3; 133 | font-weight: normal; 134 | } 135 | 136 | #box2 .function.save { background-position: -5px top; } 137 | #box2 .function.enabled.save { background-position: -5px center; } 138 | #box2 .function.enabled.save:hover { background-position: -5px bottom; } 139 | 140 | #box2 .function.new { background-position: -42px top; } 141 | #box2 .function.enabled.new { background-position: -42px center; } 142 | #box2 .function.enabled.new:hover { background-position: -42px bottom; } 143 | 144 | #box2 .function.duplicate { background-position: -79px top; } 145 | #box2 .function.enabled.duplicate { background-position: -79px center; } 146 | #box2 .function.enabled.duplicate:hover { background-position: -79px bottom; } 147 | 148 | #box2 .function.raw { background-position: -116px top; } 149 | #box2 .function.enabled.raw { background-position: -116px center; } 150 | #box2 .function.enabled.raw:hover { background-position: -116px bottom; } 151 | 152 | #box2 .function.twitter { background-position: -153px top; } 153 | #box2 .function.enabled.twitter { background-position: -153px center; } 154 | #box2 .function.enabled.twitter:hover { background-position: -153px bottom; } 155 | #box2 .button-picture{ border-width: 0; font-size: inherit; } 156 | 157 | #messages { 158 | position:fixed; 159 | top:0px; 160 | right:138px; 161 | margin:0; 162 | padding:0; 163 | width:400px; 164 | } 165 | 166 | #messages li { 167 | background:rgba(23,62,72,0.8); 168 | margin:0 auto; 169 | list-style:none; 170 | } 171 | 172 | #messages li.error { 173 | background:rgba(102,8,0,0.8); 174 | } 175 | 176 | -------------------------------------------------------------------------------- /lib/document_handler.js: -------------------------------------------------------------------------------- 1 | var winston = require('winston'); 2 | var Busboy = require('busboy'); 3 | 4 | // For handling serving stored documents 5 | 6 | var DocumentHandler = function(options) { 7 | if (!options) { 8 | options = {}; 9 | } 10 | this.keyLength = options.keyLength || DocumentHandler.defaultKeyLength; 11 | this.maxLength = options.maxLength; // none by default 12 | this.store = options.store; 13 | this.keyGenerator = options.keyGenerator; 14 | }; 15 | 16 | DocumentHandler.defaultKeyLength = 10; 17 | 18 | // Handle retrieving a document 19 | DocumentHandler.prototype.handleGet = function(request, response, config) { 20 | const key = request.params.id.split('.')[0]; 21 | const skipExpire = !!config.documents[key]; 22 | 23 | this.store.get(key, function(ret) { 24 | if (ret) { 25 | winston.verbose('retrieved document', { key: key }); 26 | response.writeHead(200, { 'content-type': 'application/json' }); 27 | if (request.method === 'HEAD') { 28 | response.end(); 29 | } else { 30 | response.end(JSON.stringify({ data: ret, key: key })); 31 | } 32 | } 33 | else { 34 | winston.warn('document not found', { key: key }); 35 | response.writeHead(404, { 'content-type': 'application/json' }); 36 | if (request.method === 'HEAD') { 37 | response.end(); 38 | } else { 39 | response.end(JSON.stringify({ message: 'Document not found.' })); 40 | } 41 | } 42 | }, skipExpire); 43 | }; 44 | 45 | // Handle retrieving the raw version of a document 46 | DocumentHandler.prototype.handleRawGet = function(request, response, config) { 47 | const key = request.params.id.split('.')[0]; 48 | const skipExpire = !!config.documents[key]; 49 | 50 | this.store.get(key, function(ret) { 51 | if (ret) { 52 | winston.verbose('retrieved raw document', { key: key }); 53 | response.writeHead(200, { 'content-type': 'text/plain; charset=UTF-8' }); 54 | if (request.method === 'HEAD') { 55 | response.end(); 56 | } else { 57 | response.end(ret); 58 | } 59 | } 60 | else { 61 | winston.warn('raw document not found', { key: key }); 62 | response.writeHead(404, { 'content-type': 'application/json' }); 63 | if (request.method === 'HEAD') { 64 | response.end(); 65 | } else { 66 | response.end(JSON.stringify({ message: 'Document not found.' })); 67 | } 68 | } 69 | }, skipExpire); 70 | }; 71 | 72 | // Handle adding a new Document 73 | DocumentHandler.prototype.handlePost = function (request, response) { 74 | var _this = this; 75 | var buffer = ''; 76 | var cancelled = false; 77 | 78 | // What to do when done 79 | var onSuccess = function () { 80 | // Check length 81 | if (_this.maxLength && buffer.length > _this.maxLength) { 82 | cancelled = true; 83 | winston.warn('document >maxLength', { maxLength: _this.maxLength }); 84 | response.writeHead(400, { 'content-type': 'application/json' }); 85 | response.end( 86 | JSON.stringify({ message: 'Document exceeds maximum length.' }) 87 | ); 88 | return; 89 | } 90 | // And then save if we should 91 | _this.chooseKey(function (key) { 92 | _this.store.set(key, buffer, function (res) { 93 | if (res) { 94 | winston.verbose('added document', { key: key }); 95 | response.writeHead(200, { 'content-type': 'application/json' }); 96 | response.end(JSON.stringify({ key: key })); 97 | } 98 | else { 99 | winston.verbose('error adding document'); 100 | response.writeHead(500, { 'content-type': 'application/json' }); 101 | response.end(JSON.stringify({ message: 'Error adding document.' })); 102 | } 103 | }); 104 | }); 105 | }; 106 | 107 | // If we should, parse a form to grab the data 108 | var ct = request.headers['content-type']; 109 | if (ct && ct.split(';')[0] === 'multipart/form-data') { 110 | var busboy = new Busboy({ headers: request.headers }); 111 | busboy.on('field', function (fieldname, val) { 112 | if (fieldname === 'data') { 113 | buffer = val; 114 | } 115 | }); 116 | busboy.on('finish', function () { 117 | onSuccess(); 118 | }); 119 | request.pipe(busboy); 120 | // Otherwise, use our own and just grab flat data from POST body 121 | } else { 122 | request.on('data', function (data) { 123 | buffer += data.toString(); 124 | }); 125 | request.on('end', function () { 126 | if (cancelled) { return; } 127 | onSuccess(); 128 | }); 129 | request.on('error', function (error) { 130 | winston.error('connection error: ' + error.message); 131 | response.writeHead(500, { 'content-type': 'application/json' }); 132 | response.end(JSON.stringify({ message: 'Connection error.' })); 133 | cancelled = true; 134 | }); 135 | } 136 | }; 137 | 138 | // Keep choosing keys until one isn't taken 139 | DocumentHandler.prototype.chooseKey = function(callback) { 140 | var key = this.acceptableKey(); 141 | var _this = this; 142 | this.store.get(key, function(ret) { 143 | if (ret) { 144 | _this.chooseKey(callback); 145 | } else { 146 | callback(key); 147 | } 148 | }, true); // Don't bump expirations when key searching 149 | }; 150 | 151 | DocumentHandler.prototype.acceptableKey = function() { 152 | return this.keyGenerator.createKey(this.keyLength); 153 | }; 154 | 155 | module.exports = DocumentHandler; 156 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var fs = require('fs'); 3 | 4 | var uglify = require('uglify-js'); 5 | var winston = require('winston'); 6 | var connect = require('connect'); 7 | var route = require('connect-route'); 8 | var connect_st = require('st'); 9 | var connect_rate_limit = require('connect-ratelimit'); 10 | 11 | var DocumentHandler = require('./lib/document_handler'); 12 | 13 | // Load the configuration and set some defaults 14 | const configPath = process.argv.length <= 2 ? 'config.js' : process.argv[2]; 15 | const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); 16 | config.port = process.env.PORT || config.port || 7777; 17 | config.host = process.env.HOST || config.host || 'localhost'; 18 | 19 | // Set up the logger 20 | if (config.logging) { 21 | try { 22 | winston.remove(winston.transports.Console); 23 | } catch(e) { 24 | /* was not present */ 25 | } 26 | 27 | var detail, type; 28 | for (var i = 0; i < config.logging.length; i++) { 29 | detail = config.logging[i]; 30 | type = detail.type; 31 | delete detail.type; 32 | winston.add(winston.transports[type], detail); 33 | } 34 | } 35 | 36 | // build the store from the config on-demand - so that we don't load it 37 | // for statics 38 | if (!config.storage) { 39 | config.storage = { type: 'file' }; 40 | } 41 | if (!config.storage.type) { 42 | config.storage.type = 'file'; 43 | } 44 | 45 | var Store, preferredStore; 46 | 47 | if (process.env.REDISTOGO_URL && config.storage.type === 'redis') { 48 | var redisClient = require('redis-url').connect(process.env.REDISTOGO_URL); 49 | Store = require('./lib/document_stores/redis'); 50 | preferredStore = new Store(config.storage, redisClient); 51 | } 52 | else { 53 | Store = require('./lib/document_stores/' + config.storage.type); 54 | preferredStore = new Store(config.storage); 55 | } 56 | 57 | // Compress the static javascript assets 58 | if (config.recompressStaticAssets) { 59 | var list = fs.readdirSync('./static'); 60 | for (var j = 0; j < list.length; j++) { 61 | var item = list[j]; 62 | if ((item.indexOf('.js') === item.length - 3) && (item.indexOf('.min.js') === -1)) { 63 | var dest = item.substring(0, item.length - 3) + '.min' + item.substring(item.length - 3); 64 | var orig_code = fs.readFileSync('./static/' + item, 'utf8'); 65 | 66 | fs.writeFileSync('./static/' + dest, uglify.minify(orig_code).code, 'utf8'); 67 | winston.info('compressed ' + item + ' into ' + dest); 68 | } 69 | } 70 | } 71 | 72 | // Send the static documents into the preferred store, skipping expirations 73 | var path, data; 74 | for (var name in config.documents) { 75 | path = config.documents[name]; 76 | data = fs.readFileSync(path, 'utf8'); 77 | winston.info('loading static document', { name: name, path: path }); 78 | if (data) { 79 | preferredStore.set(name, data, function(cb) { 80 | winston.debug('loaded static document', { success: cb }); 81 | }, true); 82 | } 83 | else { 84 | winston.warn('failed to load static document', { name: name, path: path }); 85 | } 86 | } 87 | 88 | // Pick up a key generator 89 | var pwOptions = config.keyGenerator || {}; 90 | pwOptions.type = pwOptions.type || 'random'; 91 | var gen = require('./lib/key_generators/' + pwOptions.type); 92 | var keyGenerator = new gen(pwOptions); 93 | 94 | // Configure the document handler 95 | var documentHandler = new DocumentHandler({ 96 | store: preferredStore, 97 | maxLength: config.maxLength, 98 | keyLength: config.keyLength, 99 | keyGenerator: keyGenerator 100 | }); 101 | 102 | var app = connect(); 103 | 104 | // Rate limit all requests 105 | if (config.rateLimits) { 106 | config.rateLimits.end = true; 107 | app.use(connect_rate_limit(config.rateLimits)); 108 | } 109 | 110 | // first look at API calls 111 | app.use(route(function(router) { 112 | // get raw documents - support getting with extension 113 | 114 | router.get('/raw/:id', function(request, response) { 115 | return documentHandler.handleRawGet(request, response, config); 116 | }); 117 | 118 | router.head('/raw/:id', function(request, response) { 119 | return documentHandler.handleRawGet(request, response, config); 120 | }); 121 | 122 | // add documents 123 | 124 | router.post('/documents', function(request, response) { 125 | return documentHandler.handlePost(request, response); 126 | }); 127 | 128 | // get documents 129 | router.get('/documents/:id', function(request, response) { 130 | return documentHandler.handleGet(request, response, config); 131 | }); 132 | 133 | router.head('/documents/:id', function(request, response) { 134 | return documentHandler.handleGet(request, response, config); 135 | }); 136 | })); 137 | 138 | // Otherwise, try to match static files 139 | app.use(connect_st({ 140 | path: __dirname + '/static', 141 | content: { maxAge: config.staticMaxAge }, 142 | passthrough: true, 143 | index: false 144 | })); 145 | 146 | // Then we can loop back - and everything else should be a token, 147 | // so route it back to / 148 | app.use(route(function(router) { 149 | router.get('/:id', function(request, response, next) { 150 | request.sturl = '/'; 151 | next(); 152 | }); 153 | })); 154 | 155 | // And match index 156 | app.use(connect_st({ 157 | path: __dirname + '/static', 158 | content: { maxAge: config.staticMaxAge }, 159 | index: 'index.html' 160 | })); 161 | 162 | http.createServer(app).listen(config.port, config.host); 163 | 164 | winston.info('listening on ' + config.host + ':' + config.port); 165 | -------------------------------------------------------------------------------- /static/application.min.js: -------------------------------------------------------------------------------- 1 | var haste_document=function(){this.locked=!1};haste_document.prototype.htmlEscape=function(t){return t.replace(/&/g,"&").replace(/>/g,">").replace(/'+t+"");$("#messages").prepend(o),setTimeout(function(){o.slideUp("fast",function(){$(this).remove()})},3e3)},haste.prototype.lightKey=function(){this.configureKey(["new","save"])},haste.prototype.fullKey=function(){this.configureKey(["new","duplicate","twitter","raw"])},haste.prototype.configureKey=function(t){var e,o=0;$("#box2 .function").each(function(){for(e=$(this),o=0;o";$("#linenos").html(e)},haste.prototype.removeLineNumbers=function(){$("#linenos").html(">")},haste.prototype.loadDocument=function(t){var e=t.split(".",2),o=this;o.doc=new haste_document,o.doc.load(e[0],function(t){t?(o.$code.html(t.value),o.setTitle(t.key),o.fullKey(),o.$textarea.val("").hide(),o.$box.show().focus(),o.addLineNumbers(t.lineCount)):o.newDocument()},this.lookupTypeByExtension(e[1]))},haste.prototype.duplicateDocument=function(){if(this.doc.locked){var t=this.doc.data;this.newDocument(),this.$textarea.val(t)}},haste.prototype.lockDocument=function(){var t=this;this.doc.save(this.$textarea.val(),function(e,o){if(e)t.showMessage(e.message,"error");else if(o){t.$code.html(o.value),t.setTitle(o.key);var n="/"+o.key;o.language&&(n+="."+t.lookupExtensionByType(o.language)),window.history.pushState(null,t.appName+"-"+o.key,n),t.fullKey(),t.$textarea.val("").hide(),t.$box.show().focus(),t.addLineNumbers(o.lineCount)}})},haste.prototype.configureButtons=function(){var t=this;this.buttons=[{$where:$("#box2 .save"),label:"Save",shortcutDescription:"control + s",shortcut:function(t){return t.ctrlKey&&83===t.keyCode},action:function(){""!==t.$textarea.val().replace(/^\s+|\s+$/g,"")&&t.lockDocument()}},{$where:$("#box2 .new"),label:"New",shortcut:function(t){return t.ctrlKey&&78===t.keyCode},shortcutDescription:"control + n",action:function(){t.newDocument(!t.doc.key)}},{$where:$("#box2 .duplicate"),label:"Duplicate & Edit",shortcut:function(e){return t.doc.locked&&e.ctrlKey&&68===e.keyCode},shortcutDescription:"control + d",action:function(){t.duplicateDocument()}},{$where:$("#box2 .raw"),label:"Just Text",shortcut:function(t){return t.ctrlKey&&t.shiftKey&&82===t.keyCode},shortcutDescription:"control + shift + r",action:function(){window.location.href="/raw/"+t.doc.key}},{$where:$("#box2 .twitter"),label:"Twitter",shortcut:function(e){return t.options.twitter&&t.doc.locked&&e.shiftKey&&e.ctrlKey&&84==e.keyCode},shortcutDescription:"control + shift + t",action:function(){window.open("https://twitter.com/share?url="+encodeURI(window.location.href))}}];for(var e=0;e/g, '>') 14 | .replace(/'+msg+''); 116 | $('#messages').prepend(msgBox); 117 | setTimeout(function() { 118 | msgBox.slideUp('fast', function() { $(this).remove(); }); 119 | }, 3000); 120 | }; 121 | 122 | // Show the light key 123 | haste.prototype.lightKey = function() { 124 | this.configureKey(['new', 'save']); 125 | }; 126 | 127 | // Show the full key 128 | haste.prototype.fullKey = function() { 129 | this.configureKey(['new', 'duplicate', 'twitter', 'raw']); 130 | }; 131 | 132 | // Set the key up for certain things to be enabled 133 | haste.prototype.configureKey = function(enable) { 134 | var $this, i = 0; 135 | $('#box2 .function').each(function() { 136 | $this = $(this); 137 | for (i = 0; i < enable.length; i++) { 138 | if ($this.hasClass(enable[i])) { 139 | $this.addClass('enabled'); 140 | return true; 141 | } 142 | } 143 | $this.removeClass('enabled'); 144 | }); 145 | }; 146 | 147 | // Remove the current document (if there is one) 148 | // and set up for a new one 149 | haste.prototype.newDocument = function(hideHistory) { 150 | this.$box.hide(); 151 | this.doc = new haste_document(); 152 | if (!hideHistory) { 153 | window.history.pushState(null, this.appName, '/'); 154 | } 155 | this.setTitle(); 156 | this.lightKey(); 157 | this.$textarea.val('').show('fast', function() { 158 | this.focus(); 159 | }); 160 | this.removeLineNumbers(); 161 | }; 162 | 163 | // Map of common extensions 164 | // Note: this list does not need to include anything that IS its extension, 165 | // due to the behavior of lookupTypeByExtension and lookupExtensionByType 166 | // Note: optimized for lookupTypeByExtension 167 | haste.extensionMap = { 168 | rb: 'ruby', py: 'python', pl: 'perl', php: 'php', scala: 'scala', go: 'go', 169 | xml: 'xml', html: 'xml', htm: 'xml', css: 'css', js: 'javascript', vbs: 'vbscript', 170 | lua: 'lua', pas: 'delphi', java: 'java', cpp: 'cpp', cc: 'cpp', m: 'objectivec', 171 | vala: 'vala', sql: 'sql', sm: 'smalltalk', lisp: 'lisp', ini: 'ini', 172 | diff: 'diff', bash: 'bash', sh: 'bash', tex: 'tex', erl: 'erlang', hs: 'haskell', 173 | md: 'markdown', txt: '', coffee: 'coffee', swift: 'swift' 174 | }; 175 | 176 | // Look up the extension preferred for a type 177 | // If not found, return the type itself - which we'll place as the extension 178 | haste.prototype.lookupExtensionByType = function(type) { 179 | for (var key in haste.extensionMap) { 180 | if (haste.extensionMap[key] === type) return key; 181 | } 182 | return type; 183 | }; 184 | 185 | // Look up the type for a given extension 186 | // If not found, return the extension - which we'll attempt to use as the type 187 | haste.prototype.lookupTypeByExtension = function(ext) { 188 | return haste.extensionMap[ext] || ext; 189 | }; 190 | 191 | // Add line numbers to the document 192 | // For the specified number of lines 193 | haste.prototype.addLineNumbers = function(lineCount) { 194 | var h = ''; 195 | for (var i = 0; i < lineCount; i++) { 196 | h += (i + 1).toString() + '
'; 197 | } 198 | $('#linenos').html(h); 199 | }; 200 | 201 | // Remove the line numbers 202 | haste.prototype.removeLineNumbers = function() { 203 | $('#linenos').html('>'); 204 | }; 205 | 206 | // Load a document and show it 207 | haste.prototype.loadDocument = function(key) { 208 | // Split the key up 209 | var parts = key.split('.', 2); 210 | // Ask for what we want 211 | var _this = this; 212 | _this.doc = new haste_document(); 213 | _this.doc.load(parts[0], function(ret) { 214 | if (ret) { 215 | _this.$code.html(ret.value); 216 | _this.setTitle(ret.key); 217 | _this.fullKey(); 218 | _this.$textarea.val('').hide(); 219 | _this.$box.show().focus(); 220 | _this.addLineNumbers(ret.lineCount); 221 | } 222 | else { 223 | _this.newDocument(); 224 | } 225 | }, this.lookupTypeByExtension(parts[1])); 226 | }; 227 | 228 | // Duplicate the current document - only if locked 229 | haste.prototype.duplicateDocument = function() { 230 | if (this.doc.locked) { 231 | var currentData = this.doc.data; 232 | this.newDocument(); 233 | this.$textarea.val(currentData); 234 | } 235 | }; 236 | 237 | // Lock the current document 238 | haste.prototype.lockDocument = function() { 239 | var _this = this; 240 | this.doc.save(this.$textarea.val(), function(err, ret) { 241 | if (err) { 242 | _this.showMessage(err.message, 'error'); 243 | } 244 | else if (ret) { 245 | _this.$code.html(ret.value); 246 | _this.setTitle(ret.key); 247 | var file = '/' + ret.key; 248 | if (ret.language) { 249 | file += '.' + _this.lookupExtensionByType(ret.language); 250 | } 251 | window.history.pushState(null, _this.appName + '-' + ret.key, file); 252 | _this.fullKey(); 253 | _this.$textarea.val('').hide(); 254 | _this.$box.show().focus(); 255 | _this.addLineNumbers(ret.lineCount); 256 | } 257 | }); 258 | }; 259 | 260 | haste.prototype.configureButtons = function() { 261 | var _this = this; 262 | this.buttons = [ 263 | { 264 | $where: $('#box2 .save'), 265 | label: 'Save', 266 | shortcutDescription: 'control + s', 267 | shortcut: function(evt) { 268 | return evt.ctrlKey && (evt.keyCode === 83); 269 | }, 270 | action: function() { 271 | if (_this.$textarea.val().replace(/^\s+|\s+$/g, '') !== '') { 272 | _this.lockDocument(); 273 | } 274 | } 275 | }, 276 | { 277 | $where: $('#box2 .new'), 278 | label: 'New', 279 | shortcut: function(evt) { 280 | return evt.ctrlKey && evt.keyCode === 78; 281 | }, 282 | shortcutDescription: 'control + n', 283 | action: function() { 284 | _this.newDocument(!_this.doc.key); 285 | } 286 | }, 287 | { 288 | $where: $('#box2 .duplicate'), 289 | label: 'Duplicate & Edit', 290 | shortcut: function(evt) { 291 | return _this.doc.locked && evt.ctrlKey && evt.keyCode === 68; 292 | }, 293 | shortcutDescription: 'control + d', 294 | action: function() { 295 | _this.duplicateDocument(); 296 | } 297 | }, 298 | { 299 | $where: $('#box2 .raw'), 300 | label: 'Just Text', 301 | shortcut: function(evt) { 302 | return evt.ctrlKey && evt.shiftKey && evt.keyCode === 82; 303 | }, 304 | shortcutDescription: 'control + shift + r', 305 | action: function() { 306 | window.location.href = '/raw/' + _this.doc.key; 307 | } 308 | }, 309 | { 310 | $where: $('#box2 .twitter'), 311 | label: 'Twitter', 312 | shortcut: function(evt) { 313 | return _this.options.twitter && _this.doc.locked && evt.shiftKey && evt.ctrlKey && evt.keyCode == 84; 314 | }, 315 | shortcutDescription: 'control + shift + t', 316 | action: function() { 317 | window.open('https://twitter.com/share?url=' + encodeURI(window.location.href)); 318 | } 319 | } 320 | ]; 321 | for (var i = 0; i < this.buttons.length; i++) { 322 | this.configureButton(this.buttons[i]); 323 | } 324 | }; 325 | 326 | haste.prototype.configureButton = function(options) { 327 | // Handle the click action 328 | options.$where.click(function(evt) { 329 | evt.preventDefault(); 330 | if (!options.clickDisabled && $(this).hasClass('enabled')) { 331 | options.action(); 332 | } 333 | }); 334 | // Show the label 335 | options.$where.mouseenter(function() { 336 | $('#box3 .label').text(options.label); 337 | $('#box3 .shortcut').text(options.shortcutDescription || ''); 338 | $('#box3').show(); 339 | $(this).append($('#pointer').remove().show()); 340 | }); 341 | // Hide the label 342 | options.$where.mouseleave(function() { 343 | $('#box3').hide(); 344 | $('#pointer').hide(); 345 | }); 346 | }; 347 | 348 | // Configure keyboard shortcuts for the textarea 349 | haste.prototype.configureShortcuts = function() { 350 | var _this = this; 351 | $(document.body).keydown(function(evt) { 352 | var button; 353 | for (var i = 0 ; i < _this.buttons.length; i++) { 354 | button = _this.buttons[i]; 355 | if (button.shortcut && button.shortcut(evt)) { 356 | evt.preventDefault(); 357 | button.action(); 358 | return; 359 | } 360 | } 361 | }); 362 | }; 363 | 364 | ///// Tab behavior in the textarea - 2 spaces per tab 365 | $(function() { 366 | 367 | $('textarea').keydown(function(evt) { 368 | if (evt.keyCode === 9) { 369 | evt.preventDefault(); 370 | var myValue = ' '; 371 | // http://stackoverflow.com/questions/946534/insert-text-into-textarea-with-jquery 372 | // For browsers like Internet Explorer 373 | if (document.selection) { 374 | this.focus(); 375 | var sel = document.selection.createRange(); 376 | sel.text = myValue; 377 | this.focus(); 378 | } 379 | // Mozilla and Webkit 380 | else if (this.selectionStart || this.selectionStart == '0') { 381 | var startPos = this.selectionStart; 382 | var endPos = this.selectionEnd; 383 | var scrollTop = this.scrollTop; 384 | this.value = this.value.substring(0, startPos) + myValue + 385 | this.value.substring(endPos,this.value.length); 386 | this.focus(); 387 | this.selectionStart = startPos + myValue.length; 388 | this.selectionEnd = startPos + myValue.length; 389 | this.scrollTop = scrollTop; 390 | } 391 | else { 392 | this.value += myValue; 393 | this.focus(); 394 | } 395 | } 396 | }); 397 | 398 | }); 399 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Haste 2 | 3 | Haste is an open-source pastebin software written in node.js, which is easily 4 | installable in any network. It can be backed by either redis or filesystem, 5 | and has a very easy adapter interface for other stores. A publicly available 6 | version can be found at [hastebin.com](http://hastebin.com) 7 | 8 | Major design objectives: 9 | 10 | * Be really pretty 11 | * Be really simple 12 | * Be easy to set up and use 13 | 14 | Haste works really well with a little utility called 15 | [haste-client](https://github.com/seejohnrun/haste-client), allowing you 16 | to do things like: 17 | 18 | `cat something | haste` 19 | 20 | which will output a URL to share containing the contents of `cat something`'s 21 | STDOUT. Check the README there for more details and usages. 22 | 23 | ## Tested Browsers 24 | 25 | * Firefox 8 26 | * Chrome 17 27 | * Safari 5.3 28 | 29 | ## Installation 30 | 31 | 1. Download the package, and expand it 32 | 2. Explore the settings inside of config.js, but the defaults should be good 33 | 3. `npm install` 34 | 4. `npm start` (you may specify an optional `` as well) 35 | 36 | ## Settings 37 | 38 | * `host` - the host the server runs on (default localhost) 39 | * `port` - the port the server runs on (default 7777) 40 | * `keyLength` - the length of the keys to user (default 10) 41 | * `maxLength` - maximum length of a paste (default 400000) 42 | * `staticMaxAge` - max age for static assets (86400) 43 | * `recompressStaticAssets` - whether or not to compile static js assets (true) 44 | * `documents` - static documents to serve (ex: http://hastebin.com/about.com) 45 | in addition to static assets. These will never expire. 46 | * `storage` - storage options (see below) 47 | * `logging` - logging preferences 48 | * `keyGenerator` - key generator options (see below) 49 | * `rateLimits` - settings for rate limiting (see below) 50 | 51 | ## Rate Limiting 52 | 53 | When present, the `rateLimits` option enables built-in rate limiting courtesy 54 | of `connect-ratelimit`. Any of the options supported by that library can be 55 | used and set in `config.js`. 56 | 57 | See the README for [connect-ratelimit](https://github.com/dharmafly/connect-ratelimit) 58 | for more information! 59 | 60 | ## Key Generation 61 | 62 | ### Phonetic 63 | 64 | Attempts to generate phonetic keys, similar to `pwgen` 65 | 66 | ``` json 67 | { 68 | "type": "phonetic" 69 | } 70 | ``` 71 | 72 | ### Random 73 | 74 | Generates a random key 75 | 76 | ``` json 77 | { 78 | "type": "random", 79 | "keyspace": "abcdef" 80 | } 81 | ``` 82 | 83 | The _optional_ keySpace argument is a string of acceptable characters 84 | for the key. 85 | 86 | ## Storage 87 | 88 | ### File 89 | 90 | To use file storage (the default) change the storage section in `config.js` to 91 | something like: 92 | 93 | ``` json 94 | { 95 | "path": "./data", 96 | "type": "file" 97 | } 98 | ``` 99 | 100 | where `path` represents where you want the files stored. 101 | 102 | File storage currently does not support paste expiration, you can follow [#191](https://github.com/seejohnrun/haste-server/issues/191) for status updates. 103 | 104 | ### Redis 105 | 106 | To use redis storage you must install the `redis` package in npm, and have 107 | `redis-server` running on the machine. 108 | 109 | `npm install redis` 110 | 111 | Once you've done that, your config section should look like: 112 | 113 | ``` json 114 | { 115 | "type": "redis", 116 | "host": "localhost", 117 | "port": 6379, 118 | "db": 2 119 | } 120 | ``` 121 | 122 | You can also set an `expire` option to the number of seconds to expire keys in. 123 | This is off by default, but will constantly kick back expirations on each view 124 | or post. 125 | 126 | All of which are optional except `type` with very logical default values. 127 | 128 | If your Redis server is configured for password authentification, use the `password` field. 129 | 130 | ### Postgres 131 | 132 | To use postgres storage you must install the `pg` package in npm 133 | 134 | `npm install pg` 135 | 136 | Once you've done that, your config section should look like: 137 | 138 | ``` json 139 | { 140 | "type": "postgres", 141 | "connectionUrl": "postgres://user:password@host:5432/database" 142 | } 143 | ``` 144 | 145 | You can also just set the environment variable for `DATABASE_URL` to your database connection url. 146 | 147 | You will have to manually add a table to your postgres database: 148 | 149 | `create table entries (id serial primary key, key varchar(255) not null, value text not null, expiration int, unique(key));` 150 | 151 | You can also set an `expire` option to the number of seconds to expire keys in. 152 | This is off by default, but will constantly kick back expirations on each view 153 | or post. 154 | 155 | All of which are optional except `type` with very logical default values. 156 | 157 | ### MongoDB 158 | 159 | To use mongodb storage you must install the 'mongodb' package in npm 160 | 161 | `npm install mongodb` 162 | 163 | Once you've done that, your config section should look like: 164 | 165 | ``` json 166 | { 167 | "type": "mongo", 168 | "connectionUrl": "mongodb://localhost:27017/database" 169 | } 170 | ``` 171 | 172 | You can also just set the environment variable for `DATABASE_URL` to your database connection url. 173 | 174 | Unlike with postgres you do NOT have to create the table in your mongo database prior to running. 175 | 176 | You can also set an `expire` option to the number of seconds to expire keys in. 177 | This is off by default, but will constantly kick back expirations on each view or post. 178 | 179 | ### Memcached 180 | 181 | To use memcache storage you must install the `memcached` package via npm 182 | 183 | `npm install memcached` 184 | 185 | Once you've done that, your config section should look like: 186 | 187 | ``` json 188 | { 189 | "type": "memcached", 190 | "host": "127.0.0.1", 191 | "port": 11211 192 | } 193 | ``` 194 | 195 | You can also set an `expire` option to the number of seconds to expire keys in. 196 | This behaves just like the redis expirations, but does not push expirations 197 | forward on GETs. 198 | 199 | All of which are optional except `type` with very logical default values. 200 | 201 | ### RethinkDB 202 | 203 | To use the RethinkDB storage system, you must install the `rethinkdbdash` package via npm 204 | 205 | `npm install rethinkdbdash` 206 | 207 | Once you've done that, your config section should look like this: 208 | 209 | ``` json 210 | { 211 | "type": "rethinkdb", 212 | "host": "127.0.0.1", 213 | "port": 28015, 214 | "db": "haste" 215 | } 216 | ``` 217 | 218 | In order for this to work, the database must be pre-created before the script is ran. 219 | Also, you must create an `uploads` table, which will store all the data for uploads. 220 | 221 | You can optionally add the `user` and `password` properties to use a user system. 222 | 223 | ### Google Datastore 224 | 225 | To use the Google Datastore storage system, you must install the `@google-cloud/datastore` package via npm 226 | 227 | `npm install @google-cloud/datastore` 228 | 229 | Once you've done that, your config section should look like this: 230 | 231 | ``` json 232 | { 233 | "type": "google-datastore" 234 | } 235 | ``` 236 | 237 | Authentication is handled automatically by [Google Cloud service account credentials](https://cloud.google.com/docs/authentication/getting-started), by providing authentication details to the GOOGLE_APPLICATION_CREDENTIALS environmental variable. 238 | 239 | ### Amazon S3 240 | 241 | To use [Amazon S3](https://aws.amazon.com/s3/) as a storage system, you must 242 | install the `aws-sdk` package via npm: 243 | 244 | `npm install aws-sdk` 245 | 246 | Once you've done that, your config section should look like this: 247 | 248 | ```json 249 | { 250 | "type": "amazon-s3", 251 | "bucket": "your-bucket-name", 252 | "region": "us-east-1" 253 | } 254 | ``` 255 | 256 | Authentication is handled automatically by the client. Check 257 | [Amazon's documentation](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html) 258 | for more information. You will need to grant your role these permissions to 259 | your bucket: 260 | 261 | ```json 262 | { 263 | "Version": "2012-10-17", 264 | "Statement": [ 265 | { 266 | "Action": [ 267 | "s3:GetObject", 268 | "s3:PutObject" 269 | ], 270 | "Effect": "Allow", 271 | "Resource": "arn:aws:s3:::your-bucket-name-goes-here/*" 272 | } 273 | ] 274 | } 275 | ``` 276 | 277 | ## Docker 278 | 279 | ### Build image 280 | 281 | ```bash 282 | docker build --tag haste-server . 283 | ``` 284 | 285 | ### Run container 286 | 287 | For this example we will run haste-server, and connect it to a redis server 288 | 289 | ```bash 290 | docker run --name haste-server-container --env STORAGE_TYPE=redis --env STORAGE_HOST=redis-server --env STORAGE_PORT=6379 haste-server 291 | ``` 292 | 293 | ### Use docker-compose example 294 | 295 | There is an example `docker-compose.yml` which runs haste-server together with memcached 296 | 297 | ```bash 298 | docker-compose up 299 | ``` 300 | 301 | ### Configuration 302 | 303 | The docker image is configured using environmental variables as you can see in the example above. 304 | 305 | Here is a list of all the environment variables 306 | 307 | ### Storage 308 | 309 | | Name | Default value | Description | 310 | | :--------------------: | :-----------: | :-----------------------------------------------------------------------------------------------------------: | 311 | | STORAGE_TYPE | memcached | Type of storage . Accepted values: "memcached","redis","postgres","rethinkdb", "amazon-s3", and "file" | 312 | | STORAGE_HOST | 127.0.0.1 | Storage host. Applicable for types: memcached, redis, postgres, and rethinkdb | 313 | | STORAGE_PORT | 11211 | Port on the storage host. Applicable for types: memcached, redis, postgres, and rethinkdb | 314 | | STORAGE_EXPIRE_SECONDS | 2592000 | Number of seconds to expire keys in. Applicable for types. Redis, postgres, memcached. `expire` option to the | 315 | | STORAGE_DB | 2 | The name of the database. Applicable for redis, postgres, and rethinkdb | 316 | | STORAGE_PASSWORD | | Password for database. Applicable for redis, postges, rethinkdb . | 317 | | STORAGE_USERNAME | | Database username. Applicable for postgres, and rethinkdb | 318 | | STORAGE_AWS_BUCKET | | Applicable for amazon-s3. This is the name of the S3 bucket | 319 | | STORAGE_AWS_REGION | | Applicable for amazon-s3. The region in which the bucket is located | 320 | | STORAGE_FILEPATH | | Path to file to save data to. Applicable for type file | 321 | 322 | ### Logging 323 | 324 | | Name | Default value | Description | 325 | | :---------------: | :-----------: | :---------: | 326 | | LOGGING_LEVEL | verbose | | 327 | | LOGGING_TYPE= | Console | 328 | | LOGGING_COLORIZE= | true | 329 | 330 | ### Basics 331 | 332 | | Name | Default value | Description | 333 | | :----------------------: | :--------------: | :---------------------------------------------------------------------------------------: | 334 | | HOST | 0.0.0.0 | The hostname which the server answers on | 335 | | PORT | 7777 | The port on which the server is running | 336 | | KEY_LENGTH | 10 | the length of the keys to user | 337 | | MAX_LENGTH | 400000 | maximum length of a paste | 338 | | STATIC_MAX_AGE | 86400 | max age for static assets | 339 | | RECOMPRESS_STATIC_ASSETS | true | whether or not to compile static js assets | 340 | | KEYGENERATOR_TYPE | phonetic | Type of key generator. Acceptable values: "phonetic", or "random" | 341 | | KEYGENERATOR_KEYSPACE | | keySpace argument is a string of acceptable characters | 342 | | DOCUMENTS | about=./about.md | Comma separated list of static documents to serve. ex: \n about=./about.md,home=./home.md | 343 | 344 | ### Rate limits 345 | 346 | | Name | Default value | Description | 347 | | :----------------------------------: | :-----------------------------------: | :--------------------------------------------------------------------------------------: | 348 | | RATELIMITS_NORMAL_TOTAL_REQUESTS | 500 | By default anyone uncategorized will be subject to 500 requests in the defined timespan. | 349 | | RATELIMITS_NORMAL_EVERY_MILLISECONDS | 60000 | The timespan to allow the total requests for uncategorized users | 350 | | RATELIMITS_WHITELIST_TOTAL_REQUESTS | | By default client names in the whitelist will not have their requests limited. | 351 | | RATELIMITS_WHITELIST_EVERY_SECONDS | | By default client names in the whitelist will not have their requests limited. | 352 | | RATELIMITS_WHITELIST | example1.whitelist,example2.whitelist | Comma separated list of the clients which are in the whitelist pool | 353 | | RATELIMITS_BLACKLIST_TOTAL_REQUESTS | | By default client names in the blacklist will be subject to 0 requests per hours. | 354 | | RATELIMITS_BLACKLIST_EVERY_SECONDS | | By default client names in the blacklist will be subject to 0 requests per hours | 355 | | RATELIMITS_BLACKLIST | example1.blacklist,example2.blacklist | Comma separated list of the clients which are in the blacklistpool. | 356 | 357 | ## Author 358 | 359 | John Crepezzi 360 | 361 | ## License 362 | 363 | (The MIT License) 364 | 365 | Copyright © 2011-2012 John Crepezzi 366 | 367 | Permission is hereby granted, free of charge, to any person obtaining a copy of 368 | this software and associated documentation files (the ‘Software’), to deal in 369 | the Software without restriction, including without limitation the rights to 370 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 371 | of the Software, and to permit persons to whom the Software is furnished to do 372 | so, subject to the following conditions: 373 | 374 | The above copyright notice and this permission notice shall be included in all 375 | copies or substantial portions of the Software. 376 | 377 | THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 378 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 379 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 380 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 381 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 382 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 383 | SOFTWARE 384 | 385 | ### Other components: 386 | 387 | * jQuery: MIT/GPL license 388 | * highlight.js: Copyright © 2006, Ivan Sagalaev 389 | * highlightjs-coffeescript: WTFPL - Copyright © 2011, Dmytrii Nagirniak 390 | -------------------------------------------------------------------------------- /static/highlight.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | Highlight.js 10.2.1 (32fb9a1d) 3 | License: BSD-3-Clause 4 | Copyright (c) 2006-2020, Ivan Sagalaev 5 | */ 6 | var hljs=function(){"use strict";function e(n){Object.freeze(n);var t="function"==typeof n;return Object.getOwnPropertyNames(n).forEach((function(r){!Object.hasOwnProperty.call(n,r)||null===n[r]||"object"!=typeof n[r]&&"function"!=typeof n[r]||t&&("caller"===r||"callee"===r||"arguments"===r)||Object.isFrozen(n[r])||e(n[r])})),n}class n{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data}ignoreMatch(){this.ignore=!0}}function t(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function r(e,...n){var t={};for(const n in e)t[n]=e[n];return n.forEach((function(e){for(const n in e)t[n]=e[n]})),t}function a(e){return e.nodeName.toLowerCase()}var i=Object.freeze({__proto__:null,escapeHTML:t,inherit:r,nodeStream:function(e){var n=[];return function e(t,r){for(var i=t.firstChild;i;i=i.nextSibling)3===i.nodeType?r+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:r,node:i}),r=e(i,r),a(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:r,node:i}));return r}(e,0),n},mergeStreams:function(e,n,r){var i=0,s="",o=[];function l(){return e.length&&n.length?e[0].offset!==n[0].offset?e[0].offset"}function u(e){s+=""}function g(e){("start"===e.event?c:u)(e.node)}for(;e.length||n.length;){var d=l();if(s+=t(r.substring(i,d[0].offset)),i=d[0].offset,d===e){o.reverse().forEach(u);do{g(d.splice(0,1)[0]),d=l()}while(d===e&&d.length&&d[0].offset===i);o.reverse().forEach(c)}else"start"===d[0].event?o.push(d[0].node):o.pop(),g(d.splice(0,1)[0])}return s+t(r.substr(i))}});const s="",o=e=>!!e.kind;class l{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=t(e)}openNode(e){if(!o(e))return;let n=e.kind;e.sublanguage||(n=`${this.classPrefix}${n}`),this.span(n)}closeNode(e){o(e)&&(this.buffer+=s)}value(){return this.buffer}span(e){this.buffer+=``}}class c{constructor(){this.rootNode={children:[]},this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const n={kind:e,children:[]};this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return"string"==typeof n?e.addText(n):n.children&&(e.openNode(n),n.children.forEach(n=>this._walk(e,n)),e.closeNode(n)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every(e=>"string"==typeof e)?e.children=[e.children.join("")]:e.children.forEach(e=>{c._collapse(e)}))}}class u extends c{constructor(e){super(),this.options=e}addKeyword(e,n){""!==e&&(this.openNode(n),this.addText(e),this.closeNode())}addText(e){""!==e&&this.add(e)}addSublanguage(e,n){const t=e.root;t.kind=n,t.sublanguage=!0,this.add(t)}toHTML(){return new l(this,this.options).value()}finalize(){return!0}}function g(e){return e?"string"==typeof e?e:e.source:null}const d="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",h={begin:"\\\\[\\s\\S]",relevance:0},f={className:"string",begin:"'",end:"'",illegal:"\\n",contains:[h]},p={className:"string",begin:'"',end:'"',illegal:"\\n",contains:[h]},m={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},b=function(e,n,t={}){var a=r({className:"comment",begin:e,end:n,contains:[]},t);return a.contains.push(m),a.contains.push({className:"doctag",begin:"(?:TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):",relevance:0}),a},v=b("//","$"),x=b("/\\*","\\*/"),E=b("#","$");var _=Object.freeze({__proto__:null,IDENT_RE:"[a-zA-Z]\\w*",UNDERSCORE_IDENT_RE:"[a-zA-Z_]\\w*",NUMBER_RE:"\\b\\d+(\\.\\d+)?",C_NUMBER_RE:d,BINARY_NUMBER_RE:"\\b(0b[01]+)",RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const n=/^#![ ]*\//;return e.binary&&(e.begin=function(...e){return e.map(e=>g(e)).join("")}(n,/.*\b/,e.binary,/\b.*/)),r({className:"meta",begin:n,end:/$/,relevance:0,"on:begin":(e,n)=>{0!==e.index&&n.ignoreMatch()}},e)},BACKSLASH_ESCAPE:h,APOS_STRING_MODE:f,QUOTE_STRING_MODE:p,PHRASAL_WORDS_MODE:m,COMMENT:b,C_LINE_COMMENT_MODE:v,C_BLOCK_COMMENT_MODE:x,HASH_COMMENT_MODE:E,NUMBER_MODE:{className:"number",begin:"\\b\\d+(\\.\\d+)?",relevance:0},C_NUMBER_MODE:{className:"number",begin:d,relevance:0},BINARY_NUMBER_MODE:{className:"number",begin:"\\b(0b[01]+)",relevance:0},CSS_NUMBER_MODE:{className:"number",begin:"\\b\\d+(\\.\\d+)?(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},REGEXP_MODE:{begin:/(?=\/[^/\n]*\/)/,contains:[{className:"regexp",begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[h,{begin:/\[/,end:/\]/,relevance:0,contains:[h]}]}]},TITLE_MODE:{className:"title",begin:"[a-zA-Z]\\w*",relevance:0},UNDERSCORE_TITLE_MODE:{className:"title",begin:"[a-zA-Z_]\\w*",relevance:0},METHOD_GUARD:{begin:"\\.\\s*[a-zA-Z_]\\w*",relevance:0},END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{n.data._beginMatch!==e[1]&&n.ignoreMatch()}})}}),w="of and for in not or if then".split(" ");function N(e,n){return n?+n:function(e){return w.includes(e.toLowerCase())}(e)?0:1}const y={props:["language","code","autodetect"],data:function(){return{detectedLanguage:"",unknownLanguage:!1}},computed:{className(){return this.unknownLanguage?"":"hljs "+this.detectedLanguage},highlighted(){if(!this.autoDetect&&!hljs.getLanguage(this.language))return console.warn(`The language "${this.language}" you specified could not be found.`),this.unknownLanguage=!0,t(this.code);let e;return this.autoDetect?(e=hljs.highlightAuto(this.code),this.detectedLanguage=e.language):(e=hljs.highlight(this.language,this.code,this.ignoreIllegals),this.detectectLanguage=this.language),e.value},autoDetect(){return!(this.language&&(e=this.autodetect,!e&&""!==e));var e},ignoreIllegals:()=>!0},render(e){return e("pre",{},[e("code",{class:this.className,domProps:{innerHTML:this.highlighted}})])}},R={install(e){e.component("highlightjs",y)}},k=t,M=r,{nodeStream:O,mergeStreams:L}=i,A=Symbol("nomatch");return function(t){var a=[],i=Object.create(null),s=Object.create(null),o=[],l=!0,c=/(^(<[^>]+>|\t|)+|\n)/gm,d="Could not find the language '{}', did you forget to load/include a language module?";const h={disableAutodetect:!0,name:"Plain text",contains:[]};var f={noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:null,__emitter:u};function p(e){return f.noHighlightRe.test(e)}function m(e,n,t,r){var a={code:n,language:e};j("before:highlight",a);var i=a.result?a.result:b(a.language,a.code,t,r);return i.code=a.code,j("after:highlight",i),i}function b(e,t,a,s){var o=t;function c(e,n){var t=E.case_insensitive?n[0].toLowerCase():n[0];return Object.prototype.hasOwnProperty.call(e.keywords,t)&&e.keywords[t]}function u(){null!=R.subLanguage?function(){if(""!==L){var e=null;if("string"==typeof R.subLanguage){if(!i[R.subLanguage])return void O.addText(L);e=b(R.subLanguage,L,!0,M[R.subLanguage]),M[R.subLanguage]=e.top}else e=v(L,R.subLanguage.length?R.subLanguage:null);R.relevance>0&&(I+=e.relevance),O.addSublanguage(e.emitter,e.language)}}():function(){if(!R.keywords)return void O.addText(L);let e=0;R.keywordPatternRe.lastIndex=0;let n=R.keywordPatternRe.exec(L),t="";for(;n;){t+=L.substring(e,n.index);const r=c(R,n);if(r){const[e,a]=r;O.addText(t),t="",I+=a,O.addKeyword(n[0],e)}else t+=n[0];e=R.keywordPatternRe.lastIndex,n=R.keywordPatternRe.exec(L)}t+=L.substr(e),O.addText(t)}(),L=""}function h(e){return e.className&&O.openNode(e.className),R=Object.create(e,{parent:{value:R}})}function p(e){return 0===R.matcher.regexIndex?(L+=e[0],1):(S=!0,0)}var m={};function x(t,r){var i=r&&r[0];if(L+=t,null==i)return u(),0;if("begin"===m.type&&"end"===r.type&&m.index===r.index&&""===i){if(L+=o.slice(r.index,r.index+1),!l){const n=Error("0 width match regex");throw n.languageName=e,n.badRule=m.rule,n}return 1}if(m=r,"begin"===r.type)return function(e){var t=e[0],r=e.rule;const a=new n(r),i=[r.__beforeBegin,r["on:begin"]];for(const n of i)if(n&&(n(e,a),a.ignore))return p(t);return r&&r.endSameAsBegin&&(r.endRe=RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"m")),r.skip?L+=t:(r.excludeBegin&&(L+=t),u(),r.returnBegin||r.excludeBegin||(L=t)),h(r),r.returnBegin?0:t.length}(r);if("illegal"===r.type&&!a){const e=Error('Illegal lexeme "'+i+'" for mode "'+(R.className||"")+'"');throw e.mode=R,e}if("end"===r.type){var s=function(e){var t=e[0],r=o.substr(e.index),a=function e(t,r,a){let i=function(e,n){var t=e&&e.exec(n);return t&&0===t.index}(t.endRe,a);if(i){if(t["on:end"]){const e=new n(t);t["on:end"](r,e),e.ignore&&(i=!1)}if(i){for(;t.endsParent&&t.parent;)t=t.parent;return t}}if(t.endsWithParent)return e(t.parent,r,a)}(R,e,r);if(!a)return A;var i=R;i.skip?L+=t:(i.returnEnd||i.excludeEnd||(L+=t),u(),i.excludeEnd&&(L=t));do{R.className&&O.closeNode(),R.skip||R.subLanguage||(I+=R.relevance),R=R.parent}while(R!==a.parent);return a.starts&&(a.endSameAsBegin&&(a.starts.endRe=a.endRe),h(a.starts)),i.returnEnd?0:t.length}(r);if(s!==A)return s}if("illegal"===r.type&&""===i)return 1;if(j>1e5&&j>3*r.index)throw Error("potential infinite loop, way more iterations than matches");return L+=i,i.length}var E=y(e);if(!E)throw console.error(d.replace("{}",e)),Error('Unknown language: "'+e+'"');var _=function(e){function n(n,t){return RegExp(g(n),"m"+(e.case_insensitive?"i":"")+(t?"g":""))}class t{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,n){n.position=this.position++,this.matchIndexes[this.matchAt]=n,this.regexes.push([n,e]),this.matchAt+=function(e){return RegExp(e.toString()+"|").exec("").length-1}(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map(e=>e[1]);this.matcherRe=n(function(e,n="|"){for(var t=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./,r=0,a="",i=0;i0&&(a+=n),a+="(";o.length>0;){var l=t.exec(o);if(null==l){a+=o;break}a+=o.substring(0,l.index),o=o.substring(l.index+l[0].length),"\\"===l[0][0]&&l[1]?a+="\\"+(+l[1]+s):(a+=l[0],"("===l[0]&&r++)}a+=")"}return a}(e),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const n=this.matcherRe.exec(e);if(!n)return null;const t=n.findIndex((e,n)=>n>0&&void 0!==e),r=this.matchIndexes[t];return n.splice(0,t),Object.assign(n,r)}}class a{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const n=new t;return this.rules.slice(e).forEach(([e,t])=>n.addRule(e,t)),n.compile(),this.multiRegexes[e]=n,n}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,n){this.rules.push([e,n]),"begin"===n.type&&this.count++}exec(e){const n=this.getMatcher(this.regexIndex);n.lastIndex=this.lastIndex;let t=n.exec(e);if(this.resumingScanAtSamePosition())if(t&&t.index===this.lastIndex);else{const n=this.getMatcher(0);n.lastIndex=this.lastIndex+1,t=n.exec(e)}return t&&(this.regexIndex+=t.position+1,this.regexIndex===this.count&&this.considerAll()),t}}function i(e,n){const t=e.input[e.index-1],r=e.input[e.index+e[0].length];"."!==t&&"."!==r||n.ignoreMatch()}if(e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return function t(s,o){const l=s;if(s.compiled)return l;s.compiled=!0,s.__beforeBegin=null,s.keywords=s.keywords||s.beginKeywords;let c=null;if("object"==typeof s.keywords&&(c=s.keywords.$pattern,delete s.keywords.$pattern),s.keywords&&(s.keywords=function(e,n){var t={};return"string"==typeof e?r("keyword",e):Object.keys(e).forEach((function(n){r(n,e[n])})),t;function r(e,r){n&&(r=r.toLowerCase()),r.split(" ").forEach((function(n){var r=n.split("|");t[r[0]]=[e,N(r[0],r[1])]}))}}(s.keywords,e.case_insensitive)),s.lexemes&&c)throw Error("ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) ");return l.keywordPatternRe=n(s.lexemes||c||/\w+/,!0),o&&(s.beginKeywords&&(s.begin="\\b("+s.beginKeywords.split(" ").join("|")+")(?=\\b|\\s)",s.__beforeBegin=i),s.begin||(s.begin=/\B|\b/),l.beginRe=n(s.begin),s.endSameAsBegin&&(s.end=s.begin),s.end||s.endsWithParent||(s.end=/\B|\b/),s.end&&(l.endRe=n(s.end)),l.terminator_end=g(s.end)||"",s.endsWithParent&&o.terminator_end&&(l.terminator_end+=(s.end?"|":"")+o.terminator_end)),s.illegal&&(l.illegalRe=n(s.illegal)),void 0===s.relevance&&(s.relevance=1),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map((function(e){return function(e){return e.variants&&!e.cached_variants&&(e.cached_variants=e.variants.map((function(n){return r(e,{variants:null},n)}))),e.cached_variants?e.cached_variants:function e(n){return!!n&&(n.endsWithParent||e(n.starts))}(e)?r(e,{starts:e.starts?r(e.starts):null}):Object.isFrozen(e)?r(e):e}("self"===e?s:e)}))),s.contains.forEach((function(e){t(e,l)})),s.starts&&t(s.starts,o),l.matcher=function(e){const n=new a;return e.contains.forEach(e=>n.addRule(e.begin,{rule:e,type:"begin"})),e.terminator_end&&n.addRule(e.terminator_end,{type:"end"}),e.illegal&&n.addRule(e.illegal,{type:"illegal"}),n}(l),l}(e)}(E),w="",R=s||_,M={},O=new f.__emitter(f);!function(){for(var e=[],n=R;n!==E;n=n.parent)n.className&&e.unshift(n.className);e.forEach(e=>O.openNode(e))}();var L="",I=0,T=0,j=0,S=!1;try{for(R.matcher.considerAll();;){j++,S?S=!1:R.matcher.considerAll(),R.matcher.lastIndex=T;const e=R.matcher.exec(o);if(!e)break;const n=x(o.substring(T,e.index),e);T=e.index+n}return x(o.substr(T)),O.closeAllNodes(),O.finalize(),w=O.toHTML(),{relevance:I,value:w,language:e,illegal:!1,emitter:O,top:R}}catch(n){if(n.message&&n.message.includes("Illegal"))return{illegal:!0,illegalBy:{msg:n.message,context:o.slice(T-100,T+100),mode:n.mode},sofar:w,relevance:0,value:k(o),emitter:O};if(l)return{illegal:!1,relevance:0,value:k(o),emitter:O,language:e,top:R,errorRaised:n};throw n}}function v(e,n){n=n||f.languages||Object.keys(i);var t=function(e){const n={relevance:0,emitter:new f.__emitter(f),value:k(e),illegal:!1,top:h};return n.emitter.addText(e),n}(e),r=t;return n.filter(y).filter(T).forEach((function(n){var a=b(n,e,!1);a.language=n,a.relevance>r.relevance&&(r=a),a.relevance>t.relevance&&(r=t,t=a)})),r.language&&(t.second_best=r),t}function x(e){return f.tabReplace||f.useBR?e.replace(c,e=>"\n"===e?f.useBR?"
":e:f.tabReplace?e.replace(/\t/g,f.tabReplace):e):e}function E(e){let n=null;const t=function(e){var n=e.className+" ";n+=e.parentNode?e.parentNode.className:"";const t=f.languageDetectRe.exec(n);if(t){var r=y(t[1]);return r||(console.warn(d.replace("{}",t[1])),console.warn("Falling back to no-highlight mode for this block.",e)),r?t[1]:"no-highlight"}return n.split(/\s+/).find(e=>p(e)||y(e))}(e);if(p(t))return;j("before:highlightBlock",{block:e,language:t}),f.useBR?(n=document.createElement("div")).innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n"):n=e;const r=n.textContent,a=t?m(t,r,!0):v(r),i=O(n);if(i.length){const e=document.createElement("div");e.innerHTML=a.value,a.value=L(i,O(e),r)}a.value=x(a.value),j("after:highlightBlock",{block:e,result:a}),e.innerHTML=a.value,e.className=function(e,n,t){var r=n?s[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),e.includes(r)||a.push(r),a.join(" ").trim()}(e.className,t,a.language),e.result={language:a.language,re:a.relevance,relavance:a.relevance},a.second_best&&(e.second_best={language:a.second_best.language,re:a.second_best.relevance,relavance:a.second_best.relevance})}const w=()=>{if(!w.called){w.called=!0;var e=document.querySelectorAll("pre code");a.forEach.call(e,E)}};function y(e){return e=(e||"").toLowerCase(),i[e]||i[s[e]]}function I(e,{languageName:n}){"string"==typeof e&&(e=[e]),e.forEach(e=>{s[e]=n})}function T(e){var n=y(e);return n&&!n.disableAutodetect}function j(e,n){var t=e;o.forEach((function(e){e[t]&&e[t](n)}))}Object.assign(t,{highlight:m,highlightAuto:v,fixMarkup:function(e){return console.warn("fixMarkup is deprecated and will be removed entirely in v11.0"),console.warn("Please see https://github.com/highlightjs/highlight.js/issues/2534"),x(e)},highlightBlock:E,configure:function(e){f=M(f,e)},initHighlighting:w,initHighlightingOnLoad:function(){window.addEventListener("DOMContentLoaded",w,!1)},registerLanguage:function(e,n){var r=null;try{r=n(t)}catch(n){if(console.error("Language definition for '{}' could not be registered.".replace("{}",e)),!l)throw n;console.error(n),r=h}r.name||(r.name=e),i[e]=r,r.rawDefinition=n.bind(null,t),r.aliases&&I(r.aliases,{languageName:e})},listLanguages:function(){return Object.keys(i)},getLanguage:y,registerAliases:I,requireLanguage:function(e){var n=y(e);if(n)return n;throw Error("The '{}' language is required, but not loaded.".replace("{}",e))},autoDetection:T,inherit:M,addPlugin:function(e){o.push(e)},vuePlugin:R}),t.debugMode=function(){l=!1},t.safeMode=function(){l=!0},t.versionString="10.2.1";for(const n in _)"object"==typeof _[n]&&e(_[n]);return Object.assign(t,_),t}({})}();"object"==typeof exports&&"undefined"!=typeof module&&(module.exports=hljs);hljs.registerLanguage("lua",function(){"use strict";return function(e){var t={begin:"\\[=*\\[",end:"\\]=*\\]",contains:["self"]},a=[e.COMMENT("--(?!\\[=*\\[)","$"),e.COMMENT("--\\[=*\\[","\\]=*\\]",{contains:[t],relevance:10})];return{name:"Lua",keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:a.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:a}].concat(a)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:"\\[=*\\[",end:"\\]=*\\]",contains:[t],relevance:5}])}}}());hljs.registerLanguage("kotlin",function(){"use strict";return function(e){var n={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},a={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},i={className:"subst",begin:"\\${",end:"}",contains:[e.C_NUMBER_MODE]},s={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},t={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[s,i]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,s,i]}]};i.contains.push(t);var r={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},l={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(t,{className:"meta-string"})]}]},c=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),o={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},d=o;return d.variants[1].contains=[o],o.variants[1].contains=[d],{name:"Kotlin",aliases:["kt"],keywords:n,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,c,{className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},a,r,l,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:n,illegal:/fun\s+(<.*>)?[^\s\(]+(\s+[^\s\(]+)\s*=/,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin://,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:n,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[o,e.C_LINE_COMMENT_MODE,c],relevance:0},e.C_LINE_COMMENT_MODE,c,r,l,t,e.C_NUMBER_MODE]},c]},{className:"class",beginKeywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},e.UNDERSCORE_TITLE_MODE,{className:"type",begin://,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,]|$/,excludeBegin:!0,returnEnd:!0},r,l]},t,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:"\n"},{className:"number",begin:"\\b(0[bB]([01]+[01_]+[01]+|[01]+)|0[xX]([a-fA-F0-9]+[a-fA-F0-9_]+[a-fA-F0-9]+|[a-fA-F0-9]+)|(([\\d]+[\\d_]+[\\d]+|[\\d]+)(\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))?|\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))([eE][-+]?\\d+)?)[lLfF]?",relevance:0}]}}}());hljs.registerLanguage("ruby",function(){"use strict";return function(e){var n="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",a={keyword:"and then defined module in return redo if BEGIN retry end for self when next until do begin unless END rescue else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor",literal:"true false nil"},s={className:"doctag",begin:"@[A-Za-z]+"},i={begin:"#<",end:">"},r=[e.COMMENT("#","$",{contains:[s]}),e.COMMENT("^\\=begin","^\\=end",{contains:[s],relevance:10}),e.COMMENT("^__END__","\\n$")],c={className:"subst",begin:"#\\{",end:"}",keywords:a},t={className:"string",contains:[e.BACKSLASH_ESCAPE,c],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:"%[qQwWx]?\\(",end:"\\)"},{begin:"%[qQwWx]?\\[",end:"\\]"},{begin:"%[qQwWx]?{",end:"}"},{begin:"%[qQwWx]?<",end:">"},{begin:"%[qQwWx]?/",end:"/"},{begin:"%[qQwWx]?%",end:"%"},{begin:"%[qQwWx]?-",end:"-"},{begin:"%[qQwWx]?\\|",end:"\\|"},{begin:/\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/},{begin:/<<[-~]?'?(\w+)(?:.|\n)*?\n\s*\1\b/,returnBegin:!0,contains:[{begin:/<<[-~]?'?/},e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,c]})]}]},b={className:"params",begin:"\\(",end:"\\)",endsParent:!0,keywords:a},d=[t,i,{className:"class",beginKeywords:"class module",end:"$|;",illegal:/=/,contains:[e.inherit(e.TITLE_MODE,{begin:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?"}),{begin:"<\\s*",contains:[{begin:"("+e.IDENT_RE+"::)?"+e.IDENT_RE}]}].concat(r)},{className:"function",beginKeywords:"def",end:"$|;",contains:[e.inherit(e.TITLE_MODE,{begin:n}),b].concat(r)},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(\\!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[t,{begin:n}],relevance:0},{className:"number",begin:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",relevance:0},{begin:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{className:"params",begin:/\|/,end:/\|/,keywords:a},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[i,{className:"regexp",contains:[e.BACKSLASH_ESCAPE,c],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:"%r{",end:"}[a-z]*"},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(r),relevance:0}].concat(r);c.contains=d,b.contains=d;var g=[{begin:/^\s*=>/,starts:{end:"$",contains:d}},{className:"meta",begin:"^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+>|(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>)",starts:{end:"$",contains:d}}];return{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:a,illegal:/\/\*/,contains:r.concat(g).concat(d)}}}());hljs.registerLanguage("rust",function(){"use strict";return function(e){var n="([ui](8|16|32|64|128|size)|f(32|64))?",t="drop i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize f32 f64 str char bool Box Option Result String Vec Copy Send Sized Sync Drop Fn FnMut FnOnce ToOwned Clone Debug PartialEq PartialOrd Eq Ord AsRef AsMut Into From Default Iterator Extend IntoIterator DoubleEndedIterator ExactSizeIterator SliceConcatExt ToString assert! assert_eq! bitflags! bytes! cfg! col! concat! concat_idents! debug_assert! debug_assert_eq! env! panic! file! format! format_args! include_bin! include_str! line! local_data_key! module_path! option_env! print! println! select! stringify! try! unimplemented! unreachable! vec! write! writeln! macro_rules! assert_ne! debug_assert_ne!";return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",keyword:"abstract as async await become box break const continue crate do dyn else enum extern false final fn for if impl in let loop macro match mod move mut override priv pub ref return self Self static struct super trait true try type typeof unsafe unsized use virtual where while yield",literal:"true false Some None Ok Err",built_in:t},illegal:""}]}}}());hljs.registerLanguage("go",function(){"use strict";return function(e){var n={keyword:"break default func interface select case map struct chan else goto package switch const fallthrough if range type continue for import return var go defer bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 uint16 uint32 uint64 int uint uintptr rune",literal:"true false iota nil",built_in:"append cap close complex copy imag len make new panic print println real recover delete"};return{name:"Go",aliases:["golang"],keywords:n,illegal:"")+")",r={className:"keyword",begin:"\\b[a-z\\d_]*_t\\b"},a={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},i={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},s={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{"meta-keyword":"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(a,{className:"meta-string"}),{className:"meta-string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},o={className:"title",begin:t("[a-zA-Z_]\\w*::")+e.IDENT_RE,relevance:0},c=t("[a-zA-Z_]\\w*::")+e.IDENT_RE+"\\s*\\(",l={keyword:"int float while private char char8_t char16_t char32_t catch import module export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using asm case typeid wchar_t short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignas alignof constexpr consteval constinit decltype concept co_await co_return co_yield requires noexcept static_assert thread_local restrict final override atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr _Bool complex _Complex imaginary _Imaginary",literal:"true false nullptr NULL"},d=[r,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,i,a],_={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:l,contains:d.concat([{begin:/\(/,end:/\)/,keywords:l,contains:d.concat(["self"]),relevance:0}]),relevance:0},u={className:"function",begin:"("+n+"[\\*&\\s]+)+"+c,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:l,illegal:/[^\w\s\*&:<>]/,contains:[{begin:"decltype\\(auto\\)",keywords:l,relevance:0},{begin:c,returnBegin:!0,contains:[o],relevance:0},{className:"params",begin:/\(/,end:/\)/,keywords:l,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,i,r,{begin:/\(/,end:/\)/,keywords:l,relevance:0,contains:["self",e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,i,r]}]},r,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s]};return{aliases:["c","cc","h","c++","h++","hpp","hh","hxx","cxx"],keywords:l,disableAutodetect:!0,illegal:"",keywords:l,contains:["self",r]},{begin:e.IDENT_RE+"::",keywords:l},{className:"class",beginKeywords:"class struct",end:/[{;:]/,contains:[{begin://,contains:["self"]},e.TITLE_MODE]}]),exports:{preprocessor:s,strings:a,keywords:l}}}}());hljs.registerLanguage("c",function(){"use strict";return function(e){var n=e.requireLanguage("c-like").rawDefinition();return n.name="C",n.aliases=["c","h"],n}}());hljs.registerLanguage("python",function(){"use strict";return function(e){var n={keyword:"and elif is global as in if from raise for except finally print import pass return exec else break not with class assert yield try while continue del or def lambda async await nonlocal|10",built_in:"Ellipsis NotImplemented",literal:"False None True"},a={className:"meta",begin:/^(>>>|\.\.\.) /},i={className:"subst",begin:/\{/,end:/\}/,keywords:n,illegal:/#/},s={begin:/\{\{/,relevance:0},r={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/(u|b)?r?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/(u|b)?r?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/(fr|rf|f)'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a,s,i]},{begin:/(fr|rf|f)"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,s,i]},{begin:/(u|r|ur)'/,end:/'/,relevance:10},{begin:/(u|r|ur)"/,end:/"/,relevance:10},{begin:/(b|br)'/,end:/'/},{begin:/(b|br)"/,end:/"/},{begin:/(fr|rf|f)'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,s,i]},{begin:/(fr|rf|f)"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,i]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},l={className:"number",relevance:0,variants:[{begin:e.BINARY_NUMBER_RE+"[lLjJ]?"},{begin:"\\b(0o[0-7]+)[lLjJ]?"},{begin:e.C_NUMBER_RE+"[lLjJ]?"}]},t={className:"params",variants:[{begin:/\(\s*\)/,skip:!0,className:null},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,contains:["self",a,l,r,e.HASH_COMMENT_MODE]}]};return i.contains=[r,l,a],{name:"Python",aliases:["py","gyp","ipython"],keywords:n,illegal:/(<\/|->|\?)|=>/,contains:[a,l,{beginKeywords:"if",relevance:0},r,e.HASH_COMMENT_MODE,{variants:[{className:"function",beginKeywords:"def"},{className:"class",beginKeywords:"class"}],end:/:/,illegal:/[${=;\n,]/,contains:[e.UNDERSCORE_TITLE_MODE,t,{begin:/->/,endsWithParent:!0,keywords:"None"}]},{className:"meta",begin:/^[\t ]*@/,end:/$/},{begin:/\b(print|exec)\(/}]}}}());hljs.registerLanguage("python-repl",function(){"use strict";return function(n){return{aliases:["pycon"],contains:[{className:"meta",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}}());hljs.registerLanguage("java",function(){"use strict";function e(e){return e?"string"==typeof e?e:e.source:null}function n(e){return a("(",e,")?")}function a(...n){return n.map(n=>e(n)).join("")}function s(...n){return"("+n.map(n=>e(n)).join("|")+")"}return function(e){var t="false synchronized int abstract float private char boolean var static null if const for true while long strictfp finally protected import native final void enum else break transient catch instanceof byte super volatile case assert short package default double public try this switch continue throws protected public private module requires exports do",i={className:"meta",begin:"@[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},r=e=>a("[",e,"]+([",e,"_]*[",e,"]+)?"),c={className:"number",variants:[{begin:`\\b(0[bB]${r("01")})[lL]?`},{begin:`\\b(0${r("0-7")})[dDfFlL]?`},{begin:a(/\b0[xX]/,s(a(r("a-fA-F0-9"),/\./,r("a-fA-F0-9")),a(r("a-fA-F0-9"),/\.?/),a(/\./,r("a-fA-F0-9"))),/([pP][+-]?(\d+))?/,/[fFdDlL]?/)},{begin:a(/\b/,s(a(/\d*\./,r("\\d")),r("\\d")),/[eE][+-]?[\d]+[dDfF]?/)},{begin:a(/\b/,r(/\d/),n(/\.?/),n(r(/\d/)),/[dDfFlL]?/)}],relevance:0};return{name:"Java",aliases:["jsp"],keywords:t,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"class",beginKeywords:"class interface enum",end:/[{;=]/,excludeEnd:!0,keywords:"class interface enum",illegal:/[:"\[\]]/,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"new throw return else",relevance:0},{className:"function",begin:"([À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*(<[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*(\\s*,\\s*[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*)*>)?\\s+)+"+e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:t,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"params",begin:/\(/,end:/\)/,keywords:t,relevance:0,contains:[i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},c,i]}}}());hljs.registerLanguage("php",function(){"use strict";return function(e){var r={begin:"\\$+[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*"},t={className:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?[=]?/},{begin:/\?>/}]},a={className:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},n=e.inherit(e.APOS_STRING_MODE,{illegal:null}),i=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(a)}),o=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*(\w+)\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(a)}),l={className:"string",contains:[e.BACKSLASH_ESCAPE,t],variants:[e.inherit(n,{begin:"b'",end:"'"}),e.inherit(i,{begin:'b"',end:'"'}),i,n,o]},s={variants:[e.BINARY_NUMBER_MODE,e.C_NUMBER_MODE]},c={keyword:"__CLASS__ __DIR__ __FILE__ __FUNCTION__ __LINE__ __METHOD__ __NAMESPACE__ __TRAIT__ die echo exit include include_once print require require_once array abstract and as binary bool boolean break callable case catch class clone const continue declare default do double else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval extends final finally float for foreach from global goto if implements instanceof insteadof int integer interface isset iterable list new object or private protected public real return string switch throw trait try unset use var void while xor yield",literal:"false null true",built_in:"Error|0 AppendIterator ArgumentCountError ArithmeticError ArrayIterator ArrayObject AssertionError BadFunctionCallException BadMethodCallException CachingIterator CallbackFilterIterator CompileError Countable DirectoryIterator DivisionByZeroError DomainException EmptyIterator ErrorException Exception FilesystemIterator FilterIterator GlobIterator InfiniteIterator InvalidArgumentException IteratorIterator LengthException LimitIterator LogicException MultipleIterator NoRewindIterator OutOfBoundsException OutOfRangeException OuterIterator OverflowException ParentIterator ParseError RangeException RecursiveArrayIterator RecursiveCachingIterator RecursiveCallbackFilterIterator RecursiveDirectoryIterator RecursiveFilterIterator RecursiveIterator RecursiveIteratorIterator RecursiveRegexIterator RecursiveTreeIterator RegexIterator RuntimeException SeekableIterator SplDoublyLinkedList SplFileInfo SplFileObject SplFixedArray SplHeap SplMaxHeap SplMinHeap SplObjectStorage SplObserver SplObserver SplPriorityQueue SplQueue SplStack SplSubject SplSubject SplTempFileObject TypeError UnderflowException UnexpectedValueException ArrayAccess Closure Generator Iterator IteratorAggregate Serializable Throwable Traversable WeakReference Directory __PHP_Incomplete_Class parent php_user_filter self static stdClass"};return{aliases:["php","php3","php4","php5","php6","php7"],case_insensitive:!0,keywords:c,contains:[e.HASH_COMMENT_MODE,e.COMMENT("//","$",{contains:[t]}),e.COMMENT("/\\*","\\*/",{contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.COMMENT("__halt_compiler.+?;",!1,{endsWithParent:!0,keywords:"__halt_compiler"}),t,{className:"keyword",begin:/\$this\b/},r,{begin:/(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/},{className:"function",beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[e.UNDERSCORE_TITLE_MODE,{className:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",r,e.C_BLOCK_COMMENT_MODE,l,s]}]},{className:"class",beginKeywords:"class interface",end:"{",excludeEnd:!0,illegal:/[:\(\$"]/,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",end:";",illegal:/[\.']/,contains:[e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"use",end:";",contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"=>"},l,s]}}}());hljs.registerLanguage("cpp",function(){"use strict";return function(e){var i=e.requireLanguage("c-like").rawDefinition();return i.disableAutodetect=!1,i.name="C++",i.aliases=["cc","c++","h++","hpp","hh","hxx","cxx"],i}}());hljs.registerLanguage("scss",function(){"use strict";return function(e){var t={className:"variable",begin:"(\\$[a-zA-Z-][a-zA-Z0-9_-]*)\\b"},i={className:"number",begin:"#[0-9A-Fa-f]+"};return e.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,e.C_BLOCK_COMMENT_MODE,{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"selector-id",begin:"\\#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},{className:"selector-attr",begin:"\\[",end:"\\]",illegal:"$"},{className:"selector-tag",begin:"\\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|samp|script|section|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\\b",relevance:0},{className:"selector-pseudo",begin:":(visited|valid|root|right|required|read-write|read-only|out-range|optional|only-of-type|only-child|nth-of-type|nth-last-of-type|nth-last-child|nth-child|not|link|left|last-of-type|last-child|lang|invalid|indeterminate|in-range|hover|focus|first-of-type|first-line|first-letter|first-child|first|enabled|empty|disabled|default|checked|before|after|active)"},{className:"selector-pseudo",begin:"::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)"},t,{className:"attribute",begin:"\\b(src|z-index|word-wrap|word-spacing|word-break|width|widows|white-space|visibility|vertical-align|unicode-bidi|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform|top|text-underline-position|text-transform|text-shadow|text-rendering|text-overflow|text-indent|text-decoration-style|text-decoration-line|text-decoration-color|text-decoration|text-align-last|text-align|tab-size|table-layout|right|resize|quotes|position|pointer-events|perspective-origin|perspective|page-break-inside|page-break-before|page-break-after|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-y|overflow-x|overflow-wrap|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|order|opacity|object-position|object-fit|normal|none|nav-up|nav-right|nav-left|nav-index|nav-down|min-width|min-height|max-width|max-height|mask|marks|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|letter-spacing|left|justify-content|initial|inherit|ime-mode|image-orientation|image-resolution|image-rendering|icon|hyphens|height|font-weight|font-variant-ligatures|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|float|flex-wrap|flex-shrink|flex-grow|flex-flow|flex-direction|flex-basis|flex|filter|empty-cells|display|direction|cursor|counter-reset|counter-increment|content|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|columns|color|clip-path|clip|clear|caption-side|break-inside|break-before|break-after|box-sizing|box-shadow|box-decoration-break|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-left-width|border-left-style|border-left-color|border-left|border-image-width|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border|background-size|background-repeat|background-position|background-origin|background-image|background-color|background-clip|background-attachment|background-blend-mode|background|backface-visibility|auto|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|align-self|align-items|align-content)\\b",illegal:"[^\\s]"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:":",end:";",contains:[t,i,e.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"meta",begin:"!important"}]},{begin:"@(page|font-face)",lexemes:"@[a-z-]+",keywords:"@page @font-face"},{begin:"@",end:"[{;]",returnBegin:!0,keywords:"and or not only",contains:[{begin:"@[a-z-]+",className:"keyword"},t,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,i,e.CSS_NUMBER_MODE]}]}}}());hljs.registerLanguage("plaintext",function(){"use strict";return function(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}}());hljs.registerLanguage("apache",function(){"use strict";return function(e){var n={className:"number",begin:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?"};return{name:"Apache config",aliases:["apacheconf"],case_insensitive:!0,contains:[e.HASH_COMMENT_MODE,{className:"section",begin:"",contains:[n,{className:"number",begin:":\\d{1,5}"},e.inherit(e.QUOTE_STRING_MODE,{relevance:0})]},{className:"attribute",begin:/\w+/,relevance:0,keywords:{nomarkup:"order deny allow setenv rewriterule rewriteengine rewritecond documentroot sethandler errordocument loadmodule options header listen serverroot servername"},starts:{end:/$/,relevance:0,keywords:{literal:"on off all deny allow"},contains:[{className:"meta",begin:"\\s\\[",end:"\\]$"},{className:"variable",begin:"[\\$%]\\{",end:"\\}",contains:["self",{className:"number",begin:"[\\$%]\\d+"}]},n,{className:"number",begin:"\\d+"},e.QUOTE_STRING_MODE]}}],illegal:/\S/}}}());hljs.registerLanguage("makefile",function(){"use strict";return function(e){var i={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,contains:[{className:"meta",begin:"",relevance:10,contains:[a,i,t,s,{begin:"\\[",end:"\\]",contains:[{className:"meta",begin:"",contains:[a,s,i,t]}]}]},e.COMMENT("\x3c!--","--\x3e",{relevance:10}),{begin:"<\\!\\[CDATA\\[",end:"\\]\\]>",relevance:10},n,{className:"meta",begin:/<\?xml/,end:/\?>/,relevance:10},{className:"tag",begin:")",end:">",keywords:{name:"style"},contains:[c],starts:{end:"",returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:")",end:">",keywords:{name:"script"},contains:[c],starts:{end:"<\/script>",returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:"",contains:[{className:"name",begin:/[^\/><\s]+/,relevance:0},c]}]}}}());hljs.registerLanguage("php-template",function(){"use strict";return function(n){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},n.inherit(n.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),n.inherit(n.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}}());hljs.registerLanguage("perl",function(){"use strict";return function(e){var n={$pattern:/[\w.]+/,keyword:"getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qq fileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent shutdown dump chomp connect getsockname die socketpair close flock exists index shmget sub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline endhostent times chop length gethostent getnetent pack getprotoent getservbyname rand mkdir pos chmod y|0 substr endnetent printf next open msgsnd readdir use unlink getsockopt getpriority rindex wantarray hex system getservbyport endservent int chr untie rmdir prototype tell listen fork shmread ucfirst setprotoent else sysseek link getgrgid shmctl waitpid unpack getnetbyname reset chdir grep split require caller lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedir ioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when"},t={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:n},s={begin:"->{",end:"}"},r={variants:[{begin:/\$\d/},{begin:/[\$%@](\^\w\b|#\w+(::\w+)*|{\w+}|\w+(::\w*)*)/},{begin:/[\$%@][^\s\w{]/,relevance:0}]},i=[e.BACKSLASH_ESCAPE,t,r],a=[r,e.HASH_COMMENT_MODE,e.COMMENT("^\\=\\w","\\=cut",{endsWithParent:!0}),s,{className:"string",contains:i,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*\\<",end:"\\>",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:"{\\w+}",contains:[],relevance:0},{begin:"-?\\w+\\s*\\=\\>",contains:[],relevance:0}]},{className:"number",begin:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",relevance:0},{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",begin:"(s|tr|y)/(\\\\.|[^/])*/(\\\\.|[^/])*/[a-z]*",relevance:10},{className:"regexp",begin:"(m|qr)?/",end:"/[a-z]*",contains:[e.BACKSLASH_ESCAPE],relevance:0}]},{className:"function",beginKeywords:"sub",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return t.contains=a,s.contains=a,{name:"Perl",aliases:["pl","pm"],keywords:n,contains:a}}}());hljs.registerLanguage("shell",function(){"use strict";return function(s){return{name:"Shell Session",aliases:["console"],contains:[{className:"meta",begin:"^\\s{0,3}[/\\w\\d\\[\\]()@-]*[>%$#]",starts:{end:"$",subLanguage:"bash"}}]}}}());hljs.registerLanguage("objectivec",function(){"use strict";return function(e){var n=/[a-zA-Z@][a-zA-Z0-9_]*/,_={$pattern:n,keyword:"@interface @class @protocol @implementation"};return{name:"Objective-C",aliases:["mm","objc","obj-c"],keywords:{$pattern:n,keyword:"int float while char export sizeof typedef const struct for union unsigned long volatile static bool mutable if do return goto void enum else break extern asm case short default double register explicit signed typename this switch continue wchar_t inline readonly assign readwrite self @synchronized id typeof nonatomic super unichar IBOutlet IBAction strong weak copy in out inout bycopy byref oneway __strong __weak __block __autoreleasing @private @protected @public @try @property @end @throw @catch @finally @autoreleasepool @synthesize @dynamic @selector @optional @required @encode @package @import @defs @compatibility_alias __bridge __bridge_transfer __bridge_retained __bridge_retain __covariant __contravariant __kindof _Nonnull _Nullable _Null_unspecified __FUNCTION__ __PRETTY_FUNCTION__ __attribute__ getter setter retain unsafe_unretained nonnull nullable null_unspecified null_resettable class instancetype NS_DESIGNATED_INITIALIZER NS_UNAVAILABLE NS_REQUIRES_SUPER NS_RETURNS_INNER_POINTER NS_INLINE NS_AVAILABLE NS_DEPRECATED NS_ENUM NS_OPTIONS NS_SWIFT_UNAVAILABLE NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_REFINED_FOR_SWIFT NS_SWIFT_NAME NS_SWIFT_NOTHROW NS_DURING NS_HANDLER NS_ENDHANDLER NS_VALUERETURN NS_VOIDRETURN",literal:"false true FALSE TRUE nil YES NO NULL",built_in:"BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once"},illegal:"/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+_.keyword.split(" ").join("|")+")\\b",end:"({|$)",excludeEnd:!0,keywords:_,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}}());hljs.registerLanguage("nginx",function(){"use strict";return function(e){var n={className:"variable",variants:[{begin:/\$\d+/},{begin:/\$\{/,end:/}/},{begin:"[\\$\\@]"+e.UNDERSCORE_IDENT_RE}]},a={endsWithParent:!0,keywords:{$pattern:"[a-z/_]+",literal:"on off yes no true false none blocked debug info notice warn error crit select break last permanent redirect kqueue rtsig epoll poll /dev/poll"},relevance:0,illegal:"=>",contains:[e.HASH_COMMENT_MODE,{className:"string",contains:[e.BACKSLASH_ESCAPE,n],variants:[{begin:/"/,end:/"/},{begin:/'/,end:/'/}]},{begin:"([a-z]+):/",end:"\\s",endsWithParent:!0,excludeEnd:!0,contains:[n]},{className:"regexp",contains:[e.BACKSLASH_ESCAPE,n],variants:[{begin:"\\s\\^",end:"\\s|{|;",returnEnd:!0},{begin:"~\\*?\\s+",end:"\\s|{|;",returnEnd:!0},{begin:"\\*(\\.[a-z\\-]+)+"},{begin:"([a-z\\-]+\\.)+\\*"}]},{className:"number",begin:"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b"},{className:"number",begin:"\\b\\d+[kKmMgGdshdwy]*\\b",relevance:0},n]};return{name:"Nginx config",aliases:["nginxconf"],contains:[e.HASH_COMMENT_MODE,{begin:e.UNDERSCORE_IDENT_RE+"\\s+{",returnBegin:!0,end:"{",contains:[{className:"section",begin:e.UNDERSCORE_IDENT_RE}],relevance:0},{begin:e.UNDERSCORE_IDENT_RE+"\\s",end:";|{",returnBegin:!0,contains:[{className:"attribute",begin:e.UNDERSCORE_IDENT_RE,starts:a}],relevance:0}],illegal:"[^\\s\\}]"}}}());hljs.registerLanguage("csharp",function(){"use strict";return function(e){var n={keyword:"abstract as base bool break byte case catch char checked const continue decimal default delegate do double enum event explicit extern finally fixed float for foreach goto if implicit in init int interface internal is lock long object operator out override params private protected public readonly ref sbyte sealed short sizeof stackalloc static string struct switch this try typeof uint ulong unchecked unsafe ushort using virtual void volatile while add alias ascending async await by descending dynamic equals from get global group into join let nameof on orderby partial remove select set value var when where yield",literal:"null false true"},i=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),a={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},s={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},t=e.inherit(s,{illegal:/\n/}),l={className:"subst",begin:"{",end:"}",keywords:n},r=e.inherit(l,{illegal:/\n/}),c={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:"{{"},{begin:"}}"},e.BACKSLASH_ESCAPE,r]},o={className:"string",begin:/\$@"/,end:'"',contains:[{begin:"{{"},{begin:"}}"},{begin:'""'},l]},g=e.inherit(o,{illegal:/\n/,contains:[{begin:"{{"},{begin:"}}"},{begin:'""'},r]});l.contains=[o,c,s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.C_BLOCK_COMMENT_MODE],r.contains=[g,c,t,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];var d={variants:[o,c,s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},E={begin:"<",end:">",contains:[{beginKeywords:"in out"},i]},_=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",b={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:n,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"\x3c!--|--\x3e"},{begin:""}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{"meta-keyword":"if else elif endif define undef warning error line region endregion pragma checksum"}},d,a,{beginKeywords:"class interface",end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},i,E,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",end:/[{;=]/,illegal:/[^\s:]/,contains:[i,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",end:/[{;=]/,illegal:/[^\s:]/,contains:[i,E,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"meta-string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+_+"\\s+)+"+e.IDENT_RE+"\\s*(\\<.+\\>)?\\s*\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:n,contains:[{begin:e.IDENT_RE+"\\s*(\\<.+\\>)?\\s*\\(",returnBegin:!0,contains:[e.TITLE_MODE,E],relevance:0},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:n,relevance:0,contains:[d,a,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},b]}}}());hljs.registerLanguage("sql",function(){"use strict";return function(e){var t=e.COMMENT("--","$");return{name:"SQL",case_insensitive:!0,illegal:/[<>{}*]/,contains:[{beginKeywords:"begin end start commit rollback savepoint lock alter create drop rename call delete do handler insert load replace select truncate update set show pragma grant merge describe use explain help declare prepare execute deallocate release unlock purge reset change stop analyze cache flush optimize repair kill install uninstall checksum restore check backup revoke comment values with",end:/;/,endsWithParent:!0,keywords:{$pattern:/[\w\.]+/,keyword:"as abort abs absolute acc acce accep accept access accessed accessible account acos action activate add addtime admin administer advanced advise aes_decrypt aes_encrypt after agent aggregate ali alia alias all allocate allow alter always analyze ancillary and anti any anydata anydataset anyschema anytype apply archive archived archivelog are as asc ascii asin assembly assertion associate asynchronous at atan atn2 attr attri attrib attribu attribut attribute attributes audit authenticated authentication authid authors auto autoallocate autodblink autoextend automatic availability avg backup badfile basicfile before begin beginning benchmark between bfile bfile_base big bigfile bin binary_double binary_float binlog bit_and bit_count bit_length bit_or bit_xor bitmap blob_base block blocksize body both bound bucket buffer_cache buffer_pool build bulk by byte byteordermark bytes cache caching call calling cancel capacity cascade cascaded case cast catalog category ceil ceiling chain change changed char_base char_length character_length characters characterset charindex charset charsetform charsetid check checksum checksum_agg child choose chr chunk class cleanup clear client clob clob_base clone close cluster_id cluster_probability cluster_set clustering coalesce coercibility col collate collation collect colu colum column column_value columns columns_updated comment commit compact compatibility compiled complete composite_limit compound compress compute concat concat_ws concurrent confirm conn connec connect connect_by_iscycle connect_by_isleaf connect_by_root connect_time connection consider consistent constant constraint constraints constructor container content contents context contributors controlfile conv convert convert_tz corr corr_k corr_s corresponding corruption cos cost count count_big counted covar_pop covar_samp cpu_per_call cpu_per_session crc32 create creation critical cross cube cume_dist curdate current current_date current_time current_timestamp current_user cursor curtime customdatum cycle data database databases datafile datafiles datalength date_add date_cache date_format date_sub dateadd datediff datefromparts datename datepart datetime2fromparts day day_to_second dayname dayofmonth dayofweek dayofyear days db_role_change dbtimezone ddl deallocate declare decode decompose decrement decrypt deduplicate def defa defau defaul default defaults deferred defi defin define degrees delayed delegate delete delete_all delimited demand dense_rank depth dequeue des_decrypt des_encrypt des_key_file desc descr descri describ describe descriptor deterministic diagnostics difference dimension direct_load directory disable disable_all disallow disassociate discardfile disconnect diskgroup distinct distinctrow distribute distributed div do document domain dotnet double downgrade drop dumpfile duplicate duration each edition editionable editions element ellipsis else elsif elt empty enable enable_all enclosed encode encoding encrypt end end-exec endian enforced engine engines enqueue enterprise entityescaping eomonth error errors escaped evalname evaluate event eventdata events except exception exceptions exchange exclude excluding execu execut execute exempt exists exit exp expire explain explode export export_set extended extent external external_1 external_2 externally extract failed failed_login_attempts failover failure far fast feature_set feature_value fetch field fields file file_name_convert filesystem_like_logging final finish first first_value fixed flash_cache flashback floor flush following follows for forall force foreign form forma format found found_rows freelist freelists freepools fresh from from_base64 from_days ftp full function general generated get get_format get_lock getdate getutcdate global global_name globally go goto grant grants greatest group group_concat group_id grouping grouping_id groups gtid_subtract guarantee guard handler hash hashkeys having hea head headi headin heading heap help hex hierarchy high high_priority hosts hour hours http id ident_current ident_incr ident_seed identified identity idle_time if ifnull ignore iif ilike ilm immediate import in include including increment index indexes indexing indextype indicator indices inet6_aton inet6_ntoa inet_aton inet_ntoa infile initial initialized initially initrans inmemory inner innodb input insert install instance instantiable instr interface interleaved intersect into invalidate invisible is is_free_lock is_ipv4 is_ipv4_compat is_not is_not_null is_used_lock isdate isnull isolation iterate java join json json_exists keep keep_duplicates key keys kill language large last last_day last_insert_id last_value lateral lax lcase lead leading least leaves left len lenght length less level levels library like like2 like4 likec limit lines link list listagg little ln load load_file lob lobs local localtime localtimestamp locate locator lock locked log log10 log2 logfile logfiles logging logical logical_reads_per_call logoff logon logs long loop low low_priority lower lpad lrtrim ltrim main make_set makedate maketime managed management manual map mapping mask master master_pos_wait match matched materialized max maxextents maximize maxinstances maxlen maxlogfiles maxloghistory maxlogmembers maxsize maxtrans md5 measures median medium member memcompress memory merge microsecond mid migration min minextents minimum mining minus minute minutes minvalue missing mod mode model modification modify module monitoring month months mount move movement multiset mutex name name_const names nan national native natural nav nchar nclob nested never new newline next nextval no no_write_to_binlog noarchivelog noaudit nobadfile nocheck nocompress nocopy nocycle nodelay nodiscardfile noentityescaping noguarantee nokeep nologfile nomapping nomaxvalue nominimize nominvalue nomonitoring none noneditionable nonschema noorder nopr nopro noprom nopromp noprompt norely noresetlogs noreverse normal norowdependencies noschemacheck noswitch not nothing notice notnull notrim novalidate now nowait nth_value nullif nulls num numb numbe nvarchar nvarchar2 object ocicoll ocidate ocidatetime ociduration ociinterval ociloblocator ocinumber ociref ocirefcursor ocirowid ocistring ocitype oct octet_length of off offline offset oid oidindex old on online only opaque open operations operator optimal optimize option optionally or oracle oracle_date oradata ord ordaudio orddicom orddoc order ordimage ordinality ordvideo organization orlany orlvary out outer outfile outline output over overflow overriding package pad parallel parallel_enable parameters parent parse partial partition partitions pascal passing password password_grace_time password_lock_time password_reuse_max password_reuse_time password_verify_function patch path patindex pctincrease pctthreshold pctused pctversion percent percent_rank percentile_cont percentile_disc performance period period_add period_diff permanent physical pi pipe pipelined pivot pluggable plugin policy position post_transaction pow power pragma prebuilt precedes preceding precision prediction prediction_cost prediction_details prediction_probability prediction_set prepare present preserve prior priority private private_sga privileges procedural procedure procedure_analyze processlist profiles project prompt protection public publishingservername purge quarter query quick quiesce quota quotename radians raise rand range rank raw read reads readsize rebuild record records recover recovery recursive recycle redo reduced ref reference referenced references referencing refresh regexp_like register regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy reject rekey relational relative relaylog release release_lock relies_on relocate rely rem remainder rename repair repeat replace replicate replication required reset resetlogs resize resource respect restore restricted result result_cache resumable resume retention return returning returns reuse reverse revoke right rlike role roles rollback rolling rollup round row row_count rowdependencies rowid rownum rows rtrim rules safe salt sample save savepoint sb1 sb2 sb4 scan schema schemacheck scn scope scroll sdo_georaster sdo_topo_geometry search sec_to_time second seconds section securefile security seed segment select self semi sequence sequential serializable server servererror session session_user sessions_per_user set sets settings sha sha1 sha2 share shared shared_pool short show shrink shutdown si_averagecolor si_colorhistogram si_featurelist si_positionalcolor si_stillimage si_texture siblings sid sign sin size size_t sizes skip slave sleep smalldatetimefromparts smallfile snapshot some soname sort soundex source space sparse spfile split sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_small_result sql_variant_property sqlcode sqldata sqlerror sqlname sqlstate sqrt square standalone standby start starting startup statement static statistics stats_binomial_test stats_crosstab stats_ks_test stats_mode stats_mw_test stats_one_way_anova stats_t_test_ stats_t_test_indep stats_t_test_one stats_t_test_paired stats_wsr_test status std stddev stddev_pop stddev_samp stdev stop storage store stored str str_to_date straight_join strcmp strict string struct stuff style subdate subpartition subpartitions substitutable substr substring subtime subtring_index subtype success sum suspend switch switchoffset switchover sync synchronous synonym sys sys_xmlagg sysasm sysaux sysdate sysdatetimeoffset sysdba sysoper system system_user sysutcdatetime table tables tablespace tablesample tan tdo template temporary terminated tertiary_weights test than then thread through tier ties time time_format time_zone timediff timefromparts timeout timestamp timestampadd timestampdiff timezone_abbr timezone_minute timezone_region to to_base64 to_date to_days to_seconds todatetimeoffset trace tracking transaction transactional translate translation treat trigger trigger_nestlevel triggers trim truncate try_cast try_convert try_parse type ub1 ub2 ub4 ucase unarchived unbounded uncompress under undo unhex unicode uniform uninstall union unique unix_timestamp unknown unlimited unlock unnest unpivot unrecoverable unsafe unsigned until untrusted unusable unused update updated upgrade upped upper upsert url urowid usable usage use use_stored_outlines user user_data user_resources users using utc_date utc_timestamp uuid uuid_short validate validate_password_strength validation valist value values var var_samp varcharc vari varia variab variabl variable variables variance varp varraw varrawc varray verify version versions view virtual visible void wait wallet warning warnings week weekday weekofyear wellformed when whene whenev wheneve whenever where while whitespace window with within without work wrapped xdb xml xmlagg xmlattributes xmlcast xmlcolattval xmlelement xmlexists xmlforest xmlindex xmlnamespaces xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltype xor year year_to_month years yearweek",literal:"true false null unknown",built_in:"array bigint binary bit blob bool boolean char character date dec decimal float int int8 integer interval number numeric real record serial serial8 smallint text time timestamp tinyint varchar varchar2 varying void"},contains:[{className:"string",begin:"'",end:"'",contains:[{begin:"''"}]},{className:"string",begin:'"',end:'"',contains:[{begin:'""'}]},{className:"string",begin:"`",end:"`"},e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,t,e.HASH_COMMENT_MODE]},e.C_BLOCK_COMMENT_MODE,t,e.HASH_COMMENT_MODE]}}}());hljs.registerLanguage("diff",function(){"use strict";return function(e){return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,variants:[{begin:/^@@ +\-\d+,\d+ +\+\d+,\d+ +@@$/},{begin:/^\*\*\* +\d+,\d+ +\*\*\*\*$/},{begin:/^\-\-\- +\d+,\d+ +\-\-\-\-$/}]},{className:"comment",variants:[{begin:/Index: /,end:/$/},{begin:/={3,}/,end:/$/},{begin:/^\-{3}/,end:/$/},{begin:/^\*{3} /,end:/$/},{begin:/^\+{3}/,end:/$/},{begin:/^\*{15}$/}]},{className:"addition",begin:"^\\+",end:"$"},{className:"deletion",begin:"^\\-",end:"$"},{className:"addition",begin:"^\\!",end:"$"}]}}}());hljs.registerLanguage("javascript",function(){"use strict";const e=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],n=["true","false","null","undefined","NaN","Infinity"],a=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"]);function s(e){return r("(?=",e,")")}function r(...e){return e.map(e=>(function(e){return e?"string"==typeof e?e:e.source:null})(e)).join("")}return function(t){var i="[A-Za-z$_][0-9A-Za-z$_]*",c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/},o={$pattern:"[A-Za-z$_][0-9A-Za-z$_]*",keyword:e.join(" "),literal:n.join(" "),built_in:a.join(" ")},l={className:"number",variants:[{begin:"\\b(0[bB][01]+)n?"},{begin:"\\b(0[oO][0-7]+)n?"},{begin:t.C_NUMBER_RE+"n?"}],relevance:0},E={className:"subst",begin:"\\$\\{",end:"\\}",keywords:o,contains:[]},d={begin:"html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,E],subLanguage:"xml"}},g={begin:"css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,E],subLanguage:"css"}},u={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,E]};E.contains=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,d,g,u,l,t.REGEXP_MODE];var b=E.contains.concat([{begin:/\(/,end:/\)/,contains:["self"].concat(E.contains,[t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE])},t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]),_={className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,contains:b};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,contains:[t.SHEBANG({binary:"node",relevance:5}),{className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,d,g,u,t.C_LINE_COMMENT_MODE,t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+",contains:[{className:"type",begin:"\\{",end:"\\}",relevance:0},{className:"variable",begin:i+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,l,{begin:r(/[{,\n]\s*/,s(r(/(((\/\/.*$)|(\/\*(.|\n)*\*\/))\s*)*/,i+"\\s*:"))),relevance:0,contains:[{className:"attr",begin:i+s("\\s*:"),relevance:0}]},{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,t.REGEXP_MODE,{className:"function",begin:"(\\([^(]*(\\([^(]*(\\([^(]*\\))?\\))?\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:b}]}]},{begin:/,/,relevance:0},{className:"",begin:/\s/,end:/\s*/,skip:!0},{variants:[{begin:"<>",end:""},{begin:c.begin,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}],relevance:0},{className:"function",beginKeywords:"function",end:/\{/,excludeEnd:!0,contains:[t.inherit(t.TITLE_MODE,{begin:i}),_],illegal:/\[|%/},{begin:/\$[(.]/},t.METHOD_GUARD,{className:"class",beginKeywords:"class",end:/[{;=]/,excludeEnd:!0,illegal:/[:"\[\]]/,contains:[{beginKeywords:"extends"},t.UNDERSCORE_TITLE_MODE]},{beginKeywords:"constructor",end:/\{/,excludeEnd:!0},{begin:"(get|set)\\s+(?="+i+"\\()",end:/{/,keywords:"get set",contains:[t.inherit(t.TITLE_MODE,{begin:i}),{begin:/\(\)/},_]}],illegal:/#(?!!)/}}}());hljs.registerLanguage("http",function(){"use strict";return function(e){var n="HTTP/[0-9\\.]+";return{name:"HTTP",aliases:["https"],illegal:"\\S",contains:[{begin:"^"+n,end:"$",contains:[{className:"number",begin:"\\b\\d{3}\\b"}]},{begin:"^[A-Z]+ (.*?) "+n+"$",returnBegin:!0,end:"$",contains:[{className:"string",begin:" ",end:" ",excludeBegin:!0,excludeEnd:!0},{begin:n},{className:"keyword",begin:"[A-Z]+"}]},{className:"attribute",begin:"^\\w",end:": ",excludeEnd:!0,illegal:"\\n|\\s|=",starts:{end:"$",relevance:0}},{begin:"\\n\\n",starts:{subLanguage:[],endsWithParent:!0}}]}}}());hljs.registerLanguage("json",function(){"use strict";return function(n){var e={literal:"true false null"},i=[n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE],t=[n.QUOTE_STRING_MODE,n.C_NUMBER_MODE],a={end:",",endsWithParent:!0,excludeEnd:!0,contains:t,keywords:e},l={begin:"{",end:"}",contains:[{className:"attr",begin:/"/,end:/"/,contains:[n.BACKSLASH_ESCAPE],illegal:"\\n"},n.inherit(a,{begin:/:/})].concat(i),illegal:"\\S"},s={begin:"\\[",end:"\\]",contains:[n.inherit(a)],illegal:"\\S"};return t.push(l,s),i.forEach((function(n){t.push(n)})),{name:"JSON",contains:t,keywords:e,illegal:"\\S"}}}());hljs.registerLanguage("ini",function(){"use strict";function e(e){return e?"string"==typeof e?e:e.source:null}function n(...n){return n.map(n=>e(n)).join("")}return function(a){var s={className:"number",relevance:0,variants:[{begin:/([\+\-]+)?[\d]+_[\d_]+/},{begin:a.NUMBER_RE}]},i=a.COMMENT();i.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];var t={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)}/}]},r={className:"literal",begin:/\bon|off|true|false|yes|no\b/},l={className:"string",contains:[a.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[i,r,t,l,s,"self"],relevance:0},g="("+[/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/].map(n=>e(n)).join("|")+")";return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[i,{className:"section",begin:/\[+/,end:/\]+/},{begin:n(g,"(\\s*\\.\\s*",g,")*",n("(?=",/\s*=\s*[^#\s]/,")")),className:"attr",starts:{end:/$/,contains:[i,c,r,t,l,s]}}]}}}());hljs.registerLanguage("typescript",function(){"use strict";const e=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],n=["true","false","null","undefined","NaN","Infinity"],a=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"]);return function(r){var t={$pattern:"[A-Za-z$_][0-9A-Za-z$_]*",keyword:e.concat(["type","namespace","typedef","interface","public","private","protected","implements","declare","abstract","readonly"]).join(" "),literal:n.join(" "),built_in:a.concat(["any","void","number","boolean","string","object","never","enum"]).join(" ")},s={className:"meta",begin:"@[A-Za-z$_][0-9A-Za-z$_]*"},i={className:"number",variants:[{begin:"\\b(0[bB][01]+)n?"},{begin:"\\b(0[oO][0-7]+)n?"},{begin:r.C_NUMBER_RE+"n?"}],relevance:0},o={className:"subst",begin:"\\$\\{",end:"\\}",keywords:t,contains:[]},c={begin:"html`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,o],subLanguage:"xml"}},l={begin:"css`",end:"",starts:{end:"`",returnEnd:!1,contains:[r.BACKSLASH_ESCAPE,o],subLanguage:"css"}},E={className:"string",begin:"`",end:"`",contains:[r.BACKSLASH_ESCAPE,o]};o.contains=[r.APOS_STRING_MODE,r.QUOTE_STRING_MODE,c,l,E,i,r.REGEXP_MODE];var d={begin:"\\(",end:/\)/,keywords:t,contains:["self",r.QUOTE_STRING_MODE,r.APOS_STRING_MODE,r.NUMBER_MODE]},u={className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:t,contains:[r.C_LINE_COMMENT_MODE,r.C_BLOCK_COMMENT_MODE,s,d]};return{name:"TypeScript",aliases:["ts"],keywords:t,contains:[r.SHEBANG(),{className:"meta",begin:/^\s*['"]use strict['"]/},r.APOS_STRING_MODE,r.QUOTE_STRING_MODE,c,l,E,r.C_LINE_COMMENT_MODE,r.C_BLOCK_COMMENT_MODE,i,{begin:"("+r.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",contains:[r.C_LINE_COMMENT_MODE,r.C_BLOCK_COMMENT_MODE,r.REGEXP_MODE,{className:"function",begin:"(\\([^(]*(\\([^(]*(\\([^(]*\\))?\\))?\\)|"+r.UNDERSCORE_IDENT_RE+")\\s*=>",returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:r.UNDERSCORE_IDENT_RE},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:t,contains:d.contains}]}]}],relevance:0},{className:"function",beginKeywords:"function",end:/[\{;]/,excludeEnd:!0,keywords:t,contains:["self",r.inherit(r.TITLE_MODE,{begin:"[A-Za-z$_][0-9A-Za-z$_]*"}),u],illegal:/%/,relevance:0},{beginKeywords:"constructor",end:/[\{;]/,excludeEnd:!0,contains:["self",u]},{begin:/module\./,keywords:{built_in:"module"},relevance:0},{beginKeywords:"module",end:/\{/,excludeEnd:!0},{beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:"interface extends"},{begin:/\$[(.]/},{begin:"\\."+r.IDENT_RE,relevance:0},s,d]}}}());hljs.registerLanguage("css",function(){"use strict";return function(e){var n={begin:/(?:[A-Z\_\.\-]+|--[a-zA-Z0-9_-]+)\s*:/,returnBegin:!0,end:";",endsWithParent:!0,contains:[{className:"attribute",begin:/\S/,end:":",excludeEnd:!0,starts:{endsWithParent:!0,excludeEnd:!0,contains:[{begin:/[\w-]+\(/,returnBegin:!0,contains:[{className:"built_in",begin:/[\w-]+/},{begin:/\(/,end:/\)/,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,e.CSS_NUMBER_MODE]}]},e.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,e.C_BLOCK_COMMENT_MODE,{className:"number",begin:"#[0-9A-Fa-f]+"},{className:"meta",begin:"!important"}]}}]};return{name:"CSS",case_insensitive:!0,illegal:/[=\/|'\$]/,contains:[e.C_BLOCK_COMMENT_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/},{className:"selector-class",begin:/\.[A-Za-z0-9_-]+/},{className:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},{className:"selector-pseudo",begin:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{begin:"@(page|font-face)",lexemes:"@[a-z-]+",keywords:"@page @font-face"},{begin:"@",end:"[{;]",illegal:/:/,returnBegin:!0,contains:[{className:"keyword",begin:/@\-?\w[\w]*(\-\w+)*/},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:"and or not only",contains:[{begin:/[a-z-]+:/,className:"attribute"},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,e.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"[a-zA-Z-][a-zA-Z0-9_-]*",relevance:0},{begin:"{",end:"}",illegal:/\S/,contains:[e.C_BLOCK_COMMENT_MODE,n]}]}}}());hljs.registerLanguage("properties",function(){"use strict";return function(e){var n="[ \\t\\f]*",t="("+n+"[:=]"+n+"|[ \\t\\f]+)",a="([^\\\\:= \\t\\f\\n]|\\\\.)+",s={end:t,relevance:0,starts:{className:"string",end:/$/,relevance:0,contains:[{begin:"\\\\\\n"}]}};return{name:".properties",case_insensitive:!0,illegal:/\S/,contains:[e.COMMENT("^\\s*[!#]","$"),{begin:"([^\\\\\\W:= \\t\\f\\n]|\\\\.)+"+t,returnBegin:!0,contains:[{className:"attr",begin:"([^\\\\\\W:= \\t\\f\\n]|\\\\.)+",endsParent:!0,relevance:0}],starts:s},{begin:a+t,returnBegin:!0,relevance:0,contains:[{className:"meta",begin:a,endsParent:!0,relevance:0}],starts:s},{className:"attr",relevance:0,begin:a+n+"$"}]}}}());hljs.registerLanguage("less",function(){"use strict";return function(e){var n="([\\w-]+|@{[\\w-]+})",a=[],s=[],t=function(e){return{className:"string",begin:"~?"+e+".*?"+e}},r=function(e,n,a){return{className:e,begin:n,relevance:a}},i={begin:"\\(",end:"\\)",contains:s,relevance:0};s.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t("'"),t('"'),e.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},r("number","#[0-9A-Fa-f]+\\b"),i,r("variable","@@?[\\w-]+",10),r("variable","@{[\\w-]+}"),r("built_in","~?`[^`]*?`"),{className:"attribute",begin:"[\\w-]+\\s*:",end:":",returnBegin:!0,excludeEnd:!0},{className:"meta",begin:"!important"});var c=s.concat({begin:"{",end:"}",contains:a}),l={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(s)},o={begin:n+"\\s*:",returnBegin:!0,end:"[;}]",relevance:0,contains:[{className:"attribute",begin:n,end:":",excludeEnd:!0,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:s}}]},g={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",returnEnd:!0,contains:s,relevance:0}},d={className:"variable",variants:[{begin:"@[\\w-]+\\s*:",relevance:15},{begin:"@[\\w-]+"}],starts:{end:"[;}]",returnEnd:!0,contains:c}},b={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:n,end:"{"}],returnBegin:!0,returnEnd:!0,illegal:"[<='$\"]",relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,l,r("keyword","all\\b"),r("variable","@{[\\w-]+}"),r("selector-tag",n+"%?",0),r("selector-id","#"+n),r("selector-class","\\."+n,0),r("selector-tag","&",0),{className:"selector-attr",begin:"\\[",end:"\\]"},{className:"selector-pseudo",begin:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{begin:"\\(",end:"\\)",contains:c},{begin:"!important"}]};return a.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,g,d,o,b),{name:"Less",case_insensitive:!0,illegal:"[=>'/<($\"]",contains:a}}}());hljs.registerLanguage("markdown",function(){"use strict";return function(n){const e={begin:"<",end:">",subLanguage:"xml",relevance:0},a={begin:"\\[.+?\\][\\(\\[].*?[\\)\\]]",returnBegin:!0,contains:[{className:"string",begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0,relevance:0},{className:"link",begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}],relevance:10},i={className:"strong",contains:[],variants:[{begin:/_{2}/,end:/_{2}/},{begin:/\*{2}/,end:/\*{2}/}]},s={className:"emphasis",contains:[],variants:[{begin:/\*(?!\*)/,end:/\*/},{begin:/_(?!_)/,end:/_/,relevance:0}]};i.contains.push(s),s.contains.push(i);var c=[e,a];return i.contains=i.contains.concat(c),s.contains=s.contains.concat(c),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:c=c.concat(i,s)},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:c}]}]},e,{className:"bullet",begin:"^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},i,s,{className:"quote",begin:"^>\\s+",contains:c,end:"$"},{className:"code",variants:[{begin:"(`{3,})(.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})(.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{begin:"^[-\\*]{3,}",end:"$"},a,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]}]}}}());hljs.registerLanguage("swift",function(){"use strict";return function(e){var i={keyword:"#available #colorLiteral #column #else #elseif #endif #file #fileLiteral #function #if #imageLiteral #line #selector #sourceLocation _ __COLUMN__ __FILE__ __FUNCTION__ __LINE__ Any as as! as? associatedtype associativity break case catch class continue convenience default defer deinit didSet do dynamic dynamicType else enum extension fallthrough false fileprivate final for func get guard if import in indirect infix init inout internal is lazy left let mutating nil none nonmutating open operator optional override postfix precedence prefix private protocol Protocol public repeat required rethrows return right self Self set static struct subscript super switch throw throws true try try! try? Type typealias unowned var weak where while willSet",literal:"true false nil",built_in:"abs advance alignof alignofValue anyGenerator assert assertionFailure bridgeFromObjectiveC bridgeFromObjectiveCUnconditional bridgeToObjectiveC bridgeToObjectiveCUnconditional c compactMap contains count countElements countLeadingZeros debugPrint debugPrintln distance dropFirst dropLast dump encodeBitsAsWords enumerate equal fatalError filter find getBridgedObjectiveCType getVaList indices insertionSort isBridgedToObjectiveC isBridgedVerbatimToObjectiveC isUniquelyReferenced isUniquelyReferencedNonObjC join lazy lexicographicalCompare map max maxElement min minElement numericCast overlaps partition posix precondition preconditionFailure print println quickSort readLine reduce reflect reinterpretCast reverse roundUpToAlignment sizeof sizeofValue sort split startsWith stride strideof strideofValue swap toString transcode underestimateCount unsafeAddressOf unsafeBitCast unsafeDowncast unsafeUnwrap unsafeReflect withExtendedLifetime withObjectAtPlusZero withUnsafePointer withUnsafePointerToObject withUnsafeMutablePointer withUnsafeMutablePointers withUnsafePointer withUnsafePointers withVaList zip"},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),t={className:"subst",begin:/\\\(/,end:"\\)",keywords:i,contains:[]},a={className:"string",contains:[e.BACKSLASH_ESCAPE,t],variants:[{begin:/"""/,end:/"""/},{begin:/"/,end:/"/}]},r={className:"number",begin:"\\b([\\d_]+(\\.[\\deE_]+)?|0x[a-fA-F0-9_]+(\\.[a-fA-F0-9p_]+)?|0b[01_]+|0o[0-7_]+)\\b",relevance:0};return t.contains=[r],{name:"Swift",keywords:i,contains:[a,e.C_LINE_COMMENT_MODE,n,{className:"type",begin:"\\b[A-Z][\\wÀ-ʸ']*[!?]"},{className:"type",begin:"\\b[A-Z][\\wÀ-ʸ']*",relevance:0},r,{className:"function",beginKeywords:"func",end:"{",excludeEnd:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/[A-Za-z$_][0-9A-Za-z$_]*/}),{begin://},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:i,contains:["self",r,a,e.C_BLOCK_COMMENT_MODE,{begin:":"}],illegal:/["']/}],illegal:/\[|%/},{className:"class",beginKeywords:"struct protocol class extension enum",keywords:i,end:"\\{",excludeEnd:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/[A-Za-z$_][\u00C0-\u02B80-9A-Za-z$_]*/})]},{className:"meta",begin:"(@discardableResult|@warn_unused_result|@exported|@lazy|@noescape|@NSCopying|@NSManaged|@objc|@objcMembers|@convention|@required|@noreturn|@IBAction|@IBDesignable|@IBInspectable|@IBOutlet|@infix|@prefix|@postfix|@autoclosure|@testable|@available|@nonobjc|@NSApplicationMain|@UIApplicationMain|@dynamicMemberLookup|@propertyWrapper)\\b"},{beginKeywords:"import",end:/$/,contains:[e.C_LINE_COMMENT_MODE,n]}]}}}());hljs.registerLanguage("yaml",function(){"use strict";return function(e){var n="true false yes no null",a="[\\w#;/?:@&=+$,.~*\\'()[\\]]+",s={className:"string",relevance:0,variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,{className:"template-variable",variants:[{begin:"{{",end:"}}"},{begin:"%{",end:"}"}]}]},i=e.inherit(s,{variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),l={end:",",endsWithParent:!0,excludeEnd:!0,contains:[],keywords:n,relevance:0},t={begin:"{",end:"}",contains:[l],illegal:"\\n",relevance:0},g={begin:"\\[",end:"\\]",contains:[l],illegal:"\\n",relevance:0},b=[{className:"attr",variants:[{begin:"\\w[\\w :\\/.-]*:(?=[ \t]|$)"},{begin:'"\\w[\\w :\\/.-]*":(?=[ \t]|$)'},{begin:"'\\w[\\w :\\/.-]*':(?=[ \t]|$)"}]},{className:"meta",begin:"^---s*$",relevance:10},{className:"string",begin:"[\\|>]([0-9]?[+-])?[ ]*\\n( *)[\\S ]+\\n(\\2[\\S ]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+a},{className:"type",begin:"!<"+a+">"},{className:"type",begin:"!"+a},{className:"type",begin:"!!"+a},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"\\-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:n,keywords:{literal:n}},{className:"number",begin:"\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b"},{className:"number",begin:e.C_NUMBER_RE+"\\b"},t,g,s],c=[...b];return c.pop(),c.push(i),l.contains=c,{name:"YAML",case_insensitive:!0,aliases:["yml","YAML"],contains:b}}}());hljs.registerLanguage("coffeescript",function(){"use strict";const e=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],n=["true","false","null","undefined","NaN","Infinity"],a=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"]);return function(r){var t={keyword:e.concat(["then","unless","until","loop","by","when","and","or","is","isnt","not"]).filter((e=>n=>!e.includes(n))(["var","const","let","function","static"])).join(" "),literal:n.concat(["yes","no","on","off"]).join(" "),built_in:a.concat(["npm","print"]).join(" ")},i="[A-Za-z$_][0-9A-Za-z$_]*",s={className:"subst",begin:/#\{/,end:/}/,keywords:t},o=[r.BINARY_NUMBER_MODE,r.inherit(r.C_NUMBER_MODE,{starts:{end:"(\\s*/)?",relevance:0}}),{className:"string",variants:[{begin:/'''/,end:/'''/,contains:[r.BACKSLASH_ESCAPE]},{begin:/'/,end:/'/,contains:[r.BACKSLASH_ESCAPE]},{begin:/"""/,end:/"""/,contains:[r.BACKSLASH_ESCAPE,s]},{begin:/"/,end:/"/,contains:[r.BACKSLASH_ESCAPE,s]}]},{className:"regexp",variants:[{begin:"///",end:"///",contains:[s,r.HASH_COMMENT_MODE]},{begin:"//[gim]{0,3}(?=\\W)",relevance:0},{begin:/\/(?![ *]).*?(?![\\]).\/[gim]{0,3}(?=\W)/}]},{begin:"@"+i},{subLanguage:"javascript",excludeBegin:!0,excludeEnd:!0,variants:[{begin:"```",end:"```"},{begin:"`",end:"`"}]}];s.contains=o;var c=r.inherit(r.TITLE_MODE,{begin:i}),l={className:"params",begin:"\\([^\\(]",returnBegin:!0,contains:[{begin:/\(/,end:/\)/,keywords:t,contains:["self"].concat(o)}]};return{name:"CoffeeScript",aliases:["coffee","cson","iced"],keywords:t,illegal:/\/\*/,contains:o.concat([r.COMMENT("###","###"),r.HASH_COMMENT_MODE,{className:"function",begin:"^\\s*"+i+"\\s*=\\s*(\\(.*\\))?\\s*\\B[-=]>",end:"[-=]>",returnBegin:!0,contains:[c,l]},{begin:/[:\(,=]\s*/,relevance:0,contains:[{className:"function",begin:"(\\(.*\\))?\\s*\\B[-=]>",end:"[-=]>",returnBegin:!0,contains:[l]}]},{className:"class",beginKeywords:"class",end:"$",illegal:/[:="\[\]]/,contains:[{beginKeywords:"extends",endsWithParent:!0,illegal:/[:="\[\]]/,contains:[c]},c]},{begin:i+":",end:":",returnBegin:!0,returnEnd:!0,relevance:0}])}}}()); --------------------------------------------------------------------------------