Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tldr.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def colors_of(key: str) -> Tuple[str, str, List[str]]:
return (color, on_color, attrs)


def output(page: str, plain: bool = False) -> None:
def output(page: str, plain: bool = False, longform: bool = True, shortform: bool = True) -> None:
def emphasise_example(x: str) -> str:
# Use ANSI escapes to enable italics at the start and disable at the end
# Also use the color yellow to differentiate from the default green
Expand Down Expand Up @@ -478,6 +478,13 @@ def emphasise_example(x: str) -> str:
line = line.replace(r'\{\{', '__ESCAPED_OPEN__')
line = line.replace(r'\}\}', '__ESCAPED_CLOSE__')

# Extract long or short options from placeholders
if not (shortform and longform):
if shortform:
line = re.sub(r'{{(-.)\|--[^|]+?}}', r'{{\1}}', line)
elif longform:
line = re.sub(r'{{-.\|(--[^|]+?)}}', r'{{\1}}', line)

elements = [' ' * 2 * LEADING_SPACES_NUM]
for item in COMMAND_SPLIT_REGEX.split(line):
item, replaced = PARAM_REGEX.subn(
Expand Down
Loading