meetar
meetar

Reputation: 7611

How can I force MediaWiki to respect single line breaks?

By default, MediaWiki ignores single line breaks, treating them as a single space. To insert a new line in a page, you must insert two consecutive line breaks in the source, which results in a new paragraph: </p><p>. It's also possible to insert <br /> directly into the source.

How can I get MediaWiki (control its parsing engine) to convert single line breaks in the source to <br /> elements in the resulting HTML?

(Source: http://www.mediawiki.org/wiki/Help:Formatting)

Upvotes: 9

Views: 13777

Answers (3)

Ryan
Ryan

Reputation: 76

<pre></pre>

This html tag seems to do the job for me.

Upvotes: 4

MaxSem
MaxSem

Reputation: 3547

Use https://www.mediawiki.org/wiki/Extension:Poem

<poem>
Roses are red
Violets are blue
</poem>

Upvotes: 5

Jobj&#246;rn Folkesson
Jobj&#246;rn Folkesson

Reputation: 569

You could write an extension that adds br tags to newlines when parsing the wikicode. However, you'd have to be very careful - you don't want every newline in the wikicode to actually be a br tag, do you?

Edit: you don't want every newline to be a br tag, because not every newline in the wikicode should actually be a linebreak. For example, a table:

{|
|+ The table's caption
|-
|Cell 1
|Cell 2
|-
|Cell A
|Cell B
|}

It would turn quite messy if you added br tags into the table code.

Upvotes: 2

Related Questions