Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
view-container / dist / vendor / postcss / terminal-highlight.js
Size: Mime:
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const tokenize_1 = __importDefault(require("./tokenize"));
const input_1 = __importDefault(require("./input"));
const HIGHLIGHT_THEME = {
    brackets: [36, 39],
    string: [31, 39],
    'at-word': [31, 39],
    comment: [90, 39],
    '{': [32, 39],
    '}': [32, 39],
    ':': [1, 22],
    ';': [1, 22],
    '(': [1, 22],
    ')': [1, 22],
};
function code(color) {
    return '\u001b[' + color + 'm';
}
function terminalHighlight(css) {
    const tokens = tokenize_1.default(new input_1.default(css), { ignoreErrors: true });
    const result = [];
    tokens.forEach(token => {
        const color = HIGHLIGHT_THEME[token[0]];
        if (color) {
            result.push(token[1]
                .split(/\r?\n/)
                .map(i => code(color[0]) + i + code(color[1]))
                .join('\n'));
        }
        else {
            result.push(token[1]);
        }
    });
    return result.join('');
}
exports.default = terminalHighlight;
//# sourceMappingURL=terminal-highlight.js.map