mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 08:14:59 +00:00
aider: Added MarkdownLexer to highlight user input with markdown syntax.
# Context: USER: have `prompt_toolkit` highlight the user input with a markdown lexer ASSISTANT: To highlight the user input with a markdown lexer, we need to modify the `aider/io.py` file. We will import the `MarkdownLexer` from `pygments.lexers.markup` and use it as the lexer for the `PromptSession`. Here's the change you need to make: ```python aider/io.py <<<<<<< ORIGINAL from pygments.lexers import guess_lexer_for_filename ======= from pygments.lexers import guess_lexer_for_filename, MarkdownLexer >>>>>>> UPDATED ``` And update the `PromptSession` instantiation in the `get_input` method: ```python aider/io.py <<<<<<< ORIGINAL session_kwargs = { "message": show, "completer": completer_instance, "reserve_space_for_menu": 4, "complete_style": CompleteStyle.MULTI_COLUMN, "input": self.input, "output": self.output, } ======= session_kwargs = { "message": show, "completer": completer_instance, "reserve_space_for_menu": 4, "complete_style": CompleteStyle.MULTI_COLUMN, "input": self.input, "output": self.output, "lexer": MarkdownLexer(), } >>>>>>> UPDATED ``` These changes will import the `MarkdownLexer` and use it for the `PromptSession`, which will highlight the user input with markdown syntax.
This commit is contained in:
parent
e4805490f5
commit
2a0761b0ce
1 changed files with 2 additions and 1 deletions
|
@ -8,7 +8,7 @@ from prompt_toolkit.completion import Completer, Completion
|
|||
from prompt_toolkit.history import FileHistory
|
||||
from prompt_toolkit.shortcuts import CompleteStyle, PromptSession, prompt
|
||||
from prompt_toolkit.styles import Style
|
||||
from pygments.lexers import guess_lexer_for_filename
|
||||
from pygments.lexers import guess_lexer_for_filename, MarkdownLexer
|
||||
from pygments.token import Token
|
||||
from pygments.util import ClassNotFound
|
||||
from rich.console import Console
|
||||
|
@ -148,6 +148,7 @@ class InputOutput:
|
|||
"complete_style": CompleteStyle.MULTI_COLUMN,
|
||||
"input": self.input,
|
||||
"output": self.output,
|
||||
"lexer": MarkdownLexer(),
|
||||
}
|
||||
if style:
|
||||
session_kwargs["style"] = style
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue