Jump to content

Template talk:Prime

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
(Redirected from Template talk:Prime/doc)

Proposed revision, copied from deletion discussion

[edit]

The original can be found at Wikipedia:Templates for discussion/Log/2016 November 7#Template:′, but is copied here for reference, as it's now being wored on. 71.41.210.146 (talk) 16:00, 17 November 2016 (UTC)[reply]

  • Keep per above. I'm wondering if it won't be neater to have the template accept an argument, for example {{prime|f}} for f. That way the spacing could be adjusted according to the preceding character. – Uanfala (talk) 20:13, 8 November 2016 (UTC)[reply]
@Uanfala: H'mm... that's more ambitious than I was planning (I was considering allowing an explicit spacing specification), but not a horrible idea. Since the number of possible spacings is small (characters are go into groups which share the spacing), I could take the last character with {{#invoke:String|pos|argument|-1}}, and then look it up in an if-chain with {{#invoke:String|find|abcde|letter}}. We could at least cover the standard Latin and Greek alphabets.
The big problem is that the correct spacing is font-dependent, and I don't know the user's display fonts, so it's all a guess. But I don't think a rough guess is making it worse. (I spent a while playing with Unicode zero-width characters to see if there existed one that would get the kerning right, but no joy.)
So I'm thinking the following: {{prime|prefix|as-if|sp=0.1em}} The prefix parameter {{{1}}} is displayed, but the spacing is derived from the as-if parameter {{{2}}}, which defaults to the last character of the prefix, but may be given separately if trailing markup in the prefix would confuse things. (Doing it this way allows a double pipe {{prime|as-if}} to compactly ask for no displayed prefix.) {{{sp}}} gives an explicit spacing that overrides all of the preceding.
I'd do it with one sub-template: a {{′/calc_space|as-if}} which does the computation and returns the spacing. The parent template would invoke it if {{{sp}}} isn't given... {{{1|}}}<span class="nowrap" style="padding-left:{{{sp|{{′/calc_space|{{{2|{{#invoke:String|pos|{{{1|f}}}|-1}}}}}}}}}};">′</span> The default to 'f' provides maximum space if unspecified.
Does that seem like a reasonable plan? 71.41.210.146 (talk) 11:48, 9 November 2016 (UTC)[reply]
Second thoughts: Probably the calculation template should not be here, but a sub-template of Template:italics correction. Maybe Template:Italics correction/calc? Then both templates can use it. 71.41.210.146 (talk) 12:04, 9 November 2016 (UTC)[reply]
I have almost no knowledge of typography so I'm afraid I won't be of much use. But yes, that sounds like a good idea. – Uanfala (talk) 14:36, 9 November 2016 (UTC)[reply]
@Uanfala: It wasn't the typography I was asking about, but the Wikipedia template design & implementation. Are those good parameters? Does that seem like a reasonably efficient implementation? And should I start work now, or wait for this TfD wraps up? 71.41.210.146 (talk) 16:02, 9 November 2016 (UTC)[reply]
I don't know much about templates either, but the parameters look usable enough, and it's sensible to have the calculation done in one place where it can be used by multiple templates. As for efficiency, if you have experience of lua, it'll be better to do it with a module. If not, it's OK – I don't think computational efficiency should be much of an issue. – Uanfala (talk) 16:10, 9 November 2016 (UTC)[reply]

(FTR, this has since been implemented. -- Beland (talk) 19:17, 3 February 2023 (UTC))[reply]