PrismJS doesn't highlight with VueJS
See original GitHub issueHi, prism does not work when the content is loading async. (As with VueJS)
<pre id="editor">
<code class="language-css">{{ paste.content }}</code>
</pre>
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Prism not working inside Vue component - Stack Overflow
import Vue from 'vue' import Prism from 'prismjs' // Highlight some code Vue.filter('highlight', (code, lang = 'javascript') => { return ...
Read more >Syntax highlight with prismjs : r/vuejs - Reddit
Hello, I am working on a blog using a MEVN stack, and I did add a tiny-mce-vue to have a better layout with...
Read more >Prism Not Working Inside Vue Component - ADocLib
Vue JS is supposed to be a single page application and there is no classical server in the ... PrismJS doesn't highlight with...
Read more >Highlight Code Using Prism.js and Vue Component - Morioh
Highlight Code Using Prism.js and Vue Component. ... be used to capture the Print output if the drawing software does not directly support...
Read more >@j0nz/v-marked - npm
Advanced Setup With Syntax Highlighting from Prismjs ... import VMarked from '@j0nz/v-marked' Vue. ... If you prefer to link to your prism css...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello,
someone had a similar issue, using highlightjs which does a similar job as Prism (check the lastest answer from LinusBorg).
I don’t know if it’s your case, but I guess you are updating your model (paste.content) from your Vue / Component instance and you are expecting the DOM to be updated and highlighted in the same time.
The problem is that Prism will update your model rendered value (raw string), then apply a lot of HTML transformations. Then VueJS won’t be able to update the DOM. This is well described in the link I mentionned above :
One possible dirty solution is to update manually the DOM :
EDIT:
An exemple of code is :
One other option is to watch the paste object using the deep option which will help you to observe inner property change:
Hope it will help you
Solved using updated property on component: