simonw / datasette-ripgrep

Web interface for searching your code using ripgrep, built as a Datasette plugin
https://ripgrep.datasette.io
Apache License 2.0
72 stars 1 forks source link

Add syntax highlighting #23

Open pjamargh opened 3 years ago

pjamargh commented 3 years ago

It would be great to have syntax highlighting shown on the results (depending on the extensions).

Maybe is possible to leverage https://github.com/simonw/datasette-render-markdown and its Markdown engine's https://python-markdown.github.io/extensions/code_hilite/ extension to display that. Something like ripgrep > recognize files pieces > mardown with code blocks > datasette-render-markdown.

Thanks!

pjamargh commented 3 years ago

I just found out another fast tool to generate syntax highlighted output (https://github.com/sharkdp/bat) has specific integration with ripgrep (see https://github.com/eth-p/bat-extras/blob/master/doc/batgrep.md). As it does not have html output you would still have to convert the result with ANSI's color to html.