Template:Row numbers/doc: Difference between revisions

From escforumwiki
Jump to navigation Jump to search
en>Manabimasu
No edit summary
m (39 revisions imported)
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
{{lua|Module:Row numbers}}
{{lua|Module:Row numbers}}
{{warning|This template breaks content in the mobile app because it relies on an escaping strategy which does not work with Parsoid, which is used by o.a. the Mobile apps. See also: [[phab:T203293]].}}
This is a stop-gap template that serves as an interface to [[Module:Row numbers]].
This is a stop-gap template that serves as an interface to [[Module:Row numbers]].


Line 11: Line 10:
"1": {
"1": {
"label": "the wikitable",
"label": "the wikitable",
"description": "the wiki table surrounded by <nowiki>… </nowiki> tags",
"description": "Either the whole wiki table surrounded by <nowiki>… </nowiki> tags, or the first section, when split by {{!}} characters",
"type": "string",
"type": "string",
"required": true,
"required": true,
Line 18: Line 17:
"index": {
"index": {
"label": "starting index",
"label": "starting index",
"description": "starting index of row count which is useful when table is split by headings. See https://en.wikipedia.org/w/index.php?title=List_of_highest-funded_crowdfunding_projects&oldid=1018568495",
"description": "starting index of row count which is useful when table is split by headings.<br><small>See [https://en.wikipedia.org/w/index.php?title=List_of_highest-funded_crowdfunding_projects&oldid=1018568495 List of highest-funded crowdfunding projects]</small>",
"example": "50",
"example": "50",
"type": "number",  
"type": "number",  
Line 30: Line 29:
} }}  
} }}  


This template takes one parameter: the table and the starting index. There is a caveat: the table {{em|must}} be wrapped inside {{tag|nowiki}} tags so that all of the pipe characters (<code>|</code>) required in a wiki table do not confuse the template into thinking that they are all individual template parameters. Internally, the Module maintains a monotonically increasing counter. The Module looks for the keywords <code>_row_count</code> and <code>_row_count_hold</code> in the table. Keyword <code>_row_count</code> is replaced with the next counter value; keyword <code>_row_count_hold</code> is replaced with the value from the last <code>_row_count</code> replacement.
This template takes an arbitrary number of parameters: the table and the starting index. There is a caveat: the table is wrapped in the template without escaping the <code>|</code> characters. The module is capable of dealing with this, but it is not capable of dealing with bare equals signs at the same time. As such, bare equals signs must still be escaped with {{tl|=}}. Internally, the Module maintains a monotonically increasing counter. The Module looks for the keywords <code>_row_count</code> and <code>_row_count_hold</code> in the table. Keyword <code>_row_count</code> is replaced with the next counter value; keyword <code>_row_count_hold</code> is replaced with the value from the last <code>_row_count</code> replacement.


{| class="wikitable"
{| class="wikitable"
Line 37: Line 36:
! Visual effect !! Markup
! Visual effect !! Markup
|-
|-
| {{row numbers|<nowiki>
| {{row numbers|
{| class="wikitable"
{| class{{=}}"wikitable"
|+test incrementor
|+test incrementor
!count !! lorem
!count !! lorem
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|123}}
|_row_count || {{Str left|{{Lorem ipsum span}}|123}}
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|27}}
|_row_count || {{Str left|{{Lorem ipsum span}}|27}}
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|5}}
|_row_count || {{Str left|{{Lorem ipsum span}}|5}}
|-
|-
|_row_count_hold || {{Str left|{{Lorem ipsum}}|11}}
|_row_count_hold || {{Str left|{{Lorem ipsum span}}|11}}
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|123}}
|_row_count || {{Str left|{{Lorem ipsum span}}|123}}
|}</nowiki>}}
|}}}
|| <pre> {{row numbers|&lt;nowiki>
|| <pre>{{row numbers|
{| class="wikitable"
{| class{{=}}"wikitable"
|+test incrementor
|+test incrementor
!count !! lorem
!count !! lorem
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|123}}
|_row_count || {{Str left|{{Lorem ipsum span}}|123}}
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|27}}
|_row_count || {{Str left|{{Lorem ipsum span}}|27}}
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|5}}
|_row_count || {{Str left|{{Lorem ipsum span}}|5}}
|-
|-
|_row_count_hold || {{Str left|{{Lorem ipsum}}|11}}
|_row_count_hold || {{Str left|{{Lorem ipsum span}}|11}}
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|123}}
|_row_count || {{Str left|{{Lorem ipsum span}}|123}}
|}}} </pre>
|}}}</pre>
|-
|-
|  {{row numbers|<nowiki>
|  {{row numbers|
{| class="wikitable"
{| class{{=}}"wikitable"
|+test incrementor
|+test incrementor
!count !! lorem
!count !! lorem
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|123}}
|_row_count || {{Str left|{{Lorem ipsum span}}|123}}
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|27}}
|_row_count || {{Str left|{{Lorem ipsum span}}|27}}
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|5}}
|_row_count || {{Str left|{{Lorem ipsum span}}|5}}
|-
|-
|_row_count_hold || {{Str left|{{Lorem ipsum}}|11}}
|_row_count_hold || {{Str left|{{Lorem ipsum span}}|11}}
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|123}}
|_row_count || {{Str left|{{Lorem ipsum span}}|123}}
|}</nowiki>|index =50}}  
|}|index =50}}  
|| <pre>   {{row numbers| &lt;nowiki>
|| <pre>{{row numbers|
{| class="wikitable"
{| class{{=}}"wikitable"
|+test incrementor
|+test incrementor
!count !! lorem
!count !! lorem
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|123}}
|_row_count || {{Str left|{{Lorem ipsum span}}|123}}
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|27}}
|_row_count || {{Str left|{{Lorem ipsum span}}|27}}
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|5}}
|_row_count || {{Str left|{{Lorem ipsum span}}|5}}
|-
|-
|_row_count_hold || {{Str left|{{Lorem ipsum}}|11}}
|_row_count_hold || {{Str left|{{Lorem ipsum span}}|11}}
|-
|-
|_row_count || {{Str left|{{Lorem ipsum}}|123}}
|_row_count || {{Str left|{{Lorem ipsum span}}|123}}
|} &lt;/nowiki> |index =50}} </pre>
|} |index =50}}</pre>
|}
|}


