Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.")

like image 973
inanutshellus Avatar asked Feb 14 '11 15:02

inanutshellus


People also ask

How do I insert a code block in Wikipedia?

The TechNet Wiki Editor has a Format Code Block option ( ). Click it, insert some code, select a language, click Preview to see it, tweak the code, and then click OK. The source code is now formatted and into your article!

How do you show code on Wikipedia?

When you go into the editing view of a wiki page, on the right hand side you will see a plus sign. Clicking on it will provide a short list of formatting codes as a help. You can edit this and custom design it for your worksite.

How do you continue numbering in Wikipedia?

I have a numbered list and have to include images in each step. So I want to continure the numbering in the list. How can i do this? If they're in a sequence, you can use the # sign at the beginning of each paragraph.


1 Answers

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> 
like image 52
Kyle Avatar answered Sep 28 '22 02:09

Kyle