mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
Detect prompt lines in code blocks
This commit is contained in:
@@ -34,6 +34,8 @@ Create an [Option] from a string. Syntax is:
|
||||
default: something
|
||||
Help text on multiple lines. Indented lines are preserved as indented blocks. Blank lines
|
||||
are preserved as blank lines. #placeholder_for_formatting# is replaced by the empty string.
|
||||
.. code:: blocks are handled specially. Lines in them starting with "$ " have the $ colored
|
||||
to indicate a prompt.
|
||||
|
||||
Available types are: string, str, list, int, float, count, bool-set, bool-reset, choices
|
||||
The default dest is the first --option-name which must be a long option. The destination is automatically CamelCased from snake_case.
|
||||
@@ -238,7 +240,13 @@ func prepare_help_text_for_display(raw string) string {
|
||||
in_code_block = false
|
||||
return handle_non_empty_line(i, line)
|
||||
}
|
||||
help.WriteString(line[4:])
|
||||
line = line[4:]
|
||||
is_prompt := strings.HasPrefix(line, "$ ")
|
||||
if is_prompt {
|
||||
help.WriteString(":yellow:`$ `")
|
||||
line = line[2:]
|
||||
}
|
||||
help.WriteString(line)
|
||||
help.WriteString("\n")
|
||||
return i
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user