How to use the ansi_up.ansi_to_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 taskcluster / taskcluster-tools / src / lib / ui / terminalview.jsx View on Github external
{frame.map(line => {
            // Check if there are any ansi colors/styles
            const doubleSpace = line.match(/ {2}/g);

            if (ansiRegex().test(line)) {
              const newLine = ansiUp.ansi_to_html(line);

              return doubleSpace && doubleSpace.length ? (
                  <div>
                ) :
                <div>;
            } else if (doubleSpace &amp;&amp; doubleSpace.length) {
              return <div>{line}</div>;
            }

            return <div>{line}</div>;
          })}
        </div></div>
github remixz / run-js / lib / generate-bundle.js View on Github external
function generateErrorScript (err) {
  let errorBox = errorTemplate({
    name: err.name,
    message: ansiUp.ansi_to_html(escapeHtml(err.message))
  })

  // if it's not a string, and just included as a function that's interpolated by the returned string
  // it'll get mucked up during coverage testing
  let bundleJs = `function bundleError () {
    var template = ${JSON.stringify(errorBox)}
    if (typeof document === 'undefined') return
    document.addEventListener('DOMContentLoaded', function print () {
      var container = document.createElement('div')
      container.innerHTML = template
      document.body.appendChild(container)
    })
  }`

  return `;(${bundleJs})()\n`
}
github vmware / admiral / ui / app / src / js / components / containers / ContainerDetails.js View on Github external
Vue.nextTick(() => {
            this.updatePending = false;

            // set the text content, regardless of the format. if the format is ansi,
            // we want to use this method to escape html tags
            this.$el.textContent = this.logs;
            if (this.format === constants.CONTAINERS.LOGS.FORMAT.ANSI) {
              var logsEscaped = this.$el.innerHTML;
              if (logsEscaped) {
                this.$el.innerHTML = ansi.ansi_to_html(logsEscaped);
              }
            }
            if (scrolledToBottom) {
              this.$el.scrollTop = this.$el.scrollHeight;
            }
          });
        }
github node-ci / nci-ansible-ui / app / components / terminal / index.js View on Github external
prepareRow: function(row) {
		return ansiUp.ansi_to_html(utils.escapeHtml(row.replace('\r', '')));
	},
	prepareOutput: function(output) {
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 mantoni / consolify / lib / browser.js View on Github external
} 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 1 year ago

Package Health Score

57 / 100
Full package analysis