Template talk:Smalldiv

(Redirected from Template talk:Smalldiv/doc)
Latest comment: 2 years ago by Jonesey95 in topic Blank lines not always preserved

Make it possible to use the template inside lists

edit

@Jonesey95: I suggest using {{#if: 1 | ... }} trick instead of <nowiki /> and a newline to kill three birds with one stone, making it possible to:

  • use the template inside lists (this is, among other things, handy in discussions);
  • use the template with newlines at the beginning and end;
  • put lists inside the parameter.

Currently the template can do only the last. Here's a test page: User:Jack who built the house/Smalldiv. Jack who built the house (talk) 18:22, 16 February 2021 (UTC)Reply

I use the template with lists in the first parameter frequently, but I am open to improvements. Can you please make your recommended changes to the template's sandbox, and then add test cases to the template's testcases page? – Jonesey95 (talk) 18:50, 16 February 2021 (UTC)Reply
I see your first example, but why use {{smalldiv}} instead of {{small}} in this case? – Jonesey95 (talk) 18:56, 16 February 2021 (UTC)Reply
@Jonesey95: To get the right line spacing. See the examples at ru:Template:Block-small. Jack who built the house (talk) 00:05, 17 February 2021 (UTC)Reply
Done. Jack who built the house (talk) 00:16, 17 February 2021 (UTC)Reply
Thanks. I have marked this as a misuse of the template for now, but I am open to change that makes the template better. If you can provide a better test case that shows the benefit of the sandbox version over the existing in-line {{small}} template, please add such a case. – Jonesey95 (talk) 05:55, 17 February 2021 (UTC)Reply
Hm?
> To get the right line spacing. See the examples at ru:Template:Block-small.
I suppose a test case should be for testing, not for showing benefit.
Semantically, any text wrapped in <small>...</small> and, therefore, {{small}} is supposed to be an inline piece. If a whole paragraph or many paragraphs are supposed to be in small print, a block tag is necessary, which this template provides. Otherwise it would get wrong line spacing and probably other flaws. (Isn't this the reason why this template exists at all? Linter errors occur for a reason.) Jack who built the house (talk) 08:26, 17 February 2021 (UTC)Reply
Test cases are for showing the differences, if any, between the live template and a sandbox. I looked at the Russian template, but I was unable to see how it is relevant here, or relevant to putting a div tag after a markup bullet. I have added yet another test case showing a whole paragraph inside smalldiv and its sandbox. I don't see a difference. If you want to demonstrate the benefit of your proposed change, please do so using a test case. I am unable to read your mind. – Jonesey95 (talk) 16:05, 17 February 2021 (UTC)Reply
I can't understand why you can't see the point. The different between the {{small}} template and this template is that this template creates a block-level element. In block-level elements, the line-height CSS property is calculated relative to the font-size of the element. On the other hand, the {{small}} template creates an inline element "small". line-height for its contents is the same as its closest parent block-level element.
As a result, whenever there is a comment in a discussion or otherwise contents of a list item in the {{small}} template or <small>...</small> tags, they get a wrong line-height, which means wrong line spacing, as you can see both on the Russian template's page and on the test page in the section you created. And while for text outside of lists you can use the present template, in lists, you can't currently. Has it become clearer? Jack who built the house (talk) 16:32, 17 February 2021 (UTC)Reply
I understand what a block-level element is. It's the reason that I created this template. What I don't understand is the difference that I am supposed to see between your proposed sandbox version, if I copied it correctly, and the live version. Perhaps you could create a new test case that demonstrates the difference clearly. – Jonesey95 (talk) 21:45, 17 February 2021 (UTC)Reply
In the test case that you marked as a misuse (which I insist is not), the live version works incorrectly. The template can't be used in lists. Jack who built the house (talk) 12:46, 18 February 2021 (UTC)Reply
So the whole line height thing is not relevant? I am having trouble following you. The test case with the bullet should use {{small}}, since an in-line element is called for. Can you show a case in which {{smalldiv}} is actually needed and the live template does not work properly? Again, I am open to being persuaded, but I'm having to do all of the work here. – Jonesey95 (talk) 15:28, 18 February 2021 (UTC)Reply
@Jonesey95: > The test case with the bullet should use {{small}}, since an in-line element is called for.
This is exactly why "the whole line height thing" is relevant. If the test case with the bullet uses {{small}}, the contents get the wrong line spacing. Again, we are talking about the whole content of an item inside a list. Not a sentence in otherwise normal-sized item narration, but the whole content of an item. An alternative would be to use full-fledged
<ul>
<li style="font-size: 85%;">Content</li>
</ul>
syntax. But the reason I'm interested in this template (and why using the above syntax is not an option) is that the script Convenient Discussions used for communicating on wiki projects needs such a block-level "small" template to use for editors' comments on talk pages if they opt to wrap the whole comment's content in the <small>...</small> tag, which they often do. This way their comment would get the correct line spacing. In Russian Wikipedia, ru:Template:Block-small does the trick (for a long time already), but in English Wikipedia, no template does.
If you choose not to make the edit (although I don't see any reasons why not—after all, the change doesn't change anything for the worse), I'll just have to create a separate template for the script's needs. Jack who built the house (talk) 21:02, 21 February 2021 (UTC)Reply
Demonstration

Block-level tag, correct line spacing

  • Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?

Inline tag, incorrect line spacing

  • Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
Thank you for finally providing a test case that shows a difference between the existing code and the proposed new code. I do see a tiny difference in the line spacing that I suppose is an improvement. I am going to hope that this update will not break any of the 13,000 existing uses of the template. – Jonesey95 (talk) 21:19, 21 February 2021 (UTC)Reply
Thank you. Well, I was sure that if you've seen how text in {{small}} / {{smalldiv}} looks without a bullet, you'll be able to extrapolate. Jack who built the house (talk) 21:25, 21 February 2021 (UTC)Reply

Blank lines not always preserved

edit

When I apply {{smalldiv}} to this:

Hampshire 77 (T Brett 26; E Stevens 2w) & 49 (G Leer 15; E Stevens 3w); All-England 177 (J Miller 73, R Simmons 20; W Hogsflesh 3w, T Brett 2w).

This is the first match since cricket’s statistical record began where some bowling and fielding details are known, though no credit was given to the bowler when a batsman was out other than by being clean bowled, a convention in scoring that was not rectified until well inside the 19th century. Lumpy seems to have been the best bowler in the game, taking five wickets bowled and likely had more from catches. The All-England team was a strong Kent & Surrey combination with Joseph Miller scoring 73 in their innings of 177.

The card includes the first known instance of "hit wicket" (by John Minshull) and it is not mentioned again until 1786. It is believed that it was usually recorded as "bowled" so it is possible that, on this occasion, Minshull hit the wicket when not taking strike (e.g., hit the wicket whilst running, perhaps). This was another "first" for Minshull who scored the first known century in 1769.

I get this:

Hampshire 77 (T Brett 26; E Stevens 2w) & 49 (G Leer 15; E Stevens 3w); All-England 177 (J Miller 73, R Simmons 20; W Hogsflesh 3w, T Brett 2w).

This is the first match since cricket’s statistical record began where some bowling and fielding details are known, though no credit was given to the bowler when a batsman was out other than by being clean bowled, a convention in scoring that was not rectified until well inside the 19th century. Lumpy seems to have been the best bowler in the game, taking five wickets bowled and likely had more from catches. The All-England team was a strong Kent & Surrey combination with Joseph Miller scoring 73 in their innings of 177.

The card includes the first known instance of "hit wicket" (by John Minshull) and it is not mentioned again until 1786. It is believed that it was usually recorded as "bowled" so it is possible that, on this occasion, Minshull hit the wicket when not taking strike (e.g., hit the wicket whilst running, perhaps). This was another "first" for Minshull who scored the first known century in 1769.

which correctly reproduces the two blank lines.

But when I apply {{smalldiv}} to this:

Hampshire 132 (John Small 58, T Sueter 29) & 154 (T Sueter 32, John Small 25, W Barber 25); All-England 187 (W Palmer 52*, Childs 38, T White 24) & 100-4 (J Boorman 55, W Palmer 30*).

Coulsdon batsman Will Palmer, who had an outstanding season in 1773, scored 52* and 30* in totals of 187 and 100-4.

I get this:

Hampshire 132 (John Small 58, T Sueter 29) & 154 (T Sueter 32, John Small 25, W Barber 25); All-England 187 (W Palmer 52*, Childs 38, T White 24) & 100-4 (J Boorman 55, W Palmer 30*). Coulsdon batsman Will Palmer, who had an outstanding season in 1773, scored 52* and 30* in totals of 187 and 100-4.

which doesn't reproduce the single blank line.

Why is that? The text is taken from 1773 English cricket season, where I'm trying to fix the misnested <small>...</small> tags.

I know there are workarounds using <br /> or <p>...</p>, but the question remains, why does {{smalldiv}} behave like this? (@Jonesey95: FYI).

Bruce1eetalk 13:30, 29 October 2022 (UTC)Reply

I see the lint errors were fixed here using {{smalldiv}}, but, if you compare the tables in the original version and the repaired version, where there is only one blank line in the text, the blank line is ignored. —Bruce1eetalk 15:19, 30 October 2022 (UTC)Reply
This seems anomalous to me. I recommend simplifying this test case as much as possible, preferably without using the template (just use div tags). If you can replicate it with just a few lines of one word each, submit a bug on Phabricator. Let me know if you need help. – Jonesey95 (talk) 17:51, 1 November 2022 (UTC)Reply
@Jonesey95: Thanks for your reply. I tried replacing {{smalldiv}} with <div style="font-size:85%;">...</div> on the samples above, and oddly, I get the identical result: the two blank lines in the 3-paragraph sample are retained, but the single blank line in the 2-paragraph sample is lost. I'll play around with it some more and look at reporting the template bug on Phabricator. —Bruce1eetalk 23:30, 1 November 2022 (UTC)Reply
Looking at {{smalldiv}}'s source code, I see it also uses <div style="font-size:85%;">, so obviously the output is going to be identical! —Bruce1eetalk 06:51, 2 November 2022 (UTC)Reply
It appears that the change discussed at length in the above section may have caused this problem. See this set of test cases, in which I restored the previous version of this template to the sandbox and got the expected result. The sandbox template renders as expected. We may need to adjust this template further. Maybe Jack who built the house has an idea about how to get both their desired line spacing and our expected line break rendering to work. – Jonesey95 (talk) 14:48, 2 November 2022 (UTC)Reply