Search code examples
phphtmlcssmediawikiwiki

<noinclude>category:example</noinclude> in template, undesirably wraps content in <pre> tag


In MediaWiki 1.32.0 in Hebrew, if one creates a template named רקע_אפור ("Grey background") with the following content:

<span style="background: grey">{{{1}}}</span>
<noinclude>[[קטגוריה:דוגמה]]</noinclude>

Having <noinclude> before [[קטגוריה:דוגמה]], makes passages containing the template call to be wrapped inside a <pre> tag with a line break; for example:

Current state

Code

מופע_1 {{תבנית:רקע_אפור|מופע_2}} מופע_3

Output

מופע_1

מופע_2

מופע_3

Desired state

Code

מופע_1 {{תבנית:רקע_אפור|מופע_2}} מופע_3

Output

מופע_1 מופע_2 מופע_3

Why is the <pre> tag and line break get created happening and how to prevent this?


Solution

  • Try

    <span style="background: grey">{{{1}}}</span><noinclude>
    [[קטגוריה:דוגמה]]
    </noinclude>
    

    The problem is that in your original code, there's a newline after </span>, so:

    מופע_1 {{תבנית:רקע_אפור|מופע_2}} מופע_3
    

    is expanded to:

    מופע_1 <span style="background: grey">מופע_2</span>
     מופע_3
    

    which causes the pre to happen.