Skip to content

Commit

Permalink
Add support for custom inline code lexer in markdown rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
ncoop57 committed Nov 19, 2024
1 parent c811d05 commit 66c6aaa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bash_buddy/core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from claudette import *
from fastcore.script import *
from functools import partial
from rich.console import Console
from rich.markdown import Markdown

import psutil,subprocess,sys
Expand Down Expand Up @@ -42,6 +43,7 @@
- Link to documentation with `man command_name` or `-h`/`--help`
</important>'''

print = Console().print
cli = Client(models[1])
bb = partial(cli, sp=sp)

Expand All @@ -56,6 +58,8 @@ def main(
n: int = 200, # Number of history lines
o: int = 70, # Number of output lines before piping to less
code_theme: str = 'monokai', # The code theme to use when rendering BashBuddy's responses
code_lexer: str = 'python', # The lexer to use for inline code markdown blocks

):
query = ' '.join(query)
ctxt = ""
Expand All @@ -71,4 +75,4 @@ def main(
if len(r.splitlines()) > o:
p = subprocess.Popen(['less'], stdin=subprocess.PIPE)
p.communicate(input=r.encode())
else: print(Markdown(r, code_theme=code_theme))
else: print(Markdown(r, code_theme=code_theme, inline_code_lexer=code_lexer, inline_code_theme=code_theme))

0 comments on commit 66c6aaa

Please sign in to comment.