Skip to content
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

Add customizable syntax highlighting for generic placeholders #2

Open
EmilyGraceSeville7cf opened this issue Jan 4, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@EmilyGraceSeville7cf
Copy link

EmilyGraceSeville7cf commented Jan 4, 2023

Add a customizable syntax highlighting for generic placeholders:

  • strings:
    • default: highlight quotes and content inside them with orange color
    • settings: quotes and content color can be changed just together
  • numbers
    • default: highlight integers and floats in cyan color
    • settings: integer and float colors can be changed just together
  • ranges
    • default:
      • highlight borders (integer or float numbers) in cyan
      • highlight -infinity and infinity keywords in blue
      • highlight .. in light cyan
    • settings: can be customized for 3 different aspects separately
  • path placeholders
    • default: highlight paths in red, while highlighting their separators in dark red
    • settings: can be customized for 3 different aspects separately
  • placeholders with ellipsis
    • defaults:
      • all defaults listed above applies for ellipsis placeholders
      • ... is highlighted as gray
    • settings: only changing ... color is supported, all other settings are being set for concrete placeholder types
@EmilyGraceSeville7cf EmilyGraceSeville7cf changed the title Add syntax customizable highlighting for generic placeholders Add customizable syntax highlighting for generic placeholders Jan 4, 2023
@rwv
Copy link
Contributor

rwv commented Jan 4, 2023

Is there any example for highlighting? thank you!

@EmilyGraceSeville7cf
Copy link
Author

EmilyGraceSeville7cf commented Jan 4, 2023

Yeah, our official Python client supports highlighting, but in a much simplified manner: just placeholder content is emphasized (without respect of the kind of it).

image

@rwv
Copy link
Contributor

rwv commented Jan 4, 2023

python color code:

https://github.com/tldr-pages/tldr-python-client/blob/c7d70091e958d1ccddd1e038578ad9ee897c5358/tldr.py#L344-L369

@EmilyGraceSeville7cf
Copy link
Author

EmilyGraceSeville7cf commented Jan 4, 2023

I think that a proper parser can be written to process placeholders. We already have tldr-lint, check it out how pages are analyzed for smells, maybe you find smth useful. But for the beginning regex based highlighting can be used. This is how tldr client for Emacs works AFAIK.

@rwv
Copy link
Contributor

rwv commented Jan 5, 2023

Branch

syntax-highlighting

Demo

https://syntax-highlighting.tldr-inbrowser-app.pages.dev/

TODO

  • decide a highlight color theme with light and dark mode
  • replace more syntax
  • find a style for mnemonics
  • customize color

@rwv
Copy link
Contributor

rwv commented Jan 5, 2023

To achieve better synatx highlighting, we need to parse the markdown by ourself as well. marked.parse only returns raw html which doesn't quite compatiable with vue. As a result, some functionalities such as copy to clipboard cannot be implemented.

@EmilyGraceSeville7cf
Copy link
Author

I am glad to see syntax highlighting enabled. 😄

@rwv rwv added the enhancement New feature or request label Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants