Skip to content

Implement option length selection with options and environment variables #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Mar 25, 2025
Merged
Changes from 1 commit
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
Next Next commit
Initial work on option lenght selection
  • Loading branch information
Managor committed Dec 13, 2024
commit 6307f0173cbe26d33531783bd3913fdb7586dd26
7 changes: 6 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 @@ -477,6 +477,11 @@ def emphasise_example(x: str) -> str:
# Handle escaped placeholders first
line = line.replace(r'\{\{', '__ESCAPED_OPEN__')
line = line.replace(r'\}\}', '__ESCAPED_CLOSE__')
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):
Expand Down
Loading