http://glottopedia.org/index.php?title=User:Bibiko/GlossCnt&feed=atom&action=historyUser:Bibiko/GlossCnt - Revision history2024-03-29T05:20:38ZRevision history for this page on the wikiMediaWiki 1.34.2http://glottopedia.org/index.php?title=User:Bibiko/GlossCnt&diff=13169&oldid=prevWohlgemuth: Wohlgemuth moved page User:Hans-Jörg Bibiko/GlossCnt to User:Bibiko/GlossCnt2013-04-05T11:45:02Z<p>Wohlgemuth moved page <a href="/index.php/User:Hans-J%C3%B6rg_Bibiko/GlossCnt" class="mw-redirect" title="User:Hans-Jörg Bibiko/GlossCnt">User:Hans-Jörg Bibiko/GlossCnt</a> to <a href="/index.php/User:Bibiko/GlossCnt" title="User:Bibiko/GlossCnt">User:Bibiko/GlossCnt</a></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">Revision as of 11:45, 5 April 2013</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>Wohlgemuthhttp://glottopedia.org/index.php?title=User:Bibiko/GlossCnt&diff=6128&oldid=prevBibiko: New page: <big><big><big>Extension GlossCnt – An auto-count function</big></big></big><br><br> __TOC__ ==Background== It is often the case that an editor of an article wants to number exampl...2008-05-16T08:50:22Z<p>New page: <big><big><big>Extension GlossCnt – An auto-count function</big></big></big><br><br> __TOC__ ==Background== It is often the case that an editor of an article wants to number exampl...</p>
<p><b>New page</b></p><div><big><big><big>Extension GlossCnt &#8211; An auto-count function</big></big></big><br><br><br />
__TOC__<br />
<br />
==Background==<br />
<br />
It is often the case that an editor of an article wants to number examples, figures, diagrams, etc. serially. This can be done by hand. By doing so a problem arises if you want to add for instance a further example between existing ones. After inserting it the editor has to renumber all example following the new one. Furthermore if within this article occurs a reference like ''see example (6)'' the editor has to renumber this reference as well.<br />
<br />
<blockquote style="margin:10px;color:blue">To solve this problem the editor can use this extension '''GlossCnt''' to number them automatically by using the tags '''&lt;glcnt /&gt;''' and '''&lt;glref /&gt;'''.</blockquote><br />
<br />
<br />
==Short Description==<br />
<br />
What can you do with this extension in short terms:<br />
<br />
* define several independent counters by using different ''ns'' (&lt;glcnt ns="''ns''" name="''name''" /&gt;)<br />
* refer to the a specific counter by using the ''name'' attribute (&lt;glref name="''name''" /&gt;)<br />
* predefine the type of counting (numeric or alphabetic)<br />
** for sub-counter: specify whether only the sub-counter will be displayed ( ''7b'' or only ''b'' )<br />
* predefine the format, like '''(1)''', or '''§a''', or '''figure :''', which will be bequeathed<br />
* define a sub-counter linked via ''name'' (&lt;glsub of="''name''" /&gt;)<br />
* reset a global counter (&lt;glreset ns="''ns''" /&gt;)<br />
<br />
&nbsp;<br />
<br />
==Usage==<br />
===The tag &lt;glcnt /&gt;===<br />
<blockquote><br />
<font color=blue>'''Syntax:'''</font> &lt;glcnt ns="''ns''" pre="''prefix''" suf="''suffix''" name="''name''" type="''type''" nocnt /&gt;<br />
{| style="background-color:#EEEEEE;" cellpadding="5px"<br />
|-valign="top"<br />
| ''ns'' || ''ns'' must be a valid identifier to be able to count different topics independently.<br> If not set the default identifier ''glcnt'' is taken || optional except for counting different topics<br />
|-valign="top"<br />
| ''prefix'' || ''prefix'' specifies what will be printed just before the following number.<br>If ''prefix'' is set within the first occurrence of that tag all succeeding tags of the same ''ns'' inherits it. Otherwise its default is "(". || optional<br />
|-valign="top"<br />
| ''suffix'' || ''suffix'' specifies what will be printed just after the preceding number.<br>If ''suffix'' is set within the first occurrence of that tag all succeeding tags of the same ''ns'' inherits it. Otherwise its default is "(". || optional<br />
|-valign="top"<br />
| ''name'' || ''name'' must be any unique and valid name to be able to refer to it by using the tag &lt;glref&nbsp;/&gt;. || optional except for referring to it<br />
|-valign="top"<br />
| ''type'' || It specifies the type for counting<br>&nbsp;&nbsp;allowed types:<br>&nbsp;&nbsp;&nbsp;&nbsp;A : counts A, B, ..., Z, AA, AB, ...<br>&nbsp;&nbsp;&nbsp;&nbsp;a : counts a, b, ..., z, aa, ab, ...<br>If not set numerical counting is its default. || optional<br />
|-valign="top"<br />
| nocnt || This attribute suppresses the incrementing of the counter || &nbsp;<br />
|}<br />
<br />
<br />
<font color=blue>'''Further explanations:'''</font><br />
<br />
* ''prefix'' and ''suffix'' have to have set together. If you set only ''suffix'' this attribute will be ignored.<br />
* It is possible to add HTML tags to ''prefix'' and ''suffix''.<br>'''Example''': &lt;glcnt pre="[&amp;lt;b&amp;gt;" suf="&amp;lt;/b&amp;gt;]" /&gt; to set the number in bold face enclosed by "[]" like ['''3'''].<br>Please note that &lt; , &gt; , and &amp; must be escaped: &amp;lt; , &amp;gt; , &amp;amp;<br />
* ''name'' and ''ns'' may only contain the following characters: '''A''' to '''Z''', '''a''' to '''z''', numbers and an '''_'''<br />
* If you are editing only a section of an article please note that the numbering starts always at 1 (resp. A or a) in the Preview regardless the number of this tag within the entire article. After saving this section the numbering within the article is serially.<br />
* The ''type'' attribute must be specified within the first occurrence of &lt;glcnt {ns="''ns''"}&nbsp;/&gt;!<br />
* If ''prefix'' and ''suffix'' are set within the first occurrence of that tag you can use it as a kind of caption for figures, diagrams, examples, etc. (e.g.: figure 1, figure 2)<br />
</blockquote><br />
<br />
===The tag &lt;glsub /&gt;===<br />
<br />
<blockquote><br />
<font color=blue>'''Syntax:'''</font> &lt;glsub of="''of''" pre="''prefix''" suf="''suffix''" name="''name''" type="''type''" sep="''sep''" nocnt /&gt;<br />
{| style="background-color:#EEEEEE;" cellpadding="5px"<br />
|-valign="top"<br />
| ''of'' || ''of'' must be a valid superior name specified within the tags &lt;glcnt /&gt; or &lt;glsub /&gt;. || must be set<br />
|-valign="top"<br />
| ''prefix'' || ''prefix'' specifies what will be printed just before the following number.<br>If no ''prefix'' is set its default is "". || optional<br />
|-valign="top"<br />
| ''suffix'' || ''suffix'' specifies what will be printed just after the preceding number.<br>If no ''suffix'' is set its default is "". || optional<br />
|-valign="top"<br />
| ''name'' || ''name'' must be any unique and valid name to be able to refer to it by using the tag &lt;glref&nbsp;/&gt;. || optional except for referring to it<br />
|-valign="top"<br />
| ''type'' || It specifies the type for counting<br>&nbsp;&nbsp;allowed types:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A : counts A, B, ..., Z, AA, AB, ...<br>&nbsp;&nbsp;&nbsp;&nbsp;_A : counts A, B, ..., Z, AA, AB, ..., but it only displays the subcounter<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a : counts a, b, ..., z, aa, ab, ...<br>&nbsp;&nbsp;&nbsp;&nbsp;_a : counts a, b, ..., z, aa, ab, ..., but it only displays the subcounter<br>&nbsp;&nbsp;&nbsp;&nbsp;_1 : counts 1, 2, ..., but it only displays the subcounter<br>If not set numerical counting is its default. || optional<br />
|-valign="top"<br />
| ''sep'' || This string is used for separating the sub-counter.<br>If not set its default is "" or "." if the sub-types is equal to its superior type. Once ''sep'' is set the following sub-counter for ''of'' inherits it until it is set again. || optional<br />
|-valign="top"<br />
| nocnt || This attribute suppresses the incrementing of the counter || &nbsp;<br />
|}<br />
<br />
<br />
<br />
<font color=blue>'''Further explanations:'''</font><br />
<br />
* It is possible to nest &lt;glsub /&gt; via the attribute ''name'' to get e.g. (1.4d).<br />
* The ''type'' attribute '''must''' be specified within the first occurrence of &lt;glsub of="''of''"}&nbsp;/&gt;!<br />
<br />
</blockquote><br />
<br />
===The tag &lt;glref /&gt;===<br />
<br />
<blockquote><br />
<font color=blue>'''Syntax:'''</font> &lt;glref pre="''prefix''" suf="''suffix''" name="''name''" /&gt;<br />
{| style="background-color:#EEEEEE;" cellpadding="5px"<br />
|-valign="top"<br />
| ''prefix'' || ''prefix'' specifies what will be printed just before the following number.<br>If not set it inherits it from the refered &lt;glcnt&nbsp;name="''name''"&nbsp;/&gt;. || optional<br />
|-valign="top"<br />
| ''suffix'' || ''suffix'' specifies what will be printed just after the preceding number.<br>If not set it inherits it from the refered &lt;glcnt&nbsp;name="''name''"&nbsp;/&gt;. || optional<br />
|-valign="top"<br />
| ''name'' || ''name'' specifies to which &lt;glcnt&nbsp;name="''name''"&nbsp;/&gt; it should refer to. || must be set<br />
|}<br />
The tag &lt;glref name="myref1" /&gt; will be replaced by the number according to &lt;glcnt name="myref1" /&gt; '''and''' this number is implemented as Hyperlink to &lt;glcnt name="myref1" /&gt; to make it possible to jump to it easily.<br />
<br />
<font color=blue>'''Further explanations:'''</font><br />
<br />
* ''prefix'' and ''suffix'' have to have set together. If you set only ''suffix'' this attribute will be ignored.<br />
* It is possible to add HTML tags to ''prefix'' and ''suffix''.<br>'''Example''': &lt;glref pre="[&amp;lt;b&amp;gt;" suf="&amp;lt;/b&amp;gt;]" /&gt; to set the number in bold face enclosed by "[]" like ['''3'''].<br>Please note that &lt; , &gt; , and &amp; must be escaped: &amp;lt; , &amp;gt; , &amp;amp;<br />
* ''name'' may only contain the following characters: '''A''' to '''Z''', '''a''' to '''z''', numbers and an '''_'''<br />
* If the ''name'' is unknown within this article an error will be printed out.<br />
* If you are editing only a section of an article and the ''name'' points outside of this section an error occurs. For editing such a case you have to edit the entire article to be sure that the reference is correct or dismiss the error and save the section if you know that the ''name'' is correct.<br />
*It is possible to use &lt;glref name="''ref_name''" before &lt;glcnt name="''ref_name''"&gt; occurs in the article.<br />
</blockquote><br />
<br />
===The tag &lt;glreset /&gt;===<br />
<blockquote><font color=blue>'''Syntax:'''</font> &lt;glreset ns="''ns''" /&gt;<br />
{| style="background-color:#EEEEEE;" cellpadding="5px"<br />
|-valign="top"<br />
| ''ns'' || ''ns'' must be a valid identifier to a used counter.<br> If not set the default identifier ''glcnt'' is taken<br />
|}<br />
<br />
This tag set the counter according to its ''ns'' to 1, or A, or a.<br />
<br />
<font color=blue>'''Further explanations:'''</font><br />
<br />
* You cannot reset a sub-counter.<br />
<br />
</blockquote><br />
<br />
==Examples==<br />
{| border=1 style="margin-left:1cm;background-color:lightyellow;border-collapse:collapse" cellpadding="5px"<br />
! Syntax !! Output<br />
|- valign="top"<br />
| width="350px" | &lt;glcnt /&gt;<br>some text<br><br>&lt;glcnt /&gt; || width="250px" | (1)<br>some text<br><br>(2)<br />
|- valign="top"<br />
| &lt;glcnt pre="" suf="]" /&gt;<br>some text<br>further text<br>&lt;glcnt /&gt;<br>additional text<br>-&lt;glcnt pre="&amp;lt;font color=red&amp;gt;{" suf="}&amp;lt;/font&amp;gt;" /&gt;<br />
| 1]<br>some text<br>further text<br>2]<br>additional text<br>-<font color=red>{3}</font><br />
|- valign="top"<br />
| See example &lt;glref name="r1" /&gt;<br><br>Example: &lt;glcnt name="r1" /&gt; ''Here my example.''<br />
| See example ([[#r1|1]])<br><br>Example: (<span id="r1">1</span>) ''Here my example.''<br />
|- valign="top"<br />
| See example &lt;glref name="r2" /&gt;<br>Example: &lt;glcnt name="first" /&gt; ''Here my first example.''<br>Example: &lt;glcnt name="r2" /&gt; ''Here my example.''<br><br>See my first example &lt;glref name="first" /&gt;<br />
| See example ([[#r2|2]])<br>Example: (<span id="first">1</span>) ''Here my first example.''<br>Example: (<span id="r2">2</span>) ''Here my example.''<br><br>See my first example ([[#first|1]])<br />
|- valign="top"<br />
| See &lt;glref name="fig1" /&gt;<br>&lt;glcnt pre="figure " suf=":" /&gt;<br>&lt;glcnt name="fig1" /&gt;<br>&lt;glcnt pre="" suf="" /&gt;<br>&lt;glcnt /&gt;<br />
| See figure [[#fig1|2]]:<br>figure 1:<br>figure <span id="fig1">2</span>:<br>3<br>figure 4<br />
|- valign="top"<br />
| &lt;glcnt name="e1" /&gt;<br><br>&lt;glcnt pre="[" suf="]" name="e2" /&gt;<br>&lt;glref name="e1" /&gt;<br>&lt;glref name="e2" /&gt;<br>&lt;glref pre="" suf="" name="e2" /&gt;<br />
| (<span id="e1">1</span>)<br><br>[<span id="e2">2</span>]<br>([[#e1|1]])<br><nowiki>[</nowiki>[[#e2|2]]<nowiki>]</nowiki><br>[[#e2|2]]<br />
|- valign="top"<br />
| &lt;glcnt /&gt;<br>&lt;glcnt /&gt;<br>&lt;glcnt ns="dia" /&gt;<br>&lt;glcnt /&gt;<br>&lt;glcnt ns="dia" /&gt;<br>&lt;glcnt /&gt;&lt;glreset /&gt;<br>&lt;glcnt /&gt;<br>&lt;glcnt type="a" ns="fig" /&gt;<br>&lt;glcnt ns="dia" /&gt;<br>&lt;glcnt ns="fig" /&gt;<br />
| (1)<br>(2)<br>(1)<br>(3)<br>(2)<br>(4)<br>(1)<br>(a)<br>(3)<br>(b)<br />
|- valign="top"<br />
| &lt;glcnt /&gt;<br>&lt;glref name="ref" /&gt;<br>&lt;glcnt /&gt;<br>&lt;glcnt name="c1" /&gt;<br>&lt;glsub of="c1" type="a" sep="-" /&gt;<br>&lt;glsub of="c1" /&gt;<br>&lt;glsub of="c1" /&gt;<br>&lt;glcnt /&gt;<br>&lt;glsub of="c1" name="sub1" /&gt;<br>&lt;glsub of="sub1" sep="" name="ref" /&gt;<br />
| (1)<br>([[#ref|3-d1]])<br>(2)<br>(3)<br>(3-a)<br>(3-b)<br>(3-c)<br>(4)<br>(3-d)<br>(<span id="ref">3-d1</span>)<br />
|- valign="top"<br />
| &lt;glcnt name="s1" /&gt; Examples:<br><br>&lt;glsub of="s1" type="_a" /&gt; only the subcounter wil be displayed<br><br>&lt;glsub of="s1" name="s2" /&gt; Here also!<br><br>See &lt;glref name="s2" /&gt; But the reference shows the complete counter.<br />
| (1) Exapmles:<br><br>(a) only the subcounter wil be displayed<br><br>(<span id="s2">b</span>) Here also!<br><br>See ([[#s2|1b]]) But the reference shows the complete counter.<br />
|}<br />
<br />
&nbsp;<br />
<br />
==Comments, Bugs, Wishes==<br />
<br />
Please don't hesitate to contact me via (bibiko[at]eva.mpg.de)<br />
if there are problems, errors, bugs, or wishes regarding to this extension.<br />
<br />
<br />
March 20<sup>th</sup>, 2007</div>Bibiko