miaolz123 / vue-markdown

A Powerful and Highspeed Markdown Parser for Vue
https://miaolz123.github.io/vue-markdown/
MIT License
1.89k stars 257 forks source link

Highlight doesn't work when vue-markdown is called from <router-view/> #73

Open bjankie1 opened 6 years ago

bjankie1 commented 6 years ago

When vue-markdown is placec outside of router-view it works like a charm with highlighting. When the same component is called from within router-view component the highlighting doesn't apply. I will try to attach a screenshot presenting the effect. It seems to be some kind of race condition related to prism invocation.

bjankie1 commented 6 years ago

Screenshot

bjankie1 commented 6 years ago

I think I've found the answer: https://github.com/PrismJS/prism/issues/907

Prism only runs on DOMContentLoaded and highlights what's there. To highlight any other element, use Prism.highlightElement(). If there are many, use Prism.highlightAll(), but keep in mind that will also go over already highlighted elements and re-highlight them.