In an application that I'm developing my goal would be to have highlighted code for some language, i.e. Java, and make so that some elements of code (functions, parameters) are clickable.
I understood that I need some js-based syntax highlighter capable to output raw html instead of linking a CSS stylesheet to the code.
What I still don't get is:
- Is there any highlighter that ouputs highlighted code in such format?
- How to make just some words clickable?
- Is there any alternative to this strategy?
UPDATE1: As first attempt, I downloaded the source code of the android-codepad project, and edited the HTMLViewerPlusPlus
class so that it highlights the HTML and, instead of showing it in a WebView, it shows it in a TextView, but since codepad uses css styling, I'm not getting the proper results. I'd need a new alternative that generates hard-styled html code.
UPDATE2: Using jsoup library with this method I managed to parse the code so that I get inline style attribute for each html element, but how to convert css styles to html tags?