inukshuk / jekyll-scholar

jekyll extensions for the blogging scholar
MIT License
1.13k stars 101 forks source link

Issues with bibliography --file {{myfile}} #282

Closed dirteat closed 4 years ago

dirteat commented 4 years ago

With jekyll 3.8.6 and jekyll-scholar 5.16.0, I used to generate bibliography from different file using a variable:

%{ bibliography --file {{ myfile }} %}

which is now broken with jekyll 4.0 and latest version of jekyll-scolar (6.3.0). If seems that only the bibliography of the first evaluation of {{myfile}} is actually generated.

This feature was FANTASTIC, please restore it if you can.

Thanks :) Cheers, Chris.

inukshuk commented 4 years ago

Can you provide more context? Or ideally a failing test case? We have lots of interpolation tests and they still work with Jekyll 4.

dirteat commented 4 years ago

That's the typical layout I have. I can check that {{member.bibfile}} is evaluated correctly within the line:

Publications of X

The page generated has the expected value for X. The problem appears only within the line

{% bibliography --file {{ member.bibfile }} %}

it is evaluated only to its first value (here the name of the first member, in alphabetical order). I've tried to run jekyll in safe mode, but that does change anything.

---
layout: default
---

<header>
  <h1 class="member-title">{{ page.title }}</h1>
</header>

{% for item in site.members %}
  {% if item.title == page.title %}
    {% assign member = item %}
  {% endif %}
{% endfor %}

<div class="content">

{% unless member.bibfile == null %}
<h3> Publications of {{member.bibfile}} </h3>

{% bibliography --file {{ member.bibfile }} --group_by year --group_order descending %}

{% endunless %}
</div>
inukshuk commented 4 years ago

Out of curiosity, can you try to add {% assign bibfile = member.bibfile %} just before the h3 and then use just bibfile in both the h3 and bibliography lines. Does that produce the same result?

dirteat commented 4 years ago

Just tested, yes, it produced the same result. Publications of {{ bibfile }} returns the expected value, but not the {% bibliography --file {{bibfile}} %}

inukshuk commented 4 years ago

Hey, sorry for taking so long to get back to you. I just looked into this and I'm pretty sure jekyll optimized the way the layout context is (re-) used during compilation. Since jekyll-scholar's try to re-use its own context this might affect other aspects of using interpolation in layouts, but for the time being I added a check to ensure the bibliography is parsed again if the source files change. I hope this makes your example work again (I added a similar example to our test suite which looks good).

inukshuk commented 4 years ago

Landed in 6.3.2

dirteat commented 4 years ago

Thanks a lot, works perfectly, you rock!