Module talk:Footnotes

This is an old revision of this page, as edited by Trappist the monk (talk | contribs) at 11:14, 22 June 2018 (Logic error in handling of "n.d."). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Latest comment: 7 years ago by Trappist the monk in topic Logic error in handling of "n.d."

This doesn't work properly in Template:Sfn

Please see Template talk:Sfn#Lua version is broken. --Redrose64 (talk) 22:43, 2 April 2013 (UTC)Reply

Broken parameter

Please see Template talk:Harvard citation no brackets#Broken parameter. Similar templates are probably similarly broken. Wtmitchell (talk) (earlier Boracay Bill) 07:13, 28 April 2013 (UTC)Reply

This should be fixed. Dragons flight (talk) 10:18, 28 April 2013 (UTC)Reply

More than six parameters

It would help if the code was more compatible with CS1. At the moment it does not handle more than four authors elegantly. See Module talk:Citation/CS1#CITEREF and harvnb and CITEREF and CS1. -- PBS (talk) 13:09, 21 December 2013 (UTC)Reply

Markup

The Lua CS1 templates strip markup, such as bold or italics, where this module does not. Thus if markup is used in {{sfn}} or variant, then the link and anchor will not match. --  Gadget850 talk 11:28, 6 March 2014 (UTC)Reply

Protected edit request on 27 June 2014

Module:Citation/CS1 runs mw.uri.anchorEncode() on options.id before generating the <span id="... line. For compatibility between generated id in that module and the #CITEREF generated here, I think this change needs to be applied on this module.">

(Here is an example footnote which is not linked to it's citation and I think it's because of the above mentioned problem.) Dalba 07:38, 27 June 2014 (UTC)Reply

  Done Thanks for the fix! — Mr. Stradivarius ♪ talk ♪ 12:15, 27 June 2014 (UTC)Reply

Template:sfnp

{{sfnp}} could usefully be implemented within this module as well as {{sfn}}. As far as I can see, function f.sfnp( frame ) would simply duplicate function f.sfn( frame ) with the addition of:

args.bracket_year_left = "(";
args.bracket_year_right = ")";

An oddity at present is that |postscript=none works for {{sfn}} but not for {{sfnp}}. Peter coxhead (talk) 20:21, 15 December 2014 (UTC)Reply

It does in a sort of round-about way:
{{sfnp}} calls {{Harvard citation/core}} calls Module:Footnotes function harvard_core().
Is |postscript=none necessary for {{sfnp}}? The code seems to indicate that {{sfn}} uses '.' for a default of postscript character. If |postscript= is empty or omitted, then {{sfnp}} uses an empty string as the default postscript.
Trappist the monk (talk) 20:38, 15 December 2014 (UTC)Reply
Nope, {{sfnp|James|2004}} generates the following footnote.[1]
(After the tweak noted below, {{sfnp|Smith|2005|ps=none}} generates the following footnote.[2])

References

  1. ^ James (2004).
  2. ^ Smith (2005)
