String Interpolation Highlighting #87
Replies: 3 comments 3 replies
-
Thanks for reaching out and for the comment about the docs, I tried making them less tedious than usual documentation. I agree, |
Beta Was this translation helpful? Give feedback.
-
An update, I've improved txt = """
These are numbers: 12311, 2 122.2321 121e-4 1.5e10
These are strings: "aaa" and
'dsda33d'
These are operators: + - * % ^ /
These are operators: [green]+[/green] - * % ^ /
This is code: `print(x)` and
```
do α
do β
```
This is an expression: :(x + y)
"""
print("\n\n")
tprint(txt) This is not bad, but the problem is that user provided markup style is ignored at beast or broken in the worst case. For this reason it might be best to not have Note: user's markup information will work fine for portions of text that don't get highlighted, it will only be lost for highlighted stuff. |
Beta Was this translation helpful? Give feedback.
-
Regarding your original question:
results in If you want strings/symbols to work correctly you'll need to add x, y = :z, "test"
tprint("These are the results: x = :$x, y = '$y'") Or you can do: tprint("These are the results: x = $(highlight(x)), y = $(highlight(y))") which would work in most cases except for |
Beta Was this translation helpful? Give feedback.
-
My typical usage of
println
would look something like:println("These are the results: x = $x, y = $y")
.I wonder if
tprintln
could automatically color interpolated values? I know I can writetprintln("These are the results: x =", x, "\b, y =", y)
instead, but I find the former code easier to read.I did see the portion of the documentation that would presumably cover this use case.
However, I would rather see
highlight
as a keyword option fortprint
that defaults totrue
than its own function. This default highlighting would be lowest priority and overwritten by any other formatting called for insidetprint
. That way if you don't want the element highlighting, you could just color it some other way (or take thet
offtprint
).Finally, I would just like to commend the authors for writing some of the best documentation I have seen. Very enjoyable to read!
Beta Was this translation helpful? Give feedback.
All reactions