LLWiki正在建设中,欢迎加入我们!
“MediaWiki:Gadget-code-prettify.js”的版本间差异
跳转到导航
跳转到搜索
小 |
|||
第20行: | 第20行: | ||
} |
} |
||
}); |
}); |
||
if ($content.find('.prettyprint').length > 0) { |
if ($content.find('.prettyprint').length > 0) { mw.loader.load( '/zh?title=user:bhsd/highlight.js&action=raw&ctype=text/javascript' ); } |
||
mw.loader.getScript( '/zh?title=user:bhsd/highlight.js&action=raw&ctype=text/javascript' ).then(function() { |
|||
window.prettyPrint = true; |
|||
}); |
|||
} |
|||
}); |
}); |
2020年11月4日 (三) 05:05的版本
/* 引自[[moegirl:mediawiki:gadget-code-prettify.js]] */ mw.hook('wikipage.content').add( function($content) { var acceptsLangs = { "js": "javascript", "javascript": "javascript", "json": "json", "css": "css", "scribunto": "lua", "lua": "lua" }; var wgPageContentModel = mw.config.get( "wgPageContentModel" ).toLowerCase(); if (wgPageContentModel in acceptsLangs) { $content.find('.mw-code').addClass( 'prettyprint linenums ' + acceptsLangs[wgPageContentModel] ); } $content.find('pre[lang], code[lang]').each(function() { var self = $(this), lang = self.attr("lang").toLowerCase(); if (lang in acceptsLangs) { self.addClass("prettyprint " + acceptsLangs[lang]); if ( self.is('pre') ) { self.addClass("linenums"); } } }); if ($content.find('.prettyprint').length > 0) { mw.loader.load( '/zh?title=user:bhsd/highlight.js&action=raw&ctype=text/javascript' ); } });