Skip to content

Let 'rich' use code_theme as inline_code_theme - #4193

Merged
paul-gauthier merged 1 commit into
Aider-AI:mainfrom
tanavamsikrishna:main
Jun 8, 2025
Merged

Let 'rich' use code_theme as inline_code_theme#4193
paul-gauthier merged 1 commit into
Aider-AI:mainfrom
tanavamsikrishna:main

Conversation

@tanavamsikrishna

@tanavamsikrishna tanavamsikrishna commented Jun 8, 2025

Copy link
Copy Markdown
Contributor

Problem

The inline code snippets in the reply from AI models are formatted using some default theme. They are somewhat harder to read and are just ugly.
image

Solution

Let the inline_code_theme as used in the rich.markdown.Markdown's __init__ have effect.

But if a inline_code_lexer is not passed to rich.markdown.Markdown, inline_code_theme is not being used to style inline code, as evident in the __init__ of rich.markdown.MarkdownContext. But there's no reasonably easy way to determine the programming language of inline code snippets to be able to identify the lexer. This PR's solution is to utilize the lexer text as the value of the inline_code_lexer passed to Markdown. In this scenario "rich" uses code_theme as the fallback value for inline_code_theme

@paul-gauthier
paul-gauthier merged commit 8d48def into Aider-AI:main Jun 8, 2025
@paul-gauthier

Copy link
Copy Markdown
Collaborator

Thanks!

@iamFIREcracker

Copy link
Copy Markdown
Contributor

I was working on something similar: #4200

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.

3 participants