cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              body {
    margin: 0;
    height: 100vh;
    --size: 1.5;
}
.emoji {
    width: calc(var(--size, 1) * 14px);
    /*height: calc(var(--size, 1) * 14px);*/
    background-size: cover;
    display: inline-block;
    color: transparent;
}
            
          
!
            
              // for browsers that don't support key property
keyboardeventKeyPolyfill.polyfill();

function escape_formatters(string) {
    return string.replace(/:/g, ':').replace(/\)/g, ')')
        .replace(/(foo|bar|baz)/g, function(word) {
            return word.replace(/./g, function(chr) {
                return '&#' + chr.charCodeAt(0) + ';';
            });
        });
}

var term = $('body').terminal(function(command) {
    this.echo('you typed ' + JSON.stringify(escape_formatters(command)));
}, {
    onInit: function() {
        this.echo('type :smiley: or :) to render emoji :smiley:')
            .echo('you need to wait a moment while we fetch emoji data')
            .echo('to see available emoji type :<CHAR> and press tab twice')
    },
    completion: function(string, callback) {
        if (string.match(/^:/)) {
            callback(names.map(function(name) {
                return ':' + name + ':';
            }));
        }
    }
});
var base = 'https://rawgit.com/iamcal/emoji-data/master/img-emojione-64/';
var names = [];
$.get('https://rawgit.com/iamcal/emoji-data/master/emoji.json').then(function(list) {
    var text = {};
    list.forEach(function(emoji) {
        if (emoji.text && !text[emoji.text]) {
            text[emoji.text] = emoji.short_name;
        }
        names.push(emoji.short_name);
    });
    
    // new API old one with function will still work but if you need to use replacement
    // that change length of the output text you need to use [regex, str]
    $.terminal.defaults.formatters.push([
        new RegExp(':(' + names.map((name) => $.terminal.escape_regex(name)).join('|') + '):', 'g'),
        '[[;;;emoji $1]⻇]'
    ]);
    Object.keys(text).forEach(function(name) {
        $.terminal.defaults.formatters.push([
            new RegExp($.terminal.escape_regex(name), 'g'),
            '[[;;;emoji ' + text[name] + ']⻇]'
        ]);
    });
    $.terminal.defaults.formatters.push([/(foo|bar|baz)/g, 'text_$1']);
    term.refresh();
});

github('jcubic/jquery.terminal')
            
          
!
999px
Loading ..................

Console