Repository navigation
Description
Description
Hi team, hope you're doing well! This is a small follow up to #2938. @andretorresdg's fix in #2945 keeps a lone * as literal text really nicely, but the inline parser still treats a pair of spaced * or ** on the same line as emphasis, so plain math or expressions in agent replies lose their asterisks and get styled.
For context, parseInline in src/components/ui/markdown/Markdown.tsx is what turns each line of a settled reply into bold, italic, code and link spans for the terminal. In the harness invoke chat, every finished assistant message goes through it via <Markdown content={item.text}> (screen.tsx#L443).
The bold branch (lines 26 to 33) and the italic branch (lines 44 to 51) open on any * / ** and close on the next one, without looking at what sits on either side.

parseInline and its callers, Functions view in Architect
Steps to Reproduce
- Run
agentcore harness invoke --id <harness-id>and chat with an agent. - Have the agent reply with a line like
2 * 3 * 4 = 24ora ** b ** c. - Once the reply settles,
Markdownpasses the line toparseInline, the first*opens an italic span (or**a bold span) and the next one closes it.
I didn't go through a live harness chat for this. I rendered <Markdown> directly with ink-testing-library on v1.x (71bc760), the same way Markdown.test.tsx from #2945 does:
for (const s of [
"2 * 3 * 4 = 24",
"a ** b ** c",
"x * y",
"*em*",
"**strong**",
])
console.log(
JSON.stringify(s),
"=>",
JSON.stringify(render(<Markdown content={s} />).lastFrame()),
);Expected Behavior
Following the CommonMark flanking rule, a * followed by whitespace can't open emphasis, and a * preceded by whitespace can't close it. So both lines should render as typed, with the asterisks kept. *em* and **strong** would keep working as they do today.
Actual Behavior
"2 * 3 * 4 = 24" => "2 3 4 = 24"
"a ** b ** c" => "a b c"
"x * y" => "x * y"
"*em*" => "em"
"**strong**" => "strong"
The asterisks are gone, with 3 styled italic and b styled bold. The lone x * y case stays literal thanks to #2945, so this only shows up once there's a second spaced asterisk on the same line.
CLI Version
1.6.0 (v1.x at 71bc760)
Operating System
macOS
Additional Context
Happy to put up a PR if it helps. Which direction would you prefer? A small flanking check in parseInline (skip an opener followed by whitespace, skip a closer preceded by whitespace) keeps it dependency free, or pulling in a markdown lexer would cover the rest of the CommonMark edge cases in one go. Would love your thoughts, and any tips on how you'd like it tested. Thanks so much!
Activity