How to use the ansi_up.default function in ansi_up

To help you get started, we’ve selected a few ansi_up examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lambci / lambci / utils / log.js View on Github external
var async = require('neo-async')
var AWS = require('aws-sdk')
var AU = require('ansi_up')
var buildTemplate = require('../html/build.html.js')

// We buffer all logs in-memory, including cmd output
var LOG_BUFFER = []

var SVGS = {
  pending: fs.readFileSync(`${__dirname}/../html/pending.svg`, 'utf8'),
  passing: fs.readFileSync(`${__dirname}/../html/passing.svg`, 'utf8'),
  failing: fs.readFileSync(`${__dirname}/../html/failing.svg`, 'utf8'),
}

var s3 = new AWS.S3()
var ansiUp = new AU.default()

exports.logIfErr = function(err) {
  if (err) exports.error(err.stack || err)
}

// We rely on a singleton logger (for the buffer), so this is kinda hacky
// (ie, cannot execute concurrent invocations from the same process)
// We could return a new logger instance, but... meh.
// Lambda doesn't execute concurrently in the same process anyway.
exports.init = function() {
  LOG_BUFFER = []
  exports.info.apply(exports, arguments)
}

exports.info = function() {
  LOG_BUFFER.push(util.format.apply(util, arguments))
github yuvipanda / simplest-notebook / packages / rendermime / src / renderers.ts View on Github external
export function renderText(options: renderText.IRenderOptions): Promise {
  // Unpack the options.
  let { host, source } = options;

  const ansiUp = new AnsiUp();
  ansiUp.escape_for_html = true;
  ansiUp.use_classes = true;

  // Create the HTML content.
  let content = ansiUp.ansi_to_html(source);

  // Set the inner HTML for the host node.
  host.innerHTML = `<pre>${content}</pre>`;

  // Return the rendered promise.
  return Promise.resolve(undefined);
}
github apache / zeppelin / zeppelin-web / src / app / notebook / paragraph / result / result.controller.js View on Github external
import moment from 'moment';

import DatasetFactory from '../../../tabledata/datasetfactory';
import TableVisualization from '../../../visualization/builtins/visualization-table';
import BarchartVisualization from '../../../visualization/builtins/visualization-barchart';
import PiechartVisualization from '../../../visualization/builtins/visualization-piechart';
import AreachartVisualization from '../../../visualization/builtins/visualization-areachart';
import LinechartVisualization from '../../../visualization/builtins/visualization-linechart';
import ScatterchartVisualization from '../../../visualization/builtins/visualization-scatterchart';
import NetworkVisualization from '../../../visualization/builtins/visualization-d3network';
import {DefaultDisplayType, SpellResult} from '../../../spell';
import {ParagraphStatus} from '../paragraph.status';
import Result from './result';

const AnsiUp = require('ansi_up');
const AnsiUpConverter = new AnsiUp.default; // eslint-disable-line new-parens,new-cap
const TableGridFilterTemplate = require('../../../visualization/builtins/visualization-table-grid-filter.html');

angular.module('zeppelinWebApp').controller('ResultCtrl', ResultCtrl);

function ResultCtrl($scope, $rootScope, $route, $window, $routeParams, $location,
                    $timeout, $compile, $http, $q, $templateCache, $templateRequest, $sce, websocketMsgSrv,
                    baseUrlSrv, ngToast, saveAsService, noteVarShareService, heliumService,
                    uiGridConstants) {
  'ngInject';

  /**
   * Built-in visualizations
   */
  $scope.builtInTableDataVisualizationList = [
    {
      id: 'table',   // paragraph.config.graph.mode
github esrlabs / chipmunk / application / client.plugins.standalone / row.parser.ascii / src / parser.ts View on Github external
// tslint:disable:object-literal-sort-keys
import * as Toolkit from 'chipmunk.client.toolkit';
import { default as AnsiUp } from 'ansi_up';

const ansiup = new AnsiUp();
ansiup.escape_for_html = false;

const REGS = {
    COLORS: /\x1b\[[\d;]{1,}[mG]/,
    COLORS_GLOBAL: /\x1b\[[\d;]{1,}[mG]/g,
};

const ignoreList: { [key: string]: boolean } = {};

export class ASCIIColorsParser extends Toolkit.ARowCommonParser {

    public parse(str: string, themeTypeRef: Toolkit.EThemeType, row: Toolkit.IRowInfo): string {
        if (typeof row.sourceName === "string") {
            if (ignoreList[row.sourceName] === undefined) {
                ignoreList[row.sourceName] = row.sourceName.search(/\.dlt$/gi) !== -1;
            }
github suchipi / quinci / src / web-ui / components / JobRunOutput.js View on Github external
/* @flow */
const React = require("react");
const { TriangleRightIcon } = require("react-octicons");
const ansiUp = require("ansi_up").default;
const Job = require("../../job");
const Padding = require("./Padding");
const LabelWithIcon = require("./LabelWithIcon");

const ansiUpInstance = new ansiUp();

type Props = {
  job: Job,
  isSelected: boolean,
};

module.exports = class JobRunOutput extends React.Component {
  render() {
    const { job, isSelected } = this.props;

    const hasContent = Boolean(
      isSelected || job.runResult.output.trim().length &gt; 0 || job.error
    );
    if (!hasContent) {
      return null;
    }
github bleenco / abstruse / src / app / components / app-logs / app-logs.component.ts View on Github external
ngOnInit() {
    this.au = new AnsiUp.default();
    this.au.use_classes = true;
    this.fetch();

    this.socketService.outputEvents
      .pipe(
        filter(msg => !!msg.message && !!msg.type)
      )
      .subscribe(msg => {
        msg.created_at = new Date().getTime();
        msg.message = this.au.ansi_to_html(msg.message);

        if (this.show === 'all' || this.show === msg.type) {
          this.logs.unshift(msg);
        }
      });
github FredTingaud / quick-bench-front-end / src / BashOutput.js View on Github external
import React from 'react';
var AU = require('ansi_up');
var ansi_up = new AU.default();

class BashOutput extends React.Component {
    updateHTML(text) {
        return { __html: ansi_up.ansi_to_html(text.replace(/<br>/g, '\n')) };
    }

    render() {
        if (this.props.text) {
            return (
                <pre>                    <div>
                </div></pre>
            );
        } else {
            return (<div>);
        }</div>
github polonel / trudesk / src / socketserver.js View on Github external
socket.on('logs:fetch', function() {
            var path = require('path');
            var AnsiUp = require('ansi_up');
            var ansi_up = new AnsiUp.default;
            var fileTailer = require('file-tail');
            var fs = require('fs');
            var logFile = path.join(__dirname, '../logs/output.log');
            if (!fs.existsSync(logFile))
                utils.sendToSelf(socket, 'logs:data', 'Invalid Log File...');
            else {
                var ft = fileTailer.startTailing(logFile);
                ft.on('line', function(line) {
                    utils.sendToSelf(socket, 'logs:data', ansi_up.ansi_to_html(line));
                });
            }
        });
github polonel / trudesk / src / controllers / settings.js View on Github external
settingsController.logs = function(req, res) {
    if (!checkPerms(req, 'settings:logs')) return res.redirect('/settings');

    var content = initViewContant('logs', req);

    var fs = require('fs'),
        path = require('path'),
        AnsiUp = require('ansi_up'),
        ansiUp = new AnsiUp.default,
        file = path.join(__dirname, '../../logs/output.log');

    fs.readFile(file, 'utf-8', function(err, data) {
        if (err)  {
            content.data.logFileContent = err;
            return res.render('logs', content);
        }

        content.data.logFileContent = data.toString().trim();
        content.data.logFileContent = ansiUp.ansi_to_html(content.data.logFileContent);

        return res.render('logs', content);
    });
};

ansi_up

Convert ansi sequences in strings to colorful HTML

MIT
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis