Jump to content

Template talk:Start and end dates

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 78.28.45.127 (talk) at 18:10, 21 June 2018 (→‎Whitespace). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Whitespace

Can somebody please help remove the unnecessary whitespace in this template? Example:

  • (January 12, 1916 – June 6, 2018 (1916-01-12 – 2018-06-06))

Note there is a space before the closing parenthesis. AlbanGeller (talk) 22:20, 20 June 2018 (UTC)[reply]

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)[reply]
@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.
  1. leave out the microdata part entirely – here
  2. insert your own parens around the visible part, leaving the microdata part and its leading space intact – here
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)[reply]