There are further caveats.  When wrapped in {{tag|nowiki}}, the '<code><</code>' and '<code>></code>' characters that begin and end all html-like markup, are replaced with <code>&amp;lt;</code> and <code>&amp;gt;</code> html entities respectively.  Because the Module cannot know if there are html entities already in use before the table was wrapped in the {{tag|nowiki}} tags required here, when the module replaces the html entities with '<code><</code>' and '<code>></code>' characters, something may break. {{lang|la|caveat lector}}.
<includeonly>{{sandbox other||
<includeonly>{{sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata -->
<!-- Categories below this line, please; interwikis at Wikidata -->


}}</includeonly>
}}</includeonly>

Latest revision as of 19:08, 15 June 2022

This is a stop-gap template that serves as an interface to Module:Row numbers.

This template makes it possible, in many cases, to have an incrementing row indexer/counter in a table so that adding or removing rows automatically adjusts the numbering of subsequent rows. This template will become obsolete if and when MediaWiki supports automatically adding row numbers via WikiTable syntax. See Phab: T42618 - "jquery.tablesorter: Add support for a 'fixed' column of row numbers." And see Help:Sorting, and the sections on row numbering and auto-ranking. Using Template:Row numbers is one of the methods described on that page.

Usage

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Row numbers in articles based on its TemplateData.

TemplateData for Row numbers

INTERNAL: Module:Format_TemplateData:568: assign to undeclared variable 'dt'

This template takes an arbitrary number of parameters: the table and the starting index. There is a caveat: the table is wrapped in the template without escaping the | characters. The module is capable of dealing with this, but it is not capable of dealing with bare equals signs at the same time. As such, bare equals signs must still be escaped with {{[[Template:{{{1}}}|{{{1}}}]]}}. Internally, the Module maintains a monotonically increasing counter. The Module looks for the keywords _row_count and _row_count_hold in the table. Keyword _row_count is replaced with the next counter value; keyword _row_count_hold is replaced with the value from the last _row_count replacement.

Examples
Visual effect Markup
test incrementor
count lorem
1 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
2 Lorem ipsum dolor sit amet,
3 Lorem
3 Lorem ipsum
5 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
{{row numbers|
{| class{{=}}"wikitable"
|+test incrementor
!count !! lorem
|-
|_row_count || {{Str left|{{Lorem ipsum span}}|123}}
|-
|_row_count || {{Str left|{{Lorem ipsum span}}|27}}
|-
|_row_count || {{Str left|{{Lorem ipsum span}}|5}}
|-
|_row_count_hold || {{Str left|{{Lorem ipsum span}}|11}}
|-
|_row_count || {{Str left|{{Lorem ipsum span}}|123}}
|}}}
test incrementor
count lorem
50 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
51 Lorem ipsum dolor sit amet,
52 Lorem
52 Lorem ipsum
54 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
{{row numbers|
{| class{{=}}"wikitable"
|+test incrementor
!count !! lorem
|-
|_row_count || {{Str left|{{Lorem ipsum span}}|123}}
|-
|_row_count || {{Str left|{{Lorem ipsum span}}|27}}
|-
|_row_count || {{Str left|{{Lorem ipsum span}}|5}}
|-
|_row_count_hold || {{Str left|{{Lorem ipsum span}}|11}}
|-
|_row_count || {{Str left|{{Lorem ipsum span}}|123}}
|} |index =50}}