tldr-pages / tlrc

A tldr client written in Rust
http://tldr.sh/tlrc/
MIT License
232 stars 9 forks source link

Feature request: add ability to highlight command name #63

Open MustCodeAl opened 4 months ago

MustCodeAl commented 4 months ago

add ability to highlight command name text differently from the style of the example

like this:

Screenshot 2024-02-26 at 7 53 37 PM

config option could look like this:

[style.command_name]
color = {rgb = [96, 174, 239]} # command name is blue
background = "default"
bold = true
underline = false
italic = false
dim = false
strikethrough = false
MustCodeAl commented 4 months ago

after experimenting all day i kinda figured it out, but my code is quite ugly and i couldnt fix the styling for the rest of example text highlighting

Screenshot 2024-02-27 at 3 37 54 AM

acuteenvy commented 4 months ago

This is more complicated than just splitting the string in half on first whitespace and highlighting the first part. There are pages like sha256sum, where the command is at the end instead:

- Calculate a SHA256 checksum from `stdin`:

`{{command}} | sha256sum`

That makes it harder, but not impossible. You can take the string to highlight from the title or from the filename. But there are still pages where you just can't reliably infer what the command is. Take a look at ::

We need to infer that the command to highlight is :, but:

So even if we implement it, there are going to be pages where it doesn't work (unless there's some other way I haven't thought of).

What's the client from the first screenshot?