Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{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 && doubleSpace.length) {
return <div>{line}</div>;
}
return <div>{line}</div>;
})}
</div></div>
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`
}
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;
}
});
}
'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)
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))
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);
}
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
// 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;
}
/* @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 > 0 || job.error
);
if (!hasContent) {
return null;
}
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);
}