mirror of
https://github.com/openai/codex.git
synced 2026-11-01 19:33:35 +00:00
@@ -6,6 +6,11 @@ import React from "react";
|
||||
import { describe, afterEach, beforeEach, it, expect, vi } from "vitest";
|
||||
import chalk from "chalk";
|
||||
|
||||
const BOLD = "\x1B[1m";
|
||||
const BOLD_OFF = "\x1B[22m";
|
||||
const ITALIC = "\x1B[3m";
|
||||
const ITALIC_OFF = "\x1B[23m";
|
||||
|
||||
/** Simple sanity check that the Markdown component renders bold/italic text.
|
||||
* We strip ANSI codes, so the output should contain the raw words. */
|
||||
it("renders basic markdown", () => {
|
||||
@@ -44,13 +49,20 @@ describe("ensure <Markdown> produces content with correct ANSI escape codes", ()
|
||||
);
|
||||
|
||||
const frame = lastFrame();
|
||||
const BOLD = "\x1B[1m";
|
||||
const BOLD_OFF = "\x1B[22m";
|
||||
const ITALIC = "\x1B[3m";
|
||||
const ITALIC_OFF = "\x1B[23m";
|
||||
expect(frame).toBe(`${BOLD}bold${BOLD_OFF} ${ITALIC}italic${ITALIC_OFF}`);
|
||||
});
|
||||
|
||||
// We had to patch in https://github.com/mikaelbr/marked-terminal/pull/366 to
|
||||
// make this work.
|
||||
it("bold test in a bullet should be rendered correctly", () => {
|
||||
const { lastFrame } = renderTui(
|
||||
<Markdown fileOpener={undefined}>* **bold** text</Markdown>,
|
||||
);
|
||||
|
||||
const outputWithAnsi = lastFrame();
|
||||
expect(outputWithAnsi).toBe(`* ${BOLD}bold${BOLD_OFF} text`);
|
||||
});
|
||||
|
||||
it("citations should get converted to hyperlinks when stdout supports them", () => {
|
||||
const { lastFrame } = renderTui(
|
||||
<Markdown fileOpener={"vscode"} cwd="/foo/bar">
|
||||
|
||||
@@ -29,6 +29,15 @@
|
||||
"overrides": {
|
||||
"punycode": "^2.3.1"
|
||||
},
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"marked-terminal@7.3.0": "patches/marked-terminal@7.3.0.patch"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=22",
|
||||
"pnpm": ">=9.0.0"
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
diff --git a/index.js b/index.js
|
||||
index 5e2d4b4f212a7c614ebcd5cba8c4928fa3e0d2d0..24dba3560bee4f88dac9106911ef204f37babebe 100644
|
||||
--- a/index.js
|
||||
+++ b/index.js
|
||||
@@ -83,7 +83,7 @@ Renderer.prototype.space = function () {
|
||||
|
||||
Renderer.prototype.text = function (text) {
|
||||
if (typeof text === 'object') {
|
||||
- text = text.text;
|
||||
+ text = text.tokens ? this.parser.parseInline(text.tokens) : text.text;
|
||||
}
|
||||
return this.o.text(text);
|
||||
};
|
||||
@@ -185,10 +185,10 @@ Renderer.prototype.listitem = function (text) {
|
||||
}
|
||||
var transform = compose(this.o.listitem, this.transform);
|
||||
var isNested = text.indexOf('\n') !== -1;
|
||||
- if (isNested) text = text.trim();
|
||||
+ if (!isNested) text = transform(text);
|
||||
|
||||
// Use BULLET_POINT as a marker for ordered or unordered list item
|
||||
- return '\n' + BULLET_POINT + transform(text);
|
||||
+ return '\n' + BULLET_POINT + text;
|
||||
};
|
||||
|
||||
Renderer.prototype.checkbox = function (checked) {
|
||||
Generated
+7
-2
@@ -9,6 +9,11 @@ overrides:
|
||||
micromatch: ^4.0.8
|
||||
semver: ^7.7.1
|
||||
|
||||
patchedDependencies:
|
||||
marked-terminal@7.3.0:
|
||||
hash: 536fe9685e91d559cf29a033191aa39da45729949e9d1c69989255091c8618fb
|
||||
path: patches/marked-terminal@7.3.0.patch
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
@@ -66,7 +71,7 @@ importers:
|
||||
version: 15.0.8
|
||||
marked-terminal:
|
||||
specifier: ^7.3.0
|
||||
version: 7.3.0(marked@15.0.8)
|
||||
version: 7.3.0(patch_hash=536fe9685e91d559cf29a033191aa39da45729949e9d1c69989255091c8618fb)(marked@15.0.8)
|
||||
meow:
|
||||
specifier: ^13.2.0
|
||||
version: 13.2.0
|
||||
@@ -4105,7 +4110,7 @@ snapshots:
|
||||
|
||||
make-error@1.3.6: {}
|
||||
|
||||
marked-terminal@7.3.0(marked@15.0.8):
|
||||
marked-terminal@7.3.0(patch_hash=536fe9685e91d559cf29a033191aa39da45729949e9d1c69989255091c8618fb)(marked@15.0.8):
|
||||
dependencies:
|
||||
ansi-escapes: 7.0.0
|
||||
ansi-regex: 6.1.0
|
||||
|
||||
@@ -5,3 +5,6 @@ packages:
|
||||
|
||||
ignoredBuiltDependencies:
|
||||
- esbuild
|
||||
|
||||
patchedDependencies:
|
||||
marked-terminal@7.3.0: patches/marked-terminal@7.3.0.patch
|
||||
|
||||
Reference in New Issue
Block a user