portails/assets/js/highlight.js

25 lines
913 B
JavaScript
Raw Normal View History

2021-03-15 18:55:49 +01:00
import hljs from 'highlight.js/lib/core';
import javascript from 'highlight.js/lib/languages/javascript';
import json from 'highlight.js/lib/languages/json';
import bash from 'highlight.js/lib/languages/bash';
2021-06-15 16:27:38 +02:00
import xml from 'highlight.js/lib/languages/xml';
2021-03-15 18:55:49 +01:00
import ini from 'highlight.js/lib/languages/ini';
import yaml from 'highlight.js/lib/languages/yaml';
import markdown from 'highlight.js/lib/languages/markdown';
2021-03-15 18:55:49 +01:00
hljs.registerLanguage('javascript', javascript);
hljs.registerLanguage('json', json);
hljs.registerLanguage('bash', bash);
2021-06-15 16:27:38 +02:00
hljs.registerLanguage('html', xml);
2021-03-15 18:55:49 +01:00
hljs.registerLanguage('ini', ini);
hljs.registerLanguage('toml', ini);
hljs.registerLanguage('yaml', yaml);
hljs.registerLanguage('md', markdown);
2021-03-15 18:55:49 +01:00
document.addEventListener('DOMContentLoaded', () => {
2021-07-01 16:37:59 +02:00
document.querySelectorAll('pre code:not(.language-mermaid)').forEach((block) => {
hljs.highlightElement(block);
2021-03-15 18:55:49 +01:00
});
});