teachPress icon indicating copy to clipboard operation
teachPress copied to clipboard

Multiple citations of the same key lead to several entries in the references list

Open samthiriot opened this issue 2 years ago • 5 comments

Hi, Thanks for the great plugin!

I cited several times the same article (same key) in several places using tpcite. I expected the latex/bibtex behaviour with the same number being referenced several times (one unique entry 1 referenced several times). I obtain instead as many entries in the list of references created by tpref as tpcite calls.

I can try to contribute the code to have unique references if you agree this would be the expected behaviour

Thanks again

samthiriot avatar Jun 08 '23 14:06 samthiriot

Hi Samuel,

My intention was to enable a kind of footnote citation like in Word or Wikipedia, in which is it more common to repeat the source. But I can fully understand that this is not for all a wished behaviour. So, I think it wood be the best idea to create an option (as an shortcode parameter) for the user to switch between both variants.

winkm89 avatar Jun 11 '23 16:06 winkm89

Makes sense, thanks! I'll set up a development environment when possible and propose you a merge request later. Thanks again for the plugin, which provides a high value for me!

samthiriot avatar Jun 11 '23 18:06 samthiriot

Hi Michael,

I'm analyzing the code, and am back with a question regarding the expected behaviour.

analyzis The id of the reference is generated when processing tpcite shortcode (in order to generate the number 1, 2...). So the solution does not only lie in the tpref code, but we should know the preference of the user before the first call to tpcite. If I add an option to the tpref shortcode, earlier tpcite cannot be aware of it.

options

I see few solutions:

  1. the LaTeX/BibTeX way is to define the option earlier in the document. In bibtex, it is done with a "\bibliographystyle" command. This would mean adding a shortcode dedicated to tuning an option changing the behaviour of the further tpcite and tpref shortcodes (stored in the shared TP_Cite_Object). I'm not sure this is in line with habits in wordpress
  2. we might imagine the user wants a consistent behaviour accross all pages, so this might be an option of the entire plugin. But this would not be consistent with the behavior of the plugin for other parameters. For instance why would "show links" be defined as a shortcode option, while "how to deal with repeated cite" would be a plugin level setting?
  3. other plugins define attributes at the scale of the page (for instance language), but this requires adding parameters to the block editor, and this would be one more time the first and only option to do it

I'd tend to opt for option 1 which is easy to do with less code. It would affect only people who want to factorize the refs, the default behaviour would remain unchanged.

What do you think?

Thanks for you time

samthiriot avatar Jun 17 '23 16:06 samthiriot

After prototyping: adding a new shortcode (option 1) does not seem very relevant:

  • one more shortcode is way more php code in the plugin (therefore more maintenance)
  • it requires more doc in the wiki, and therefore more things to go through for a user,
  • it creates a weird shortcode with no direct effect (not a standard practice in wordpress)

I submitted a merge request with option 2 (additional setting). Other options might be considered later, such as adding backrefs for instance.

I've the feeling it's really not intrusive to the user; indeed no one will notice the possibility if they don't change the setting in the settings page.

Feel free to tell me if this is not ok for you.

Thanks!

samthiriot avatar Jun 19 '23 20:06 samthiriot

Thank you for the pull request! I think each variant has its advantages and disadvantages. I also haven't the perfect idea. So, the one you have added is fully fine for me. Let's give it a try in the wild :)

winkm89 avatar Jun 20 '23 19:06 winkm89