Jump to content

Topic on Project:Support desk

Excess paragraphs (<p>) on pages

9
Mukilol (talkcontribs)

Hey! I have had issues with excess paragraphs on my wiki for months. Initially I tried to solve it with CSS but was unable to do so due to how random the content structure can be and thought about asking for help here instead.

We have a template called {{skill}} on our wiki which returns a hoverable image and text inside a div which is set to display: inline-block. Whenever this template is called, any text before and after it gets wrapped in paragraph tags which results in a minimum of 3 rows when it should be 1. This was not always the case and was probably introduced with an upgrade but I can't say for sure.

As a hacky workaround for this we are currently placing all content in lists where the {{skill}} template is used, this prevents the excess paragraphs and makes everything inline.

Has anyone experienced anything like this or knows what could be causing it?

AhmadF.Cheema (talkcontribs)

The {{skill}} template, does it have extra newlines in its beginning or end?

Mukilol (talkcontribs)

The includeonly within that template has no newlines, the noinclude has a few though.

AhmadF.Cheema (talkcontribs)

Are there any between the includeonly and noinclude tags?

Note that even starting the noinclude tags on the next line might cause the template to render with extra newlines. It's better to type the opening noinclude tag on the same line, directly after the previous closing includeonly tag.

<includeonly>
Foo
</includeonly>
<noinclude>
Bar
</noinclude>
Mukilol (talkcontribs)

They are at the same line right now, there are no spaces/newlines at the start, end or between. Would it help if I post a link to the template here? Not sure if it's allowed.

Ciencia Al Poder (talkcontribs)

Yes, please, a link would help

Mukilol (talkcontribs)

I managed to fix the problem which was that the content inside {{skill}} was within a div and MediaWiki decided that everything before and after that should be in separate paragraphs. I changed from div to span and it worked. I initially had display:inline-block on the div but that didn't make any difference.

Ciencia Al Poder (talkcontribs)

This usually happens when you have several div on separate lines:

<div>something</div>
<div>something</div>
<div>something</div>

And can be solved by removing the line break between div:

<div>something</div><div>something</div><div>something</div>

or:

<div>something</div><!--
--><div>something</div><!--
--><div>something</div>
77.10.98.82 (talkcontribs)

Had the exact same issue, replacing div with span worked, thanks!

And the template did not have a single line break in it, it's just a single line, so that is most definitely not the issue, mediawiki for some reason just seems to wrap everything before and after a div in paragraphs.

Reply to "Excess paragraphs (<p>) on pages"