本文整理汇总了TypeScript中ansi_up.ansi_to_html函数的典型用法代码示例。如果您正苦于以下问题:TypeScript ansi_to_html函数的具体用法?TypeScript ansi_to_html怎么用?TypeScript ansi_to_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ansi_to_html函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: renderText
function renderText(options: renderText.IRenderOptions): Promise<void> {
// 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);
}
示例2: escapeTerminalOutput
// prepare raw data for passing to jQuery.terminal's .echo method
function escapeTerminalOutput(text) {
// term.echo will always append newline (which, by the way, really
// messes up commands that write lines to stdout in multiple chunks,
// see https://github.com/hraban/lush/issues/67) so strip one off
// the end of the output if there already is one.
if (U.hassuffix(text, '\r\n')) {
text = text.slice(0, -2);
} else if (U.hassuffix(text, '\n')) {
text = text.slice(0, -1);
}
text = U.escapeHTML(text);
text = ansi_up.ansi_to_html(text);
// jquery.terminal interprets square brackets in a weird way
text = text.replace(/\[/g, '[');
return text;
}
示例3: renderText
export function renderText(options: renderText.IRenderOptions): Promise<void> {
// 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);
}
示例4: appendToBuildLog
function appendToBuildLog(build, text) {
return {
type: APPEND_TO_BUILD_LOG,
payload: { buildId: build.id, text: ansiToHtml(text) }
};
}
示例5: populateBuildLog
export function populateBuildLog(id, data) {
return {
type: POPULATE_BUILD_LOG,
payload: { id, data: data ? ansiToHtml(data) : undefined },
};
}