Block of code in a numbered list (Wiki syntax)

In the wiki syntax for wikipedia MediaWiki (wikipedia), 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, you get something like this:

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

(Note that โ€œNumber 3โ€ and โ€œNumber 4โ€ reset are 1 and 2 ... It seems that StackOverflow is much smarter than MediaWiki, I had to give my example in PRE tags to mess it up!)

I know that you can indent text using the 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 is on a numbered list.

It becomes even more interesting 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 that now the "Number 3" is "1. 1.")

+72
syntax mediawiki wiki
Feb 14 '11 at 3:50 a.m.
source share
7 answers

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

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

This is not ideal because you have more indentation, but it allows you to use the wiki syntax for properly formatted pre-blocks over multiple lines.

As mentioned earlier, another correct way would be to use an HTML label.

 <ol> <li>one</li> <li>two</li> <pre>some stuff some more stuff</pre> <li>three</li> </ol> 
+60
Dec 05 '11 at 18:39
source share

Use html:

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

he will work in mediawiki.

Please note that in the example I posted below it is </li> , which makes it work correctly.

+31
Feb 15 '11 at 20:47
source share

At the end of 2004 and 2005, your problem was due to two errors populated in the Tracker MediaWiki:

Error 1115 - A new line as a list delimiter is nasty

Error 1584 - you need a method for list items from several paragraphs, continue numbered lists and assign specific numbers to list items

After reading them, you will find a solution not to use the MediaWiki syntax, but to rely on pure HTML.

+11
Mar 02 2018-11-21T00:
source share

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 entity and write everything in one line.

+10
Oct. 21 '13 at 14:50
source share

In the above example, the second indent (: :) is not needed.

Only one indentation works fine (:) as follows:

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

It produces:

1. one
    some stuff (just one indent level, not two)
    some more stuff 
2. two
+1
Apr 30 '13 at 23:02
source share

I offer a different answer: do not do this.

I tried using all the workarounds for this basic Mediawiki issue and found that they are all very imperfect. I learned to live without numbers, but instead:

  • Use splat (*) instead of (#) for all my lists
  • Keep using master space for all my code blocks

This is much simpler and more convenient than any workaround. In addition, the use of any number reference can be changed as the steps are edited - and this becomes another maintenance problem.

+1
Oct 25 '16 at 18:54
source share

You can also try adding the "blockquote" tag surrounding the "pre" tag so that it looks a little more polished.

 == HAProxy Configuration == #'''File:''' /etc/haproxy/haproxy.cfg <blockquote> <pre> global log 127.0.0.1 local1 notice maxconn 4096 #daemon debug crt-base /usr/local/haproxy/ssl </blockquote> </pre> 

This will cause the gray square to match your make / number without using a colon.

-2
Jan 16 '14 at 0:25
source share



All Articles