Code block in numbered list (Wiki syntax)

In MediaWiki (wikipedia's) wiki syntax, is there a way to have a numbered list with a code block in the middle?

For example:

# Number 1
# Number 2
  Indented section that will become a code block
# Number 3
# Number 4

What happens in MediaWiki is you end up with something like this:

1. Number 1
2. Number 2
   Indented section that will become a code block
1. Number 3
2. Number 4

(Note how "Number 3" and "Number 4" are reset as 1 and 2... It looks like StackOverflow is much smarter than MediaWiki, i had to put my example in PRE tags to make it screw up!)

I know you can indent text using "#:" syntax...

# Number 1
# Number 2
#: Indented section that will merely be indented
# Number 3
# Number 4

...but I really would like to get the same visual CSS class for my code even if it's in a numbered list.

It gets even more entertaining with nested lists. This syntax...

# MainEntry 1
## Number 1
## Number 2
# MainEntry 2
## Number 1
## Number 2
  Indented section that will become a code block
## Number 3
## Number 4

...becomes...

1. MainEntry 1
   1. Number 1
   2. Number 2
2. MainEntry 2
   1. Number 1
   2. Number 2
      Indented section that will become a code block
1. 1. Number 3
   2. Number 4

(Note how "Number 3" is now "1. 1.")


Solution 1:

You could try the following wiki syntax, it works for me on 1.17

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

It is not perfect, because you end up with a more indent but it does allow one to use the wiki syntax for correctly formatted pre blocks over multiple lines.

As previously mentioned, the other proper way would be to use HTML mark up.

<ol>
<li>one</li>
<li>two</li>
<pre>some stuff
some more stuff</pre>
<li>three</li>
</ol>

Solution 2:

Use html:

<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

it will work in mediawiki.

Note from the example that I posted below, it is the </li> that makes it work properly.

Solution 3:

This works fine in MediaWiki 1.17.0:

===Alternative way of using pre in numbered lists.===    
# Numbered line 1.
# Numbered line 2.<pre>code line 1&#10;code line 2</pre>
# Numbered line 3.

The secret is to replace the newlines with the entity and write everything in one line.