import 'codemirror/mode/markdown/markdown';
import 'codemirror/mode/mllike/mllike';
import 'codemirror/mode/nginx/nginx';
+import 'codemirror/mode/perl/perl';
import 'codemirror/mode/php/php';
import 'codemirror/mode/powershell/powershell';
import 'codemirror/mode/properties/properties';
markdown: 'markdown',
ml: 'mllike',
nginx: 'nginx',
+ perl: 'perl',
+ pl: 'perl',
powershell: 'powershell',
properties: 'properties',
ocaml: 'mllike',
* Highlight pre elements on a page
*/
function highlight() {
- let codeBlocks = document.querySelectorAll('.page-content pre, .comment-box .content pre');
- for (let i = 0; i < codeBlocks.length; i++) {
- highlightElem(codeBlocks[i]);
+ const codeBlocks = document.querySelectorAll('.page-content pre, .comment-box .content pre');
+ for (const codeBlock of codeBlocks) {
+ highlightElem(codeBlock);
+ }
+}
+
+/**
+ * Highlight all code blocks within the given parent element
+ * @param {HTMLElement} parent
+ */
+function highlightWithin(parent) {
+ const codeBlocks = parent.querySelectorAll('pre');
+ for (const codeBlock of codeBlocks) {
+ highlightElem(codeBlock);
}
}
* @returns {*|string}
*/
function getTheme() {
- return window.codeTheme || 'base16-light';
+ return window.codeTheme || 'mdn-like';
}
/**
export default {
highlight: highlight,
+ highlightWithin: highlightWithin,
wysiwygView: wysiwygView,
popupEditor: popupEditor,
setMode: setMode,