Template talk:Warning

From ArchWiki
Jump to: navigation, search

There's something wrong with multi-paragraph Warning templates

When multiple paragraphs are used inside this template, and the template end symbol (}}) is on a new line, it produces additional space below the warning template, which makes it look ugly.

If template end symbol is placed at the end of the line of the last template, then the paragraphs are "glued" together, which is no good either.

Demonstration 0 (regular, 1-paragraph template):

Warning: Just one paragraph.

Demonstration 1 (on new line):

{{Warning|This is paragraph 1.

This is paragraph 2 (note the slight space below this sentence).
}}

produces:

Warning: This is paragraph 1.

This is paragraph 2 (note the slight space below this sentence).

Demonstration 2 (on same line):

{{Warning|This is paragraph 1.

This is paragraph 2 (This should be on a new line!!!!!!).}}

produces:

Warning: This is paragraph 1. This is paragraph 2 (This should be on a new line!!!!!!).

This might be a problem with similar templates as well (Note, Tip). axper (talk) 05:40, 13 July 2014 (UTC)

As far as I understand the parser, this behaviour is just fine. The is that paragraphs appear to be defined with the ending newline included (see for example mw:Markup_spec/BNF/Article#Article, it might not be entirely correct/up-to-date, but it's the best I found). Now this is not a problem for regular paragraphs, since they are separated with a blank line (what a coincidence) and as you might have noticed, each article ends with a blank line.
When it comes to templates, only the text between | and }} tokens is passed to the parser. Apparently the newline has to be included by the editor if he intends to make a paragraph.
Also, use the "Inspect element" feature of the browser (Firefox and all webkit-based browsers surely have it) and see what the HTML looks like. You will notice that in your 0-th example, the text is technically not a paragraph, there are no <p> tags in the warning box. On the other hand, your 1-st example includes a paragraph inside <p> tags, which are assigned a margin by the CSS (0.4em top, 0.5em bottom), hence the additional space. The "ugly" look is caused by the inconsistency between the first and second paragraphs, only one of them uses <p> tags. To use the <p> tags even for the first paragraph (see the source, I don't want to write it twice):
Warning:

First paragraph.

Second paragraph.

This particular syntax looks much better IMO, and it has been in my to-do list for quite some time, so thanks for bringing up the issue. I'd like to include this example into Help:Editing as a way to avoid using <br> tags inside the note templates.
-- Lahwaacz (talk) 10:30, 13 July 2014 (UTC)
I like that syntax too, maybe it could go in Help:Editing#Line breaks or in Help:Template#Usage. -- Kynikos (talk) 03:27, 14 July 2014 (UTC)
I am not a huge fan of Lahwaacz's syntax, it doesn't look consistent near regular 1-paragraph warning templates, sorry :)
The mention about putting }} on a new line (for multi-paragraph templates only??) would be nice in Help:Template#Usage. axper (talk) 15:34, 14 July 2014 (UTC)
So you're saying that something like:
Note: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin egestas, magna non sollicitudin commodo, sapien elit semper sapien, adipiscing consectetur nisi ipsum ut elit. Sed ac neque ut nulla tempor porttitor. Mauris interdum. Cras feugiat sodales nibh. Proin neque turpis..
Warning:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin egestas, magna non sollicitudin commodo, sapien elit semper sapien, adipiscing consectetur nisi ipsum ut elit. Sed ac neque ut nulla tempor porttitor. Mauris interdum. Cras feugiat sodales nibh. Proin neque turpis..

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin egestas, magna non sollicitudin commodo, sapien elit semper sapien, adipiscing consectetur nisi ipsum ut elit. Sed ac neque ut nulla tempor porttitor. Mauris interdum. Cras feugiat sodales nibh. Proin neque turpis..

...is worse than:
Note: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin egestas, magna non sollicitudin commodo, sapien elit semper sapien, adipiscing consectetur nisi ipsum ut elit. Sed ac neque ut nulla tempor porttitor. Mauris interdum. Cras feugiat sodales nibh. Proin neque turpis..
Warning: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin egestas, magna non sollicitudin commodo, sapien elit semper sapien, adipiscing consectetur nisi ipsum ut elit. Sed ac neque ut nulla tempor porttitor. Mauris interdum. Cras feugiat sodales nibh. Proin neque turpis..

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin egestas, magna non sollicitudin commodo, sapien elit semper sapien, adipiscing consectetur nisi ipsum ut elit. Sed ac neque ut nulla tempor porttitor. Mauris interdum. Cras feugiat sodales nibh. Proin neque turpis..

