LLWiki正在建设中,欢迎加入我们

“MediaWiki:Gadget-code-prettify.js”的版本间差异

跳转到导航 跳转到搜索
无编辑摘要
$block.each(function() { hljs.highlightBlock( this ); }).addClass( 'highlighted' ).filter( '.linenums' )
.html(function() { // 添加行号。这里不使用<table>排版,而是使用<ol>
const $this = $(this);,
start = $this.data( 'start' ) || 1;
$this.children( ':contains(\n)' ).replaceWith(function() { // 先处理跨行元素
const $self = $(this);
var lines = $this.html().replace(/\n$/, '').split('\n');
if (mw.config.get( 'wgNamespaceNumber' ) == 274) { lines = lines.slice(1, -1); } // 扔掉首尾的Wikitext注释
return $('<ol>', { start: $this.data( 'start' ),
html: lines.map(function(ele, i) { return $('<li>', {html: ele, id: 'L' + (i + 1start)}); })
}).css('padding-left', (lines.length + start - 1).toString().length + 2.5 + 'ch');
});
mw.hook( 'code.prettify' ).fire( $block );
16,874

个编辑

导航菜单