ページの作成:「→* * Auto-number headings * * @source https://www.mediawiki.org/wiki/Snippets/Auto-number_headings * @author Krinkle * @version 2021-10-03: var toc = document.querySelector('#toc'); if (toc) { document.querySelectorAll('.mw-parser-output :is(h1,h2,h3,h4,h5,h6) .mw-headline').forEach(function (headline) { var num = toc.querySelector('a[href="#' + CSS.escape(headline.id) + '"] .tocnumber'); if (num) headline.prepend(num.textContent + ' '); }); } e…」 |
編集の要約なし |
||
| 4行目: | 4行目: | ||
* @source https://www.mediawiki.org/wiki/Snippets/Auto-number_headings | * @source https://www.mediawiki.org/wiki/Snippets/Auto-number_headings | ||
* @author Krinkle | * @author Krinkle | ||
* @version | * @version 2024-04-25 | ||
*/ | */ | ||
var toc = document.querySelector('#toc'); | var toc = document.querySelector('#toc'); | ||
if (toc) { | if (toc) { | ||
document.querySelectorAll('.mw-parser-output :is(h1,h2,h3,h4,h5,h6) .mw-headline').forEach(function (headline) { | // Support legacy Parser: <h2><span class=mw-headline id=…> | ||
// Support Parsoid: <section><div class=mw-heading><h2 id…> | |||
document.querySelectorAll('.mw-parser-output :is(h1,h2,h3,h4,h5,h6) .mw-headline[id], .mw-parser-output .mw-heading [id]:is(h1,h2,h3,h4,h5,h6)').forEach(function (headline) { | |||
var num = toc.querySelector('a[href="#' + CSS.escape(headline.id) + '"] .tocnumber'); | var num = toc.querySelector('a[href="#' + CSS.escape(headline.id) + '"] .tocnumber'); | ||
if (num) headline.prepend(num.textContent + ' '); | if (num) headline.prepend(num.textContent + ' '); | ||
2024年5月13日 (月) 00:32時点における最新版
/**
* Auto-number headings
*
* @source https://www.mediawiki.org/wiki/Snippets/Auto-number_headings
* @author Krinkle
* @version 2024-04-25
*/
var toc = document.querySelector('#toc');
if (toc) {
// Support legacy Parser: <h2><span class=mw-headline id=…>
// Support Parsoid: <section><div class=mw-heading><h2 id…>
document.querySelectorAll('.mw-parser-output :is(h1,h2,h3,h4,h5,h6) .mw-headline[id], .mw-parser-output .mw-heading [id]:is(h1,h2,h3,h4,h5,h6)').forEach(function (headline) {
var num = toc.querySelector('a[href="#' + CSS.escape(headline.id) + '"] .tocnumber');
if (num) headline.prepend(num.textContent + ' ');
});
} else {
document.body.classList.add('tpl-autonum');
}