tlrc icon indicating copy to clipboard operation
tlrc copied to clipboard

Feature request: add ability to highlight command name

Open MustCodeAl opened this issue 1 year ago • 2 comments
trafficstars

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 avatar Feb 27 '24 01:02 MustCodeAl

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

MustCodeAl avatar Feb 27 '24 09:02 MustCodeAl

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:

  • The filename is colon.md,
  • The title is colon,
  • The client has no idea where exactly is the command, so highlighting by position like you tried to do is also out of the picture.

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?

acuteenvy avatar Feb 27 '24 15:02 acuteenvy

I'm closing this, since it's not currently possible to make it work across all pages.

acuteenvy avatar Sep 29 '24 14:09 acuteenvy