File tree 1 file changed +20
-1
lines changed
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,26 @@ def get_tldr_page(self, command: str) -> str:
121
121
if command .startswith ("-" ):
122
122
return "Invalid command: Command can't start with a dash (-)."
123
123
124
- return self ._run_subprocess (["tldr" , "-r" , command ], "No TLDR page found." )
124
+ output = self ._run_subprocess (["tldr" , "-r" , command ], "No TLDR page found." )
125
+ # Process output: escape leading dashes and inline code
126
+ lines = output .splitlines ()
127
+ formatted_lines : list [str ] = []
128
+ for i , raw in enumerate (lines ):
129
+ # remove blank between dash and backtick
130
+ if (
131
+ not raw .strip ()
132
+ and i > 0
133
+ and i < len (lines ) - 1
134
+ and lines [i - 1 ].startswith ("-" )
135
+ and lines [i + 1 ].startswith ("`" )
136
+ ):
137
+ continue
138
+ line = raw
139
+ # escape leading dash
140
+ if line .startswith ("-" ):
141
+ line = "\\ " + line
142
+ formatted_lines .append (line )
143
+ return "\n " .join (formatted_lines )
125
144
126
145
def get_tldrs (self ) -> list [str ]:
127
146
"""
You can’t perform that action at this time.
0 commit comments