This PR uses [`pnpm patch`](https://www.petermekhaeil.com/til/pnpm-patch/) to pull in the following proposed fixes for `marked-terminal`: * https://github.com/mikaelbr/marked-terminal/pull/366 * https://github.com/mikaelbr/marked-terminal/pull/367 This adds a substantial test to `codex-cli/tests/markdown.test.tsx` to verify the new behavior. Note that one of the tests shows two citations being split across a line even though the rendered version would fit comfortably on one line. Changing this likely requires a subtle fix to `marked-terminal` to account for "rendered length" when determining line breaks.
27 lines
914 B
Diff
27 lines
914 B
Diff
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) {
|