syntax highlighting in textAreaInput

I would like to make a shiny app in which the user can enter text that is then processed to extract some statistics and plot graphs.

The text can be annotated with some special characters and to help the user I would like to do some syntax highlighting. I am using a textAreaInput for the user to type and I was wondering if there is a way to do so.

For example I have in my app.R:

            textAreaInput("text", h3("Text input"), 
                      value = "Here is the user text with some characters with special meaning like: * and + ",
                      resize = "both")

In the above example I would like to have highlighted the * and + while the user is typing (as some sort of simple syntax highlighting). Can this be done with a textAreaInput? Is there another alternative?

Do you know the learnr package? It has an exercise component that allows to run a piece of R code in a textarea and it highlights certain words. You can look into the code of this component to see how they achieved that

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.