DelDOT Project Development Manual:Auto-number headings: Difference between revisions

From DelDOT Project Development Manual
Jump to navigation Jump to search
Jtice (talk | contribs)
Created page with "This will be a goal for the 2023 Edition. In order to make future edits simpler when renumbering sections, it would be preferable to have sections autonumbered. When hyperlinking to specific sections it should no longer be necessary to refer to the section number since the sections are linkable. The same applies to figures and tables. == Section Headers == === In the page content === Simple: * Remove the numbers from all the section headings in the wiki markup of Sectio..."
 
Jtice (talk | contribs)
mNo edit summary
 
Line 4: Line 4:
=== In the page content ===
=== In the page content ===
Simple:
Simple:
* Remove the numbers from all the section headings in the wiki markup of Section 100 pages.
* Remove the numbers from all the section headings in the wiki markup of Section 100 pages.<br />Example: <code>=== <s style="color:red;">102.1.3 </s>Bridge Sheet Preparation ===</code>
: Example: <code>=== <s style="color:red;">102.1.3 </s>Bridge Sheet Preparation ===</code>
* Remove the numbers from the page anchor portion of anchor links.<br />Example: <code>[[102 - Bridge Design Submission Requirements#<s style="color:red;">102.1.3 </s>Bridge Sheet Preparation|<s style="color:red;">102.1.3 </s>Bridge Sheet Preparation]]</code>
* Remove the numbers from the page anchor portion of anchor links.
: Example: <code>[[102 - Bridge Design Submission Requirements#<s style="color:red;">102.1.3 </s>Bridge Sheet Preparation|<s style="color:red;">102.1.3 </s>Bridge Sheet Preparation]]</code>


=== In the backend interface ===
=== In the backend interface ===
Line 13: Line 11:


<pre>
<pre>
if ( mw.config.get( 'wgPageName' ) === 'Pagename' ) {
if ( mw.config.get( 'wgPageName' ) === 'Pagename' ) {
     [snippet]
     [snippet]
}
}
Line 35: Line 33:


<pre>
<pre>
.page-101_-_Introduction :is(.tocnumber::before, .mw-headline::before) {
.page-101_-_Introduction :is(.tocnumber::before, .mw-headline::before) {
     101
     101
}
}

Latest revision as of 19:41, 4 November 2022

This will be a goal for the 2023 Edition. In order to make future edits simpler when renumbering sections, it would be preferable to have sections autonumbered. When hyperlinking to specific sections it should no longer be necessary to refer to the section number since the sections are linkable. The same applies to figures and tables.

Section Headers

In the page content

Simple:

  • Remove the numbers from all the section headings in the wiki markup of Section 100 pages.
    Example: === 102.1.3 Bridge Sheet Preparation ===
  • Remove the numbers from the page anchor portion of anchor links.
    Example: [[102 - Bridge Design Submission Requirements#102.1.3 Bridge Sheet Preparation|102.1.3 Bridge Sheet Preparation]]

In the backend interface

Use this snippet in MediaWiki:Common.js. We only want to apply it to specific pages (Section 100) so put within something like this

if ( mw.config.get( 'wgPageName' ) === 'Pagename' ) {
    [snippet]
}

for each page OR modify the snippet like this to select the page-specific css classes:

var toc = document.querySelector('#toc');
if (toc) {
  document.querySelectorAll(':is(.page-XXX,...) .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 + ' ');
  });
} else {
  document.body.classList.add('tpl-autonum');
}

Use the page-specific css classes with ::before in MediaWiki:Common.css to add the section number in front:

.page-101_-_Introduction :is(.tocnumber::before, .mw-headline::before) {
    101
}
.page-102_-_Bridge_Design_Submission_Requirements :is(.tocnumber::before, .mw-headline::before) {
    102
}
...

And remove the .tocnumber {display: none;}

Figures and Tables

There are multiple "figures" that should be tables and accomplishing this first would make that conversion easier. It would be feasible to accomplish this with redirects (wouldn't work for tables though) but it would still be preferable to auto-number the Section 100 figure captions and not refer to them by number but by the caption, just like with #Section Headers.

In the page content

Basically the similar to #Section Headers.

In the backend interface

All File:FIGURE XXX.XX pages would have to be renamed to something descriptive.