45

When using MediaWiki's markup language, the only thing that I hate is creating numbered lists. The only way I know to create a list is to do something like this:

#Item1
#Item2

However, if I want to add spaces or some other text between those lines, the numbering gets lost. For example, the following will create text that has two number one items:

#Item1
Somestuff
#Item2

Is there any way around this, or should I just use bullet points instead? I noticed just now that the stackoverflow system does not allow numbering like this, you have to do it all manually.

11 Answers11

30

Like this:

#Item1
#:Somestuff
#Item2
finnw
  • 47,861
  • 24
  • 143
  • 221
  • I am having the same problem when "Somestuff" uses PRE tags. – Xonatron Dec 06 '11 at 13:32
  • @sw. put the pre at the end of the previous list element and use for line breaks. source: http://dansesacrale.wordpress.com/2010/07/14/mediawiki-multi-line-pre-within-list/ – Gerry Dec 31 '13 at 02:54
  • Don't use newlines in `Somestuff`. Continue writing after Item1 (you *can* use `
    because that's not a newline in the page source) (In my case, I didn't even need `#`:` )
    – Mark Jeronimus May 24 '16 at 13:17
18

I use <ol></ol> and <li></li> to embed the <pre></pre> code formatting portions. Works great for me! :-)

alomeli
  • 49
  • 9
Yap Chin Hoong
  • 181
  • 1
  • 2
12

There are a couple of options, but you can start an ordered list from an arbitrary number like this:

#Item1

Something

<ol start="2">
#Item2
</ol>

You can also use "#:" if you don't mind "Something" being indented a lot:

#Item1
#:
#: Something
#:
#Item2

There are quite a lot of options with lists, you can find more info on Wiki's Help Pages:List.

update

Newer version work more like regular html markup the old syntax will now give you a double indent and will not adjust the start offset, but the following works well, even with the source/syntaxhighlight tag.

<ol>
<li>Item1</li>
Something
</ol>

<ol start="2">
<li>Item2</li&gt
<source lang=javascript>
var a = 1;
</source>
</ol>

In short everything within the ol tag will have the same indentation and will not be numbered if it is outside a li tag. The following will now work and it mean you don't have to offset groups manually.

<ol>
<li>Item1</li>
Something
<li>Item2</li&gt
<source lang=javascript>
var a = 1;
</source>
</ol>
Digital Fu
  • 2,877
  • 1
  • 14
  • 20
Andrew Johnson
  • 7,277
  • 4
  • 23
  • 27
6

The #: works, but you cannot create a section with spaces, so I would prefer the non-working option. Anyone knows a similar syntaxis that does the trick (start numbering at given value)?

This response is probably a bit late, but I figure I'll add it in case anyone stumbles across this, as I have. You can create a section with spaces by doing something like:

# Item 1
#: 
#: 
# Item 2

This will appear as:

  1. Item 1

  2. Item 2

Now, before you say this doesn't work, the trick is to add an ASCII no-break space after the #: rather than just simply hitting spacebar. You can add this by holding ALT on your keyboard and typing 0160. Doing this should add the usual Wiki paragraph formatting while preserving your numbering between #s.

Hope that helps!

OrangeDog
  • 36,653
  • 12
  • 122
  • 207
Sam
  • 61
  • 1
  • 1
  • 1
    The 'ALT + Unicode-character-number' trick only (?) works on Windows; at least it doesn't work on some versions of Mac OS X. – Kenny Evitt Jun 12 '13 at 16:16
  • 3
    Use " " without the quotes. Visible (in the editor) too, so a little less magic for the next person. – Peter Sep 25 '13 at 06:01
2

And for cases where you want to have some block text within your numbered wiki list try this

# one
#:<pre>
#:some stuff
#:some more stuff</pre>
# two

Which produces:

  • 1. one
       some stuff
       some more stuff
  • 2. two
  • Kory Lovre
    • 146
    • 5
    2

    "#:" will not work with other tags like

    <source lang=javascript>
    //...
    </source>
    
    Leon
    • 2,810
    • 5
    • 21
    • 32
    2

    I'm using Mediawiki 1.13.3 and this works:

    #Item1
    Somestuff
    <ol start="2">
    <li>Item2 </li>
    </ol>
    
    Community
    • 1
    • 1
    Adrian Archer
    • 2,323
    • 1
    • 17
    • 20
    1

    From the Wiki Help Page I was able to get the numbering in a list to stay consitant using <p> and <pre>:

    # Item 1
    # Item 2 <p><pre>Item 2 Pre Stuff</pre></p>
    # Item 3
    

    Would generate

    1. Item 1
    2. Item 2
       [ Item 2 Pre Stuff ]
    3. Item 3
    
    Dirk
    • 3,030
    • 1
    • 34
    • 40
    1

    You can do:

    # one
    # two<br />spanning more lines<br />doesn't break numbering
    # three
    ## three point one
    ## three point two
    

    Regular old <br> works as well but probably pisses off someone.

    You can put additional HTML formatting in as well to do <pre> formatting and the like without breaking the numbering as well. This also works other list formats.

    From: http://www.mediawiki.org/wiki/Help:Formatting

    edit: Also found that inside a <pre></pre> many of my old tricks don't work, but using &#10; works as a newline, and allows multi-line blocks. The cost is that you jam all your lines on one line.

    # one
    #: <pre>foo&#10;bar</pre>
    
    josefwells
    • 67
    • 5
    1

    Following the link to Wiki Help, I found an example that meets what I think are the implied requirements

    1. The list needs to keep numbering
    2. Sometimes the "Somestuff" should be on it's own line in the source

    To get (1) there are a few solutions proposed. Bug one way is to use paragraph delimiters around the extra "somestuff".

    Example 1:

    # Paragraph 1.<p>Paragraph 2.</p><p>Paragraph 3.</p>
    # Second item.
    

    To meet (2), you use paragraph marking in combination with commenting out the new lines (with <!-- newline-->).

    Example 2:

    # Paragraph 1.&lt!--
      --><p>Paragraph 2.</p><!--
      --><p>Paragraph 3.</p>
    # Second item.
    

    Both examples display as

    Result:

    
        1. Paragraph 1.
           Paragraph 2.
           Paragraph 3.
        2. Second item
    

    Note that the comment eats all of the white space between the end of one element and the start of the next, which seems to be standard practice, and makes sense if you're trying to have whitespace without the "wiki effects" of the white space.

    Peter
    • 971
    • 8
    • 15
    1

    Extension:ComplexList

    https://www.mediawiki.org/w/index.php?oldid=2126533

    was put together but not maintained (for lack of time). It works with 1.26.2 of MediaWiki.

    For example.

    <cl>
    1. list item A1
    
    * list item A2
    
    continuing list item A2
    
    further continuing list item A2
    
    * list item A3
    </cl>

    becomes

    1. list item A1
    2. list item A2
      continuing list item A2
      further continuing list item A2
    3. list item A3
    user1930469
    • 324
    • 1
    • 2
    • 7