pelican-plugins / pandoc-reader

Pandoc Reader is a Pelican plugin that processes Markdown content via Pandoc
11 stars 3 forks source link

Some added functionality for managing bibliography and style files for citations #28

Closed JonathanMair closed 1 year ago

JonathanMair commented 1 year ago

Hi - am submitting a pull request as discussed in Issues.

Happy for you to use this as you see fit.

All the best,

Jon

nandac commented 1 year ago

Thanks, @JonathanMair I will take a look into it this week and look into including it.

nandac commented 1 year ago

@JonathanMair I have a few things to ask and point out:

  1. Adding the below code will conflict with Pandoc's own functionality for the bibliography key in the content metadata where you can specify it is specified as a YAML array. The metadata is then passed directly to Pandoc to handle. So could you please tell me if the below is really needed for your use case:

    if 'bibliography' in metadata_from_content.keys():
    filename = metadata_from_content['bibliography']
    pandoc_cmd.append("--bibliography={0}".format(filename))
  2. The code for default CSL had a list as a default value of a list as shown below:

    default_csl = self.settings.get("DEFAULT_CSL", [])

    I believe that. the default value for this should be None or an empty string as having multiple citation styles for the same document does not make sense to me. Your thoughts?

  3. I might prepend some of the variables in this plugin with PANDOC_READER or PANDOC to tag it to this reader something which I have been meaning to do for a while. So the names of the settings you have put in your pull request may change slightly.

  4. We should also document that specifying DEFAULT_BIBLIOGRAPHY or DEFAULT_CSL will override values in a defaults file as this may differ from Pandoc's precedence rules which is an area I am hazy on.

Thanks for the PR I will incorporate it and write some tests.

JonathanMair commented 1 year ago

Hi @nandac. Thanks for taking the time to look into this in detail.

In response to your points:

  1. You're probably right...I think I was probably thinking that adding these fields would simplify the process for the user in the metadata block. But at the same time it makes things more complicated in the code.
  2. Yes, I agree.
  3. That's fine by me.
  4. Yes, good point.

For 4, as you probably worked out, the reason I didn't rely on the default file to supply the default bibliography is that I couldn't see any way of conveniently removing the default supplied in that way for the exclusive_bibliography function. Unfortunately that's a pretty important functionality because the way citation keys are generated means there are often likely to be clashes between different bibliography files.

Basically (you probably know this already) the key is usually made up of [author] + [year] then if there are multiple works that have the same author and year they get a disambiguator, usually a letter, so we might get: nandac2022a, nandac2022b, etc. Those disambiguators are added in the order the works are added to the bibliography, so there's no way of knowing nandac2022a in one bibliography refers to the same work as nandac2022a in another bibliography.

Thanks again

nandac commented 1 year ago

Hi @nandac. Thanks for taking the time to look into this in detail.

In response to your points:

  1. You're probably right...I think I was probably thinking that adding these fields would simplify the process for the user in the metadata block. But at the same time it makes things more complicated in the code.
  2. Yes, I agree.
  3. That's fine by me.
  4. Yes, good point.

For 4, as you probably worked out, the reason I didn't rely on the default file to supply the default bibliography is that I couldn't see any way of conveniently removing the default supplied in that way for the exclusive_bibliography function. Unfortunately that's a pretty important functionality because the way citation keys are generated means there are often likely to be clashes between different bibliography files.

Basically (you probably know this already) the key is usually made up of [author] + [year] then if there are multiple works that have the same author and year they get a disambiguator, usually a letter, so we might get: nandac2022a, nandac2022b, etc. Those disambiguators are added in the order the works are added to the bibliography, so there's no way of knowing nandac2022a in one bibliography refers to the same work as nandac2022a in another bibliography.

Thanks again

I think I understand your issues better now. I guess what you want is to disable default file settings in certain cases. By right the way the plugin is built, all defaults should be in a defaults file and that is the way I should handle the case of DEFAULT_CSL and DEFAULT_BIBLIOGRAPHIES.

Let me see if I can easily cater to your case with the current functionality intact then we don't need to add the two new settings as well.

I need some time to think about it and will get back to you.

JonathanMair commented 1 year ago

Yes, ultimately the extra functions were simply:

Best,

Jon

On 17 Jan 2023, at 06:02, nandac @.***> wrote:

Hi @nandac https://github.com/nandac. Thanks for taking the time to look into this in detail.

In response to your points:

You're probably right...I think I was probably thinking that adding these fields would simplify the process for the user in the metadata block. But at the same time it makes things more complicated in the code. Yes, I agree. That's fine by me. Yes, good point. For 4, as you probably worked out, the reason I didn't rely on the default file to supply the default bibliography is that I couldn't see any way of conveniently removing the default supplied in that way for the exclusive_bibliography function. Unfortunately that's a pretty important functionality because the way citation keys are generated means there are often likely to be clashes between different bibliography files.

Basically (you probably know this already) the key is usually made up of [author] + [year] then if there are multiple works that have the same author and year they get a disambiguator, usually a letter, so we might get: nandac2022a, nandac2022b, etc. Those disambiguators are added in the order the works are added to the bibliography, so there's no way of knowing nandac2022a in one bibliography refers to the same work as nandac2022a in another bibliography.

Thanks again

I think I understand your issues better now. I guess what you want is to disable default file settings in certain cases. By right the way the plugin is built, all defaults should be in a defaults file and that is the way I should handle the case of DEFAULT_CSL and DEFAULT_BIBLIOGRAPHIES.

Let me see if I can easily cater to your case with the current functionality intact then we don't need to add the two new settings as well.

I need some time to think about it and will get back to you.

— Reply to this email directly, view it on GitHub https://github.com/pelican-plugins/pandoc-reader/pull/28#issuecomment-1384834540, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4KBPCLPYB5RU77AN2IYKITWSYRXXANCNFSM6AAAAAATUQX7KU. You are receiving this because you were mentioned.