So as a CS2 user, I end up with {{sfnp|ps=|...}} but would prefer |ps=none for same reason as you (well, actually I'd prefer another template, and did once create one, but the consensus was to delete it).
Doing things in a "round-about way" is a sure recipe for software errors (at least that's what I used to teach in first-year software engineering). The complexity of the current code is shown by the fact that it isn't easy to work out what {{sfnp}} actually does. A separate function is clearer and easier to maintain. Or perhaps better still (because more modular), pass appropriate parameters to f.sfn(). Peter coxhead (talk) 21:13, 15 December 2014 (UTC)Reply
Right, it gets it's postscript from the template call to {{Harvard citation/core}}. Module:Footnotes tweaked and I tweaked your example.
You'll get no argument from me in support of round-about code. Every line must be maintained. I'll think about integrating {{sfnp}} in the module.
Trappist the monk (talk) 22:02, 15 December 2014 (UTC)Reply
Ok, tweaked {{sfnp/sandbox}} to pass the bracket defaults as |bracket_year_left=( and |bracket_year_right=) to f.sfn() in Module:Footnotes/sandbox where those parameters override the defaults normally used by {{sfn}}:
Some text using {{sfnp}}.[1]
Some text using {{sfnp/sandbox}}.[2]
Some text using {{sfnp/sandbox|ps=none}}.[3]

References

  1. ^ Smith (2005)
  2. ^ Smith & Jones (2005).
  3. ^ Smith, Jones & Babcock (2005)
Trappist the monk (talk) 13:08, 16 December 2014 (UTC)Reply
A much more elegant approach than the current version; hopefully soon to be deployed. Peter coxhead (talk) 18:56, 16 December 2014 (UTC)Reply
Done.
Trappist the monk (talk) 00:38, 17 December 2014 (UTC)Reply
Thanks! Peter coxhead (talk) 16:54, 17 December 2014 (UTC)Reply

Dashes and hyphens, oh my

A number of threads have shown up on WT:VPT (e.g. WP:VPT#Help in fixing a "cite error") and elsewhere regarding the change in MediaWiki to output an error where the same names are used in a reference but where the reference is defined differently.

It seems to me that a basic level of checking for that could be implemented in this module, either (namely) to treat (example) |p= and |pp= the same before outputting the reference for Template:sfn or to do some basic level of sanity checking e.g. where |p= uses a dash/hyphen (and should not) or where |pp= doesn't use one of the set: (,|-) (or similar).

Thoughts? --Izno (talk) 17:17, 14 November 2015 (UTC)Reply

Only that there's a need to be careful not to exclude electronic publications which increasingly have "page" numbers with non-numerical characters in them. Peter coxhead (talk) 17:26, 14 November 2015 (UTC)Reply
My suggestion would be only to look for certain punctuation. --Izno (talk) 17:40, 14 November 2015 (UTC)Reply
And then do what once the detector detects whatever it is set to detect?
This is difficult. |p=A-1 or |p=17-6 are legitimate page numbers.
Trappist the monk (talk) 18:10, 14 November 2015 (UTC)Reply
Precisely. Peter coxhead (talk) 22:05, 14 November 2015 (UTC)Reply

Auto-formatting dashes in parameter "pages"

Module:Citation/CS1 based templates automatically replace hyphens (-) with endashes (–) when hyphens are typed in the |pages= parameter. Is it possible to implement this feature into this module?
Αντιγόνη (talk) 07:24, 28 September 2016 (UTC)Reply

Yes, we can do that here if there is sufficient support for it. If we do add it, I would like to see us adopt some sort of mechanism that allows editors to override the auto-conversion. Elsewhere I suggested a couple of ways that this might be accomplished. Those proposals were not taken up.
Trappist the monk (talk) 10:40, 28 September 2016 (UTC)Reply
So what would happen with something like |pp=A-1–A-15? Entirely possible with electronic publications. Peter coxhead (talk) 14:15, 28 September 2016 (UTC)Reply
Which is why I suggested |pp=((A-1–A-15)) or |pp=A--1-A--15 as ways to tell the module to 'do it this way': pp. A-1–A-15.
Trappist the monk (talk) 14:48, 28 September 2016 (UTC)Reply
Well, either there has to be some special mechanism, as you suggest, or no automatic replacement, which I prefer. Peter coxhead (talk) 15:24, 28 September 2016 (UTC)Reply

Last change broke date=n.d.

Please add a condition in function core to avoid adding the ampersand before the date when date=n.d.: {{harv|Author|n.d.}} results in (Author n.d.). 72.43.99.146 (talk) 00:30, 18 October 2016 (UTC)Reply

Amendment: even though it should be obvious anyway, I should have stated that any iteration of an undated reference gets similar treatment ("undated", "no date" etc.) since the module thinks that these are author names. 72.43.99.146 (talk) 00:40, 18 October 2016 (UTC)Reply

test cases

Hi. I've just run the test cases against some small changes to the code in the sandbox, with lamentable results. I reverted my changes and the test cases still fail. Is this expected? Alternatively, should I copy the main code into the sandbox to ensure that the sandbox code is up to date? I don't want to damage anyone else's work. Regards, Martin of Sheffield (talk) 22:40, 21 August 2017 (UTC)Reply

The {{sfn}} tests have never 'passed' as far as I know because two {{sfn}} templates with identical input parameters must be separately distinguishable from each other else the back-links won't work. Two instances of the same template:
{{sfn|brown|red|orange|2017}}
produce:
<sup id="cite_ref-FOOTNOTEbrownredorange2017_1-0" class="reference"><a href="#cite_note-FOOTNOTEbrownredorange2017-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-FOOTNOTEbrownredorange2017_1-1" class="reference"><a href="#cite_note-FOOTNOTEbrownredorange2017-1">&#91;1&#93;</a></sup>
I suspect that the values used in the comparison made by the test code are the values of two stripmarkers:
?'"`UNIQ--ref-0000000A-QINU`"'?
?'"`UNIQ--ref-0000000C-QINU`"'?
Stripmarkers are replaced with actual content long after the template and module code has run.
Trappist the monk (talk) 09:48, 22 August 2017 (UTC)Reply

Page needed

Have recent changes to this template caused the use of {{page needed}} as a value for the parameter "p=" caused a break. If so it has broken many pages. See for example this edit (Revision as of 09:56, 2 February 2017) mentioned in this section Talk:Second Boer War#Fixing style/layout errors.

  • {{sfn|Haydon|1964|p={{page needed|date=February 2017}} }}
  • [1]

References

  1. ^ Haydon 1964, p. [page needed].

If so please revert the and discuss how to fix it, as the change as this will have broken many pages, and the fix of placing page needed outside the short citation is not appropriate. -- PBS (talk) 20:03, 7 December 2017 (UTC)Reply

No recent changes. Last change was 18 September as you can see from the history. What is interesting is that if you were to rewrite that example without a date, it appears to function correctly. {{sfn|Haydon|1964|p={{page needed}} }}[1]

References

  1. ^ Haydon 1964, p. [page needed].
Something mysteriously wrong with {{page needed}}?
Trappist the monk (talk) 21:20, 7 December 2017 (UTC)Reply
{{Page needed}} needs a date (a bot will added it). It seems to work now, so (as always) as we do not use version numbers the broken text no longer shows an error. So for the record/archive what was fixed? -- PBS (talk) 19:54, 10 December 2017 (UTC)Reply
This; described here.
Trappist the monk (talk) 03:13, 11 December 2017 (UTC)Reply
Thanks. For the record now the above is now archived: Wikipedia:Village pump (technical)/Archive 161#Either Template:Sfn or some subtemplate of it appears to be broken. -- PBS (talk) 18:41, 18 December 2017 (UTC)Reply

Logic error in handling of "n.d."

The conditional statement in lines 70-72 ("prevent double periods when date is 'n.d.'"). It forces |ps=none ("then args.postscript = ''"). Please fix. 108.182.15.109 (talk) 13:26, 19 June 2018 (UTC)Reply

The error is harder to see because it is only visible when the in-source ___location is absent. 108.182.15.109 (talk) 13:33, 19 June 2018 (UTC)Reply
Can you provide a clear example of what you mean?
Trappist the monk (talk) 13:41, 19 June 2018 (UTC)Reply
{{sfn|Author|2018|ps=, postscript}} [1]
{{sfn|Author1|n.d.|ps=, postscript1}} [2]
  1. ^ Author 2018, postscript
  2. ^ Author1 n.d., postscript1
65.88.88.127 (talk) 20:33, 19 June 2018 (UTC)Reply
fixed
Trappist the monk (talk) 11:14, 22 June 2018 (UTC)Reply