I can't say that I disagree completely, although I don't mind the first version either... Maybe the appearance of these templates depends too much on the context, or on the length of the first paragraph, or the number of paragraphs, to be regulated in general.
Quoting Lahwaacz, however, "[...] include this example into Help:Editing as a way to avoid using <br> tags [...]", it looks like he didn't mean to make it a general style rule in the first place (but correct me if I'm wrong).
-- Kynikos (talk) 15:34, 15 July 2014 (UTC)
I'm ok with Lahwaacz's style being in Help:Editing. I just don't think it or your second example are perfect. The perfect solution I think would be some CSS mods to remove bottom margin from paragraphs which are inside warnings/notes/tips. It would look something like this:
Note: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin egestas, magna non sollicitudin commodo, sapien elit semper sapien, adipiscing consectetur nisi ipsum ut elit. Sed ac neque ut nulla tempor porttitor. Mauris interdum. Cras feugiat sodales nibh. Proin neque turpis..
Warning: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin egestas, magna non sollicitudin commodo, sapien elit semper sapien, adipiscing consectetur nisi ipsum ut elit. Sed ac neque ut nulla tempor porttitor. Mauris interdum. Cras feugiat sodales nibh. Proin neque turpis..

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin egestas, magna non sollicitudin commodo, sapien elit semper sapien, adipiscing consectetur nisi ipsum ut elit. Sed ac neque ut nulla tempor porttitor. Mauris interdum. Cras feugiat sodales nibh. Proin neque turpis..

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin egestas, magna non sollicitudin commodo, sapien elit semper sapien, adipiscing consectetur nisi ipsum ut elit. Sed ac neque ut nulla tempor porttitor. Mauris interdum. Cras feugiat sodales nibh. Proin neque turpis..
(obviously with 2 paragraphs instead of three and with less space between 2 paragraphs).
If such CSS hackery (or some other tricks like parser mods??) are not possible at this time, then yeah let's go with Lahwaacz's style. axper (talk) 15:48, 15 July 2014 (UTC)
I see - the issue with inconsistency with the space at the bottom occurs only when there are exactly two paragraphs, which is the only case when the last paragraph is enclosed in <p> tags (and the }} token is not preceded by newline). I find this rather odd, I'll investigate further when I have some free time.
Regarding CSS, dealing with the inconsistent <p> tags would be pretty hard/hackish and would have to be done in the backend's arch.css. Eventually, a patch would have to be submitted to the bug tracker, and its acceptance would certainly take some time.
@Kynikos: Yes, I meant it as a mere example, enforcing such technicality would not be useful at all, perhaps even ridiculous.
-- Lahwaacz (talk) 20:22, 15 July 2014 (UTC)
No I didn't explain it properly - the <p> tag(s) will NOT be generated only in the following cases:
  1. the paragraph is on the same line as the the starting token ({{), for example:
    {{Note|This won't be paragraph'd. ...
  2. the paragraph ends with the ending token (}}); in other words if the paragraph is the last paragraph and it's not separated from ending token with a newline:
    ... This won't be paragraph'd too.}}
In all other cases a <p> is generated. Hope this helps.
axper (talk) 15:52, 16 July 2014 (UTC)
Sorry, I'm a bit lost, where do we want to get exactly here? I exclude an ad-hoc css rule for this, we must keep it simple, and <p> elements need margins in the body, so they'll have margins also wherever else they're found; the style sheets are already messy enough, we should try to simplify them instead of adding rules (see for example FS#38769). Do we want to regulate the use of "}}" and recommend not to put it on a new line? It seems a bit exaggerated to me, but we can still put it to the vote in e.g. Help:Style and then fix Help:Style/White space, which is now contradicting that. In short, let's come to a decision or let's close this :) -- Kynikos (talk) 10:14, 17 July 2014 (UTC)