Template talk:Start and end dates
Whitespace
[edit]![]() | This help request has been answered. If you need more help, you can , contact the responding user(s) directly on their user talk page, or consider visiting the Teahouse. |
Can somebody please help remove the unnecessary whitespace in this template? Example:
- (January 12, 1916 – June 6, 2018 )
Note there is a space before the closing parenthesis. AlbanGeller (talk) 22:20, 20 June 2018 (UTC)
- I'm not an expert at coding, but looking at syntax it seems sound. I even added "0" next to the 6 in the day and that seems to not helped. This might be a bug. Phearson (talk) 00:48, 21 June 2018 (UTC)
- @AlbanGeller: What an interesting puzzle!
- The template is including a hidden set of elements for the start and end dates that is not displayed. This has to be for the benefit of some other tools, or WikiData, since the reader does not see them. The extra white space appears in front of the
span style="display:none">
directive which starts the hidden elements. My conclusion is that this extra space is generated automatically by the wikimedia engine. I have spent a couple of hours trying different ideas about how to keep this space from being inserted, all to no avail. - For instance, I added a span directive with class="dtvisible" around the main part of the template and left no space between its closing tag of the first span and the opening tag of the next. In most cases, this lack of space between tags would be preserved in the generated HTML, but, no, the unwanted space was still being inserted. I saw that you had had the idea of placing HTML comments around some of the possible white-space elements, but I tried the admittedly extreme experiment of removing all whitespace from the template preceding the span directive with no better luck.
- So that leaves us with a couple of alternatives that involve using a modified version of this template.
- I've tried out both of these options and either one will give you the visible result you wanted.
- However, I'm just an amateur at template programming, so we still need to get someone more experienced to look at this problem to see if there's a better solution available than cluttering up Template: space with additional variants for special purposes. — jmcgnh(talk) (contribs) 07:16, 21 June 2018 (UTC)
- @Netoholic: Pinging the template's author. 78.28.45.127 (talk) 18:10, 21 June 2018 (UTC)
- @AlbanGeller: - the bug should be fixed now. There was a space just after the span style="display:none", replacing it with a non-breaking space now properly hides it from display when you wrap parentheses around it. Looks like this was done a while back in the {{start date}} and {{end date}} templates, and just not copied here. -- Netoholic @ 20:13, 21 June 2018 (UTC)
- @Netoholic: Sounds like I was looking in the wrong direction for the space that was appearing in front of the
<span>
. I'm still a bit mystified by the space being moved from inside to outside the span. - Also, shouldn't the symbolic version of non-breaking space be preferred over the numeric? — jmcgnh(talk) (contribs) 21:26, 21 June 2018 (UTC)
- Seems to be something about how the browser interprets <span style="display:none">. For example with a normal space
(<span style="display:none"> XX</span>)
becomes(
but with a non-breaking space )(<span style="display:none">[&]#160;XX</span>)
becomes(
. You would think both versions produce the same visual result. I usually prefer using the symbolic for readability, but chose to just keep it consistent until I know if there is some particular reason they used the numeric. -- )Netoholic @ 22:42, 21 June 2018 (UTC)- No, not the browser. The difference comes from the fact that - in the HTML as seen by the browser - the interior space is moved in front of the
<span>
, outside the range where the display:none attribute is applied. In my earlier research I came across a page that mentioned "Tidy", which exhibits this behavior of moving spaces from inside to outside, but I don't know how any of that might apply in this case. Is this tool part of the mediawiki code that generates our HTML? — jmcgnh(talk) (contribs) 02:27, 22 June 2018 (UTC)- Must be referring to this - HTML Tidy - and how mediawiki uses it mw:Parsing/Replacing Tidy/FAQ. -- Netoholic @ 03:01, 22 June 2018 (UTC)
- No, not the browser. The difference comes from the fact that - in the HTML as seen by the browser - the interior space is moved in front of the
- Seems to be something about how the browser interprets <span style="display:none">. For example with a normal space
- @Netoholic: Sounds like I was looking in the wrong direction for the space that was appearing in front of the
Confused by documentation's first paragraph
[edit]The documentation's lead paragraph:
This purpose of the {{start and end dates}} template is to return the date range during which an event transpired or an entity existed. It also includes duplicate, machine-readable date (or date-time) in the ISO date format (which is hidden by CSS), for use inside other templates (or table rows) which emit microformats. It should be used only once in each such template and never used outside such templates. The hidden date degrades gracefully when CSS is not available.
In this case, what is exactly is referred to with each such template? Am I right in assuming that this means it's best to only use this templates once per infobox, for example? What happens when it's trancluded more than once? Jay D. Easy (talk) 19:55, 10 November 2018 (UTC)
Lowercase months in Spanish
[edit]This template produces months in lowercase in Spanish, which is fine when the months are in the middle of the dates, but not when it's in the beginning, like in "enero 20, 2007". I tried to ucfirst it, but it only works on the first month, the second month is still in lowercase, as in "Enero 20, 2007 - febrero 2, 2007". Any way to go around this? Cojoilustrado (talk) 03:05, 4 November 2022 (UTC)