Any better way to create MediaWiki numbered lists?

▼魔方 西西 提交于 2019-12-02 19:53:55

Like this:

#Item1
#:Somestuff
#Item2
Yap Chin Hoong

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

Andrew Johnson

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>
Sam

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!

"#:" will not work with other tags like

<source lang=javascript>
//...
</source>
Adrian Archer

I'm using Mediawiki 1.13.3 and this works:

#Item1
Somestuff
<ol start="2">
<li>Item2 </li>
</ol>

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
  • 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

    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
    

    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.

    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
    标签
    易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
    该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!