How to use the ansi_up 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 JunoLab / atom-ink / lib / util / ansitohtml.js View on Github external
'use babel'

import AnsiUp from 'ansi_up'
let converter = new AnsiUp()
converter.escape_for_html = false

// this wraps all plain text nodes in a span, which makes sure they can be picked
// up by querySelectorAll later
function wrapTextNodes (view) {
  if (view.hasChildNodes()) {
    let nodes = view.childNodes
    for (let i = 0; i < nodes.length; i++) {
      let node = nodes[i]
      if (node.nodeType == 3) { // text nodes
        let span = document.createElement('span')
        span.innerText = node.textContent
        node.parentElement.insertBefore(span, node)
        node.parentElement.removeChild(node)
      } else if (node.nodeType == 1) { // normal HTML nodes
        wrapTextNodes(node)
github CleanstoneMC / Cleanstone / admin-ui-extension / src / console-endpoint.vue View on Github external
data: () => ({
      command: '',
      hasLoaded: false,
      logEntries: [],
      ansiUp: new AnsiUp(),
    }),
    methods: {
github vuejs / vue-cli / packages / @vue / cli-ui / src / util / ansi-colors.js View on Github external
import AU from 'ansi_up'

const ansiUp = new AU()
ansiUp.use_classes = true
ansiUp.escape_for_html = false

export default {
  install (Vue) {
    Vue.prototype.ansiColors = text => ansiUp.ansi_to_html(text)
  }
}
github wandb / client / wandb / board / ui / src / components / Log.js View on Github external
constructor(props) {
    super(props);
    this.ansi_up = new AU();
  }
  //TODO: this might go away
github hal-platform / hal / js / app / job / event-log-loader.js View on Github external
$context = $(``);

        $loading.remove();

    if (data === null) {
        $td.append('No data found');
    } else {
        for (let property in data) {
            let prop = data[property],
                $pre = $('<pre>'),
                $wrapper = $('<div class="pre-wrapper pre-ansi">');

            if (typeof prop !== 'string') {
                prop = JSON.stringify(prop, null, 4);
            } else {
                let ansi_up = new AU;

                prop = xssFilters.inHTMLData(prop);
                prop = ansi_up.ansi_to_html(prop);
            }

            $pre.appendTo($wrapper)
                .html(prop);

            $td.append(`<h4>${property}</h4>`)
                .append($wrapper)

        }
    }

    $context
        .append($td)</div></pre>
github drone / drone-ui / src / screens / repo / screens / build / logs / components / term.js View on Github external
import React, { Component } from "react";
import AnsiUp from "ansi_up";
import style from "./term.less";

let formatter = new AnsiUp();
formatter.use_classes = true;

class Term extends Component {
	render() {
		const { lines, exitcode } = this.props;
		return (
			<div>
				{lines.map(renderTermLine)}
				{exitcode !== undefined ? renderExitCode(exitcode) : undefined}
			</div>
		);
	}

	shouldComponentUpdate(nextProps, nextState) {
		return (
			this.props.lines !== nextProps.lines ||

ansi_up

Convert ansi sequences in strings to colorful HTML

MIT
Latest version published 11 months ago

Package Health Score

64 / 100
Full package analysis