A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
/* Copyright 2026 Marimo. All rights reserved. */
import { AnsiUp } from "ansi_up";
import { describe, expect, test } from "vitest";
const ansiUp = new AnsiUp();
describe("ansi", () => {
test("basic", () => {
const text = "string";
const value = ansiUp.ansi_to_html(text);
expect(value).toMatchInlineSnapshot(`"string"`);
});
test("with ansi", () => {
const text = "'\u001B[30mblack\u001B[37mwhite'";
const value = ansiUp.ansi_to_html(text);
expect(value).toMatchInlineSnapshot(
`"'<span style="color:rgb(0,0,0)">black</span><span style="color:rgb(255,255,255)">white'</span>"`,
);
});
test("with html", () => {
// HTML gets escaped
const text = "<b>string</b>";
const value = ansiUp.ansi_to_html(text);
expect(value).toMatchInlineSnapshot(
`"<span style="color:rgb(255,255,255)"><b>string</b></span>"`,
);
});
test("with ansi and html", () => {
// HTML gets escaped
const text = "'\u001B[1m<b>string\u001B[0m</b>'";
const value = ansiUp.ansi_to_html(text);
expect(value).toMatchInlineSnapshot(
`"<span style="color:rgb(255,255,255)">'</span><span style="font-weight:bold;color:rgb(255,255,255)"><b>string</span></b>'"`,
);
});
});