Handle/document more attributes such as "dim"#1663
Conversation
No direct security issues found in this diff. |
06d5613 to
44cd193
Compare
mycli/clistyle.py
Outdated
| return token_type, style_dict[token_name] | ||
|
|
||
|
|
||
| def is_valid_pygments(name: str): |
There was a problem hiding this comment.
For both these new functions, shouldn't they have a return type of bool? Surprised mypy doesn't complain about this.
For the error case of both functions, would it make sense to just return false for any exception? Otherwise it's not returning anything in the case a different error occurs (unless you want to actually do something on different errors). And seems weird one is AssertionError and one is ValueError, unless they actually do return those different error types (but would be moot if you just return false regardless).
There was a problem hiding this comment.
Good catch on the return type! We don't have mypy settings as strict as requiring them.
Yes, those are the actual expected exceptions for the two different cases, and we want to throw if some other error happens.
Handle and document more attributes for the [colors] section of the ~/.myclirc configuration file. This is a bit tricky as we try to support both Pygments and prompt_toolkit attribute names, and there is some mismatch between them. Before adding any style item we check it in a "try" block to see if it is supported (for the software, not the terminal). This works fine, with the only downside being that we silently swallow some spelling errors, applying no style in that case. We cannot reasonably warn in all such cases, since there exist styles supported by one library and not the other. In the end, we gain the support of new attributes such as "dim" and "strike". Some, such as "hidden", may not be supported most terminals. Other attributes exist, such as "roman", but it isn't clear that they are supported anywhere, so they are not documented.
44cd193 to
ff6ae82
Compare
Description
Handle and document more attributes for the
[colors]section of the~/.myclircconfiguration file.This is a bit tricky as we try to support both Pygments and prompt_toolkit attribute names, and there is some mismatch between them.
Before adding any style item we check it in a
tryblock to see if it is supported (for the software, not the terminal). This works fine, with the only downside being that we silently swallow some spelling errors, applying no style in that case. We cannot reasonably warn in all such cases, since there exist styles supported by one library and not the other.In the end, we gain the support of new attributes such as
dimandstrike. Some, such ashidden, may not be supported most terminals.Other attributes exist, such as
roman, but it isn't clear that they are supported anywhere, so they are not documented.The attribute that is most likely to be useful is
dim. (I would like the border colors of tables to be dimmed).Checklist
changelog.mdfile.AUTHORSfile (or it's already there).