7

How can I create a numbered list containing multi line pre, source or code tags without breaking the list?

That is what I have been trying:

# First
# Second <source lang="CSharp">Some
Multi
Line C Sharp
Code </source>
# Trid

It results in something like:

Broken numbered list

3

The other answer is incorrect. This can be done using the line option:

# First
# Second <source line lang="CSharp">Some
Multi
Line C Sharp
Code </source>
# Third

Look, the output is correct: https://www.mediawiki.org/w/index.php?title=Project:Sandbox&oldid=1915324

  • Thanks a lot! It really helps me to make my wiki a lot better! – Matthias Jost Oct 15 '15 at 7:31
1

I don't think that can be done with pure wiki markup. From the lists help page on mediawiki.org:

For simplicity, list items in wiki markup cannot be longer than a paragraph. A following blank line will end the list and reset the counter on ordered lists. Separating unordered list items usually has no noticeable effects.

Paragraphs can be forced in lists by using HTML tags. Two line break symbols, <br /><br />, will create the desired effect. So will enclosing all but the first paragraph with <p>...</p>

This works for normal paragraphs, but not for multiline code blocks because they need actual newlines.

However, MediaWiki does support some HTML tags, including <ol> and <ul>, so you can obtain the desired affect using HTML markup, like so:

<ol>
  <li>First</li>
  <li>Second
<source lang="CSharp">Some
Multi
Line C Sharp
Code
</source></li>
  <li>Third</li>
</ol>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.