InBrowserApp / tldr.inbrowser.app

📝 tldr InBrowser.App is a offline-capable PWA for tldr-pages. Fully runs in your browser. Zero API latency.
https://tldr.inbrowser.app
MIT License
185 stars 21 forks source link

Add customizable syntax highlighting for generic placeholders #2

Open EmilyGraceSeville7cf opened 1 year ago

EmilyGraceSeville7cf commented 1 year ago

Add a customizable syntax highlighting for generic placeholders:

rwv commented 1 year ago

Is there any example for highlighting? thank you!

EmilyGraceSeville7cf commented 1 year ago

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 commented 1 year ago

python color code:

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

EmilyGraceSeville7cf commented 1 year ago

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 commented 1 year ago

Branch

syntax-highlighting

Demo

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

TODO

rwv commented 1 year ago

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 commented 1 year ago

I am glad to see syntax highlighting enabled. 😄