-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
feat: stylize text inside backticks when appearing in example description #254
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kyluca, thanks for looking into this. It looks like this seems to reset the styling after the back ticks (it resets from being green). Would we be able to reapply the styles after this? 🤔
Ah of course, good catch 👍 |
@@ -414,6 +417,11 @@ def colors_of(key: str) -> Tuple[str, str, List[str]]: | |||
|
|||
|
|||
def output(page: str, plain: bool = False) -> None: | |||
def emphasise_example(x: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opted for a def
to avoid a lambda
exceeding the line length.
if '`' in line: | ||
elements = ['\n', ' ' * LEADING_SPACES_NUM] | ||
|
||
for item in EXAMPLE_SPLIT_REGEX.split(line): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Followed the pattern for example commands below, using regex to pull out the substrings using backticks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me, but I'll leave this for someone with more Python knowledge to merge. 👍🏻
I noted the builds are failing due to an unrelated error, so have put up a separate PR to fix them first: #256 |
Closes #253
Hoping I've understood the brief correctly :)
This change will check for the presence of backticks (`) and replace them with the ANSI escape characters for italics (and a matching reset to close the pairs).
This appears to match the desired output from the Rust CLI from the issue.
Example output: