2020-09-22 09:32:14 +00:00
|
|
|
import Prism from 'prismjs';
|
|
|
|
|
2020-09-24 11:14:55 +00:00
|
|
|
const CodeHighlight = {
|
2020-09-22 09:32:14 +00:00
|
|
|
beforeMount(el, binding) {
|
2021-03-17 11:29:01 +00:00
|
|
|
const modifiers = binding.modifiers;
|
|
|
|
const value = binding.value;
|
|
|
|
|
|
|
|
if (modifiers.script || value === 'script')
|
2020-09-22 09:32:14 +00:00
|
|
|
el.className = 'language-javascript';
|
2021-03-17 11:29:01 +00:00
|
|
|
else if (modifiers.css || value === 'css')
|
2020-09-22 09:32:14 +00:00
|
|
|
el.className = 'language-css';
|
|
|
|
else
|
|
|
|
el.className = 'language-markup';
|
|
|
|
|
|
|
|
Prism.highlightElement(el.children[0]);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-17 11:29:01 +00:00
|
|
|
export default CodeHighlight;
|