Hilfe:Sort2
Aus Tastenwiki
This page describes the usage of the mediawiki extension Sort2.
Inhaltsverzeichnis |
[bearbeiten] Purpose
The purpose of this extension is to sort lists.
[bearbeiten] Features
- Sorts ul,ol,dl and br (linebreaked) lists
- Sorts case sensitive or case insensitive
- A title can be added to precede the list (V1.1)
- Unordered, ordered and definition lists can have a style sheet (V1.1)
- Ordered lists can have a starting number (V1.1)
- Has 5 different output modes
- Wiki syntax inside the list remains untouched
- Can convert list types to each other
- Even though of a rather small importance, it can also sort whole paragraphs based on their first character
[bearbeiten] General usage
You just need to surround the list you want to sort or convert by the tags. That's all there is and your list get sorted as ul, ascending, case insensitive.
Rob's original version did not strip the wiki syntax list tokens *,#, and : so you could not sort already existing lists without removing the tokens. I found this too awful. Sorry Rob ;).
As a side effect you can now convert lists from one type to another or easily convert some paragraphs to a list of your choice.
[bearbeiten] Syntax
The syntax of this extension is pretty easy and intuitive as it resembles the usage you know from HTML already.
<sort2 [type=""] [order=""] [casesense=""] [separator=""] [style=""] [start=""] [title=""]> ... any text ... </sort2>
[bearbeiten] Options
All options are optional, default values are rendered bold below. Bold and teletype is hard to read - at least on my system - so defaults are also always the first in the list.
- type=""
- The option type takes a string as argument. It can be one of:
- ul, list is generated as unordered list
- ol, list is generated as ordered list
- dl, list is generated as definition list
- br, list is generated as separate lines
- inline, list is generated as one item after the other separated by separator (see below)
- Note: This option was named class in the original version but I found this too confusing because class normaly is used for a style sheet class.
- order=""
- The option order takes a string as argument. It can be one of:
- asc, sorting direction is ascending
- desc, sorting direction is descending
- none, no sorting of the list. This one is useful for converting list types. For instance some paragraphs to an unordered list without changing order.
- casesense=""
- The option casesense takes a string as argument. It can be one of:
- false, sorting is case insensitive. Uses php natcasesort()
- true, sorting is case sensitive. Uses php natsort()
- separator=""
- The option separator takes a string as argument. It is only evaluated when type is set to inline. The list items are separated by the char(s) you give as argument to this option. Since the parser eats spaces using php trim(), I had to introduce a pseudo-entity to be able to render separators like ", " or " | ". If you want a space at the end or beginning of the separator, you have to use &sp;.
- Examples:
- separator=",&sp;"
- separator="&sp;|&sp;"
- Note: You can not pass HTML or wikisyntax as an argument. Just in case you wonder why there is this extra type="br" option.
- style=""
- The option style takes a string as argument. It is only evaluated when type is set to ul, ol, or dl. Its main purpose is to be able to control what kind of numbered list you are generating and having control over the margins. If you want to change the list-style-type and do this by setting list-style to none , also set list-style-image to none, since there's a default image set - at least with the Monobook skin. If you don't set this explicitly, Firefox will happily omit the list bullet but IE will still display the image.
- Since this can have a large impact on layout, administrators can switch off that behaviour by setting $wgSort2AllowStyles = false in LocalSettings.php.
- start=""
- The option start takes an integer as argument. It is only evaluated when type is set to ol and controls the starting number of the ordered list.
- title=""
- The option title takes a string as argument. It is prepended to all list types and can hold wikisyntax. A space at the beginning or end must be entered as the pseudo-entity &sp;.
[bearbeiten] Examples
| The code | Results in |
<sort2> *2 *1 *ball *AMD *BMW *argument </sort2> |
|
<sort2 casesense="true"> #2 #1 #ball #AMD #BMW #argument </sort2> |
|
<sort2 type="inline" separator="&sp;|&sp;" title="A list:&sp;"> 2 1 ball AMD BMW argument </sort2> |
A list: 1 | 2 | AMD | argument | ball | BMW |
<sort2 type="ol"> This is sample paragraph And this is another one Yet another one. </sort2> |
|
I am sure you get the idea.
[bearbeiten] Restrictions
- The extension does not sense the original type of the list. So ol gets converted to a ul if you don't set the type accordingly
- The extension eliminates identical items
- The extension does not work with lists which have sub levels. Something like the following does not work correctly.
<sort> * Item 1 ** Subitem * Item 2 ** Subitem </sort>
This would mess up the order because of the two stars and also eliminate one of the subitems.

