mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-30 01:41:43 +00:00
fix(gateway): fix underscore-stripping regex to preserve snake_case identifiers
The blanket _(.+?)_ and __(.+?)__ patterns incorrectly consumed snake_case identifiers like send_as_bot and user_id. Add lookbehind/lookahead boundaries so underscores adjacent to alphanumeric characters are not treated as markdown formatting. Same fix already applied and tested in the CLI renderer; this addresses the gateway/platforms/helpers.py copy. Supersedes #15076.
This commit is contained in:
parent
00c3d848d8
commit
4eab312c35
2 changed files with 62 additions and 2 deletions
|
|
@ -157,8 +157,8 @@ class TextBatchAggregator:
|
|||
# Pre-compiled regexes for performance
|
||||
_RE_BOLD = re.compile(r"\*\*(.+?)\*\*", re.DOTALL)
|
||||
_RE_ITALIC_STAR = re.compile(r"\*(.+?)\*", re.DOTALL)
|
||||
_RE_BOLD_UNDER = re.compile(r"__(.+?)__", re.DOTALL)
|
||||
_RE_ITALIC_UNDER = re.compile(r"_(.+?)_", re.DOTALL)
|
||||
_RE_BOLD_UNDER = re.compile(r"(?<![a-zA-Z0-9])__(?=[^_\s])(.+?)(?<=[^_])__(?![a-zA-Z0-9])", re.DOTALL)
|
||||
_RE_ITALIC_UNDER = re.compile(r"(?<![a-zA-Z0-9])_(?=[^_\s])(.+?)(?<=[^_])_(?![a-zA-Z0-9])", re.DOTALL)
|
||||
_RE_CODE_BLOCK = re.compile(r"```[a-zA-Z0-9_+-]*\n?")
|
||||
_RE_INLINE_CODE = re.compile(r"`(.+?)`")
|
||||
_RE_HEADING = re.compile(r"^#{1,6}\s+", re.MULTILINE)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue