If you're looking for a Code Syntax Highlighter, I have a suggestion.
Based on your mention of jsx
, it seems like you're working with React.
You might want to consider using a library called react-syntax-highlighter
.
https://github.com/react-syntax-highlighter/react-syntax-highlighter#readme
UPDATE
I see that you're not using React, but I've provided a simple example below of how you can achieve similar results without any libraries.
function encodeHtml(html) {
return html.replace(/[\u00A0-\u9999<>\&]/g, i => '&#'+i.charCodeAt(0)+';');
}
function colorHtml(html) {
return encodeHtml(html)
.replace(/ifx-icon/g, '<span style="color:green">ifx-icon</span>')
.replace(/\sicon/g, '<span style="color:blue"> icon</span>');
}
const App = () => {
const data = colorHtml('<ifx-icon icon="c-check-16"></ifx-icon>');
return (
<pre>
<code dangerouslySetInnerHTML={{__html: data}}/>
</pre>
);
}
export default App;
Preview: https://codesandbox.io/s/crazy-khorana-sq57k5?file=/src/App.js
Remember, this is just a starting point. Feel free to customize the regex/string replacements to suit your specific needs.