inukshuk / jekyll-scholar

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

Highlight one or more authors #361

Open JulioAzcarate opened 5 months ago

JulioAzcarate commented 5 months ago

It would be very useful to have an option to highlight one or more authors in the list of publications.

PS: sorry, I didn't find how to tag this comment as inprove or suggestion.

inukshuk commented 5 months ago

Good idea!

The first approach that comes to mind is to do this by using a bibliography template. In the template you have access to the rendered reference string as well as to the all the entry's individual fields. This means you could, for example, check the entry's authors to see if the author you want to highlight is is present, and if so use a regular expression to wrap the first occurrence of the author in the reference string.

DerAndereJohannes commented 4 months ago

I also asked myself this today and looked into changing the templates. Here was my solution, feel free to use it:

{% assign new_reference = reference %}
{% for ref_name in site.reference_names %}
    {% assign highlighted_name = '<strong>' | append: ref_name | append: '</strong>' %}
    {% assign new_reference = new_reference | replace: ref_name, highlighted_name %}
{% endfor %}

{{ new_reference }}

This way I can simply define the names in the standard _config.yml file like so:

reference_names:
    - "Name One"
    - "Name Two"
robaru commented 3 months ago

Hey @DerAndereJohannes, I am trying to apply your template but I don’t manage to get it to work.

I have created a bib.html file into _layouts and referenced in _config.yml. Its content is exactly the one that you provide above.

The _config.yml looks like this:

scholar:
  style: apa
  locale: en
  source: ./assets/
  bibliography: papers.bib
  sort_by: type,year,month
  order: ascending
  group_by: type,year
  bibliography_template: bib
  reference_names:
    - “Name one"

In name one, I have written my full name.

Can I ask for some help?

DerAndereJohannes commented 3 months ago

Hi @robaru, Sorry, I should have been a bit more clear. The reference_names does not belong to the scholar repository so you have to place it outside of the scholar tag like I did here.

For you, the change would look like this:

scholar:
  style: apa
  locale: en
  source: ./assets/
  bibliography: papers.bib
  sort_by: type,year,month
  order: ascending
  group_by: type,year
  bibliography_template: bib

reference_names:
  - “Name one"

Let me know if this helped!

robaru commented 3 months ago

It worked! Thanks!

Leno4ka94 commented 2 months ago

@inukshuk @everyone Hi, can somebody help me to add other style to jekyll-scholar for example unified-style-sheet-for-linguistics.csl (zotero style) I try to add but nothing work. I hope it can be realize