Template:LiExt/doc

LiExt is an extension of Li that allows several additional options to use to make numbered lists with indentations and special text formatting. LiExt will behave exactly the same as Li when none of the additional options are used. The documentation for Li is repeated first before the extra options are explained.

Li takes a list of up to 20 string elements, together with two parameters, one which is prefixed to each element and one which is suffixed to each element.

{{Li|p_str|s_str|ele_1|ele_2|...|ele_n}} returns

p_str ele_1 s_str
p_str ele_2 s_str
.
.
.
p_str ele_n s_str

with one space added after the p_str. For example

{{Li|<li>|</li>|dog|cat|mouse}} returns

<li> dog</li>
<li> cat</li>
<li> mouse</li>

The option num adds numbering starting at the value of num when set.  For example

{{Li|num=1.1.|<li>|</li>|dog|cat|mouse}} returns

<li>1.1.1 dog</li>
<li>1.1.2 cat</li>
<li>1.1.3 mouse</li>

Use num="" (empty quoted string) to add numbering starting at 1.  For example

{{Li|num=""|<li>|</li>|dog|cat|mouse}} returns

<li>1 dog</li>
<li>2 cat</li>
<li>3 mouse</li>

The options prolog and epilog prepend and append to the list.

{{Li|prolog=<ul>|epilog=</ul>|num=1.1.|<li>|</li>|dog|cat|mouse}} returns

<ul>
<li>1.1.1 dog</li>
<li>1.1.2 cat</li>
<li>1.1.3 mouse</li>
</ul>

The option prefix inserts another copy of ele_i followed by prefix after p_str.

For example you may hope

{{Li|prefix=">|num=1.1.|<li><a href="#|</a></li>|dog|cat|mouse}} returns

<li><a href="#dog">1.1.1 dog</a></li>
<li><a href="#cat">1.1.2 cat</a></li>
<li><a href="#mouse">1.1.3 mouse</a></li>

which does not display in wiki, but you can use

{{Li|prefix={{!}}|num=1.1.|<li>{{!((}}#|{{))!}}</li>|dog|cat|mouse}}

which does produce the source

<li><a href="#dog">1.1.1 dog</a></li>
<li><a href="#cat">1.1.2 cat</a></li>
<li><a href="#mouse">1.1.3 mouse</a></li>

This is equivalent in use to

<li>[[#dog|1.1.1 dog]]</li>
<li>[[#cat|1.1.2 cat]]</li>
<li>[[#mouse|1.1.3 mouse]]</li>


The call

{{Li|prolog=<ul>|epilog=</ul>|prefix={{!}}|num=1.1.|<li>{{!((}}#|{{))!}}</li>|
dog|cat|mouse}}

appears below.
An extra detail is that a | bar must end a line before a carraige return like

{{Li|
prolog=<ul>|epilog=</ul>|
prefix={{!}}|num=1.1.|
<li>{{!((}}#|{{))!}}</li>|
dog|
cat|
mouse}}

but it does not work for

{{Li|
prolog=<ul>|epilog=</ul>|
prefix={{!}}|num=1.1.|
<li>{{!((}}#|{{))!}}</li>
|dog
|cat
|mouse}}


The extra options are <b>rep_i</b>, <b>repl_i</b>, <b>repr_i</b>, <b>nofix_i</b>, <b>ref_i</b>, and <b>vis_i</b>.

The option rep_i replaces ele_i, the i'th member of the list, with the value
of rep_i. The option repl_i replaces the prefix p_str for the i'th member of the list with the value of repl_i. The option repr_i replaces the suffix s_str for the i'th member of the list with the value of repr_i. For example, the call
<pre>
{{LiExt|<li><i>|</i></li>|
rep_2=<span style="color:red;">hello</span>|
cow|mouse|bird|dog|cat}}

will produce
  • cow
  • hello
  • bird
  • dog
  • cat
  • The call

    {{LiExt|prolog=<ol>|epilog=</ol>|<li><i>|</i></li>|
    repl_2=<li type="a"><b>|repr_2=</b></li>|repl_3=<li style="color:red"><i>|
    cow|mouse|bird|dog|cat}}
    
    will produce
    
    1. cow
    2. mouse
    3. bird
    4. dog
    5. cat

    Setting the value of either of the options repl_i or repr_i to the empty quoted string "" will make that item an empty string. For example, the call

    {{LiExt|(<i>|</i>)|
    repl_3=""|repr_3=""|
    cow|mouse|bird|dog|cat}}
    
    will result in
    

    ( cow) ( mouse) bird ( dog) ( cat)


    Setting the value of the option nofix_i to anything will disable the effect of the option prefix for the i'th element of the list. When nofix_i is set all square brackets must also be removed on the i'th element using repl_i and repr_i.

    The call
    
    {{LiExt|prolog=<ul>|epilog=</ul>|prefix={{!}}|num=1.1.|<li>{{!((}}#|{{))!}}</li>|
    nofix_2=1|repl_2=<li>|repr_2=</li>|
    dog|cat|mouse}}
    
    appears below.
    

    The option ref_i is used to change the terminating string in the path that is by default ele_i when the option prefix is used. If ref_i is set, then the option vis_i can also be used to change the appearance of the link to the value of vis_i. When using ref_i the extra right square brackets must be removed using repr_i. This done this way so that the value of ele_i can remain in the list.

    The calls
    
    {{LiExt|prolog=<ul>|epilog=</ul>|prefix={{!}}|num=1.1.|<li>{{!((}}#|
    {{))!}}</li>|ref_2=horse|repr_2=</li>|
    dog|<span> </span>The cat is still here! |mouse}}
    
    {{LiExt|prolog=<ul>|epilog=</ul>|prefix={{!}}|num=1.1.|<li>{{!((}}#|
    {{))!}}</li>|ref_2=horse|vis_2=cat|repr_2=</li>|
    dog|<span> </span>The cat is still here! |mouse}}
    
    appear below.
    


    The html outputs are
    
    <ul>
    <li><a href="#dog">1.1.1 dog</a></li>
    <li><a href="#horse">1.1.2 horse</a> The cat is still here!</li>
    <li><a href="#mouse">1.1.3 mouse</a></li>
    </ul>
    
    and
    
    <ul>
    <li><a href="#dog">1.1.1 dog</a></li>
    <li><a href="#horse">1.1.2 cat</a> The cat is still here!</li>
    <li><a href="#mouse">1.1.3 mouse</a></li>
    </ul>
    .
    

    See also

    edit