Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix commas in author list #770

Merged
merged 9 commits into from
Aug 6, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 30 additions & 43 deletions _layouts/bib.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
<div class="author">
{% assign author_array_size = entry.author_array | size %}

{% assign author_array_limit = author_array_size %}
{%- if site.max_author_limit and author_array_size > site.max_author_limit %}
{% assign author_array_limit = site.max_author_limit %}
{% else %}
{% assign author_array_limit = author_array_size %}
{% endif %}

{%- for author in entry.author_array limit: author_array_limit -%}
Expand All @@ -52,53 +51,41 @@
{%- endfor -%}
{%- endif -%}

{%- if forloop.length == 1 -%}
{%- if author_is_self %}
<em>{{author.last}}, {{author.first}}</em>
{%- if forloop.length > 1 -%}
{%- if forloop.first == false -%},&nbsp;{%- endif -%}
{%- if forloop.last and author_array_limit == author_array_size -%}and&nbsp;{%- endif -%}
{%- endif -%}
{%- if author_is_self -%}
<em>{{author.last}}, {{author.first}}</em>
{%- else -%}
{%- if coauthor_url -%}
<a href="{{coauthor_url}}">{{author.last}}, {{author.first}}</a>
{%- else -%}
{{author.last}}, {{author.first}}
{%- endif -%}
{%- else -%}
{%- unless forloop.last -%}
{% if author_is_self %}
<em>{{author.last}}, {{author.first}}</em>,&nbsp;
{%- else -%}
{% if coauthor_url -%}
<a href="{{coauthor_url}}">{{author.last}}, {{author.first}}</a>,&nbsp;
{%- else -%}
{{author.last}}, {{author.first}},&nbsp;
{%- endif -%}
{%- endif -%}
{%- else -%}
{%- if author_array_limit == author_array_size %} and {% endif %}
{% if author_is_self -%}
<em>{{author.last}}, {{author.first}}</em>
{% else -%}
{%- if coauthor_url -%}
<a href="{{coauthor_url}}">{{author.last}}, {{author.first}}</a>
{% else -%}
{{author.last}}, {{author.first}}
{%- endif -%}
{%- endif -%}
{%- endunless -%}
{%- endif -%}
{%- endfor %}

{% assign more_authors = author_array_size | minus: author_array_limit %}
{%- endfor -%}

{%- if more_authors > 0 %}
{% assign more_authors_hide = more_authors | append: " more author" %}
{% if more_authors > 1 %}
{% assign more_authors_hide = more_authors_hide | append: "s" %}
{% endif %}
{% assign more_authors_show = '' %}
{%- assign more_authors = author_array_size | minus: author_array_limit -%}

{%- if author_array_limit == 0 -%}
{%- assign more_authors_hide = more_authors | append: " more author" -%}
{%- else -%}
{%- assign more_authors_hide = ", and " | append: more_authors | append: " more author" -%}
{%- endif -%}
{%- if more_authors > 0 -%}
{%- if more_authors > 1 -%}
{%- assign more_authors_hide = more_authors_hide | append: "s" -%}
{%- endif -%}
{%- assign more_authors_show = '' -%}
{%- for author in entry.author_array offset: author_array_limit -%}
{% assign more_authors_show = more_authors_show | append: author.last | append: ", " | append: author.first %}
{% unless forloop.last %}
{% assign more_authors_show = more_authors_show | append: ",&nbsp;" %}
{% endunless %}
{%- unless forloop.last -%}
{%- assign more_authors_show = more_authors_show | append: ", " -%}
{%- else -%}
{%- assign more_authors_show = more_authors_show | append: ", and " -%}
{%- endunless -%}
{%- assign more_authors_show = more_authors_show | append: author.first | append: " " | append: author.last -%}
{%- endfor -%}
and
<span
class="more-authors"
title="click to view {{more_authors_hide}}"
Expand All @@ -115,7 +102,7 @@
}, 15);
"
>{{more_authors_hide}}</span>
{% endif %}
{%- endif -%}

</div>

Expand Down