Closed thiswillbeyourgithub closed 8 months ago
Thanks @thiswillbeyourgithub -- I think this would be a great case for a custom component, you can use gr.Code
or gr.HighlightedText
as a template! https://www.gradio.app/guides/five-minute-guide (we're happy to help).
I think this is outside of the scope of gr.Code
itself (I'm not sure if codemirror, which we use internally, supports custom syntaxes anyways) so I'll go ahead and close this. However, if you do decide to create a custom component, we're happy to help @thiswillbeyourgithub!
Codemirror does support custom syntaxes but it does so via lezer, a parser generator that has a build step. The generated parsers also need to be registered via JavaScript which poses a logistical problem as well.
This is definitely better suited as a custom component. The Code component might be a good thing to work from if you wanted to write a grammar for the custom syntax.
Alright. I'll keep it in the back of my mind but there's a low prob I'll get to it : I'm less than novice at js and won't have time for a while
Is your feature request related to a problem? Please describe.
I use gradio for an app where an LLM outputs a formatted string to the user. I would like to highlight words with low logprob while still making the text editable and also highlight some specific symbols. Using
gr.HighlightedText
sounded promissing butinteractive=True
only allows me to modify the spans of highlight and not the text.gr.Code
seems perfect but only supports predefined langauges.Describe the solution you'd like
Allowing to pass user defined syntax for language syntaxic highlighting. This would allow much flexibility and allow many use case.
Additional context
Assistant message:
. This is an example of string I'd like to highlight.