Prism.js not work for xml language in nicegui

62 views Asked by At

I'm trying use Prism for code highlight, but it did not apply for "xml language".

I add prism css and js files to head html and body html as below

ui.add_head_html('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.0/themes/prism.min.css"/>')
ui.add_body_html('<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/prism.min.js"></script>')

I tried python and css language and this way can work except xml language. I checked the page source and see that the tags "<", ">" did not replaced by < and >. Any help is appreciated

1

There are 1 answers

0
Theohreohn On

mark-up languages work a bit differently with prism. In order to get the angle brackets in the tags to render correctly you have to replace them with '&lt' and '&gt'. For example:

<anXMLTag>with some data</anXMLTag>

would have to be written as:

&ltanXMLTag&gtwith some data&lt/anXMLTag&gt.

You can find more information on this problem on this issue on Prism's Github page, and if you run into similar problems, this is handy for working around them