Topic on Project:Support desk

Mediawiki removes whitespace between headlines

7
Kebap (talkcontribs)

Hello everybody! I noticed a strange behavior and wonder if this is intentional or no. It drives me crazy!

For example, I have a small page with a few headlines like so:

= Headline 1 =

Text for headline 1


== Headline 2 ==

Text for headline 2


== Headline 3 ==

Text for headline 3

Notice the double new line in front of each headline. This is meant to be this way, because then the headline will be much more visible. This may not be as important with headline levels 1 and 2 like in the example, but when you come down to headline level 3 and 4 they get harder to distinguish from plain bold text, so the added whitespace before each headline helps to improve readability.

OK, so this is how my mediawiki pages are structured. Now I go and edit the text for headline 2 with the neat symbol next to headline 2, which is very handy because it will only show the text for headline 2 in editor. However doing this, after saving the edited text, the whole page text source will be as follows:

= Headline 1 =

Text for headline 1


== Headline 2 ==

Edited text for headline 2

== Headline 3 ==

Text for headline 3

Notice how the double new line in front of headline 3 was replaced with just a single new line. In effect, the whitespace before headline 3 has vanished. What is more, there seems to be no way to stop this from happening, because the headline 3 was not even part of the text in the editor, so the new lines could not have been adjusted by user neither. This seems to be mediawiki deciding on its own.

The only known workaround for me is to think about never editing only text for headline 2. However that way, I need to scroll in editor, find headline 2 again, before I can start editing. This can be very cumbersome, when more text and headlines are present than in the example above. Also all editors need to think about it for every edit, otherwise this effect happens again, destroying the whitespace for all users, so it is not really viable.

Please let me know if this was intentional behavior following a conscious decision by mediawiki developers or just a minor glitch which nobody seems to have cared for just yet. Thank you and best regards

AhmadF.Cheema (talkcontribs)

Not sure if this was a conscious decision or not, but in case you didn't know, new lines can be added by specifically including the code for new lines : <br />

Clump (talkcontribs)

I would interpret it as a wikimedia error.

However, if you want spacing around your headlines, perhaps a better way than manually inserting space would be to add the required spacing through css, either as a margin or padding property; e.g.,:

.mw-body h2, .mw-body h3, .mw-body h4 {
 padding-top:1em;
}
Kebap (talkcontribs)

Thanks for mentioning CSS spacing, this may be a worthwile idea as well.

How can I report the wikimedia error for it be fixed at some point in time?

Clump (talkcontribs)

How to report a bug

Note that trailing newlines are discarded in page edits, so maybe this is intended, as a uniform application of that behaviour in section editing.

Ciencia Al Poder (talkcontribs)

If you really want to add more space before each heading, for all pages, use CSS for that so it's applied in all pages and you won't need to edit each page individually adding newlines.

This post was hidden by AlvaroMolina (history)