How to use the ansi_up.escape_for_html 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 jupyterlab / jupyterlab / packages / rendermime / src / renderers.ts View on Github external
function renderText(options: renderText.IRenderOptions): Promise {
  // Unpack the options.
  let { host, source } = options;

  // Escape the terminal codes and HTML tags.
  let data = escape_for_html(source);

  // Create the HTML content.
  let content = ansi_to_html(data, { use_classes: true });

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

  // Return the rendered promise.
  return Promise.resolve(undefined);
}
github jjclark1982 / factorio-control-panel / lib / runCommand.js View on Github external
.pipe(es.through(function(text){
        var html = ansi_up.ansi_to_html(ansi_up.escape_for_html(''+text));
        this.emit('data', html);
    }, function(end){
        this.emit('data', module.exports.footer);
github jupyterlab / jupyterlab / packages / rendermime / src / widgets.ts View on Github external
constructor(options: RenderMime.IRenderOptions) {
    super();
    let source = Private.getSource(options);
    let data = escape_for_html(source);
    let pre = document.createElement('pre');
    pre.innerHTML = ansi_to_html(data, {use_classes: true});
    this.node.appendChild(pre);
    this.addClass(TEXT_CLASS);
    if (options.mimeType === 'application/vnd.jupyter.stderr') {
      this.addClass(ERROR_CLASS);
    }
  }
}
github drone / drone-ui / src / components / term_row.js View on Github external
render() {
    const {pos, out} = this.props.line;

    let html = ansi_up.escape_for_html(out || '');
    html = ansi_up.ansi_to_html(html, opts);
    html = ansi_up.linkify(html);

    return (
     <div></div>
    );
  }
}
github mantoni / consolify / lib / browser.js View on Github external
while (br.nextSibling) {
      node.removeChild(br.nextSibling);
    }
  } else {
    while (node.lastChild) {
      node.removeChild(node.lastChild);
    }
  }
  var p = msg.lastIndexOf('\u001b[2K');
  if (p !== -1) {
    line = '';
    msg = msg.substring(p + 4);
  }
  line += msg;
  msg = sm.line(consumer, line, offset);
  msg = ansi.escape_for_html(msg);
  msg = msg.replace(/\u001b\[0G/g, '');
  msg = msg.replace(/ /g, '&nbsp;');
  div.innerHTML = ansi.ansi_to_html(msg, {
    use_classes : true
  });
  Array.prototype.slice.call(div.childNodes).forEach(node.appendChild, node);
}

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