portails/assets/js/highlight.js

25 lines
890 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', () => {
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightElement(block);
2021-03-15 18:55:49 +01:00
});
});