Skip to content

fix: avoid false italic conversion in Telegram reasoning#526

Open
cpfiffer wants to merge 1 commit intomainfrom
codex/pr-523-followup
Open

fix: avoid false italic conversion in Telegram reasoning#526
cpfiffer wants to merge 1 commit intomainfrom
codex/pr-523-followup

Conversation

@cpfiffer
Copy link
Contributor

@cpfiffer cpfiffer commented Mar 7, 2026

Summary

  • tighten Telegram reasoning markdown-to-HTML conversion for *italic* and **bold**
  • avoid converting math/operator asterisks like 2 * 3 * 4 or 2*3*4
  • add regression tests for spaced and compact math expressions

Why

PR #523 added markdown conversion for Telegram thinking blocks, but the broad italic regex also matched non-markdown uses of asterisks.

Testing

  • npm test -- src/core/display.test.ts
  • npm run test:run

@cpfiffer
Copy link
Contributor Author

cpfiffer commented Mar 7, 2026

Quick context on what happened:

What this PR changes:

  • Tightens the markdown-to-HTML emphasis regex in formatReasoningDisplay so it only converts likely markdown delimiters.
  • Avoids converting escaped/in-word/math uses of *.
  • Adds regression tests for both 2 * 3 * 4 and 2*3*4.

Validation:

  • npm test -- src/core/display.test.ts
  • npm run test:run

Both pass.

@cpfiffer
Copy link
Contributor Author

cpfiffer commented Mar 7, 2026

Leaving this as a follow-up note so we can decide intent later.

I think a sensible default is to treat *...* / **...** as formatting only when delimiters are clearly markdown (not in-word operators), and to apply that consistently across languages.

Right now the fix covers ASCII math cases (2 * 3 * 4, 2*3*4), but there may still be Unicode in-word edge cases due to ASCII-oriented boundaries.

When we revisit, I suggest we confirm intent and add two focused tests:

  • привет*мир* stays literal
  • привет *мир* formats мир as italic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant