fix(base): strip markdown asterisks in pairs instead of removing all#28731
Open
LifeJiggy wants to merge 1 commit into
Open
fix(base): strip markdown asterisks in pairs instead of removing all#28731LifeJiggy wants to merge 1 commit into
LifeJiggy wants to merge 1 commit into
Conversation
prepare_tts_text used a character-class regex [*_#\[\]()] that stripped EVERY asterisk from text, breaking math expressions like '5 * 3 = 15' (rendered as '5 3 = 15') and any other literal asterisk usage. Fix: apply markdown-aware paired-asterisk regexes (***, **, *) before the character-class strip for remaining markdown characters, so that only formatting asterisks are removed while standalone ones survive. Fixes NousResearch#28010.
8c31632 to
384b215
Compare
Contributor
Author
|
@teknium1 PTAL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: fix(base): strip markdown asterisks in pairs instead of removing all
What does this PR do?
prepare_tts_text()in the base gateway adapter used a character-class regex[*_#[]()]that stripped **every** asterisk from text, breaking math expressions like5 * 3 = 15(rendered as5 3 = 15`), pointer notation, and any other literal asterisk usage.Fix: apply markdown-aware paired-asterisk regexes (
***,**,*) before the character-class strip for remaining markdown characters, so that only formatting asterisks are removed while standalone ones survive.Related Issue
Fixes #28010
Type of Change
Changes Made
gateway/platforms/base.py: Replacedre.sub(r'[*_#[]()]', '', text)with three paired-asterisk regexes followed by a reduced character class[_#\[\]()]that no longer includes*How to Test
5 * 3 = 15orfoo *bar* baz*preserved) while*italic*still correctly strips markersChecklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping