Skip to content

Commit 58391d1

Browse files
authored
Fix commas in author list (alshedivat#770)
1 parent 2186bdd commit 58391d1

File tree

2 files changed

+35
-51
lines changed

2 files changed

+35
-51
lines changed

_config.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,10 @@ scholar:
247247
# Filter out certain bibtex entry keywords used internally from the bib output
248248
filtered_bibtex_keywords: [abbr, abstract, arxiv, bibtex_show, html, pdf, selected, supp, blog, code, poster, slides, website, preview]
249249

250-
# Maximum number of authors to be shown, other authors will be visible on hover, leave blank to show all authors
251-
max_author_limit: 3
250+
# Maximum number of authors to be shown for each publication (more authors are visible on click)
251+
max_author_limit: 3 # leave blank to always show all authors
252+
more_authors_animation_delay: 10 # more authors are revealed on click using animation; smaller delay means faster animation
253+
252254

253255
# -----------------------------------------------------------------------------
254256
# Responsive WebP Images

_layouts/bib.html

+31-49
Original file line numberDiff line numberDiff line change
@@ -29,76 +29,58 @@
2929
<div class="author">
3030
{% assign author_array_size = entry.author_array | size %}
3131

32+
{% assign author_array_limit = author_array_size %}
3233
{%- if site.max_author_limit and author_array_size > site.max_author_limit %}
3334
{% assign author_array_limit = site.max_author_limit %}
34-
{% else %}
35-
{% assign author_array_limit = author_array_size %}
3635
{% endif %}
3736

3837
{%- for author in entry.author_array limit: author_array_limit -%}
3938
{%- assign author_is_self = false -%}
40-
{%- if author.last == site.scholar.last_name %}
39+
{%- assign author_last_name = author.last | remove: "¶" | remove: "&" | remove: "*" | remove: "†" | remove: "^" -%}
40+
{%- if author_last_name == site.scholar.last_name -%}
4141
{%- if site.scholar.first_name contains author.first -%}
4242
{%- assign author_is_self = true -%}
4343
{%- endif -%}
4444
{%- endif -%}
4545
{%- assign coauthor_url = nil -%}
46-
{%- if site.data.coauthors[author.last] -%}
47-
{%- for coauthor in site.data.coauthors[author.last] -%}
46+
{%- if site.data.coauthors[author_last_name] -%}
47+
{%- for coauthor in site.data.coauthors[author_last_name] -%}
4848
{%- if coauthor.firstname contains author.first -%}
4949
{%- assign coauthor_url = coauthor.url -%}
5050
{%- break -%}
5151
{%- endif -%}
5252
{%- endfor -%}
5353
{%- endif -%}
5454

55-
{%- if forloop.length == 1 -%}
56-
{%- if author_is_self %}
57-
<em>{{author.last}}, {{author.first}}</em>
58-
{%- else -%}
59-
{{author.last}}, {{author.first}}
60-
{%- endif -%}
55+
{%- if forloop.length > 1 -%}
56+
{%- if forloop.first == false -%},&nbsp;{%- endif -%}
57+
{%- if forloop.last and author_array_limit == author_array_size -%}and&nbsp;{%- endif -%}
58+
{%- endif -%}
59+
{%- if author_is_self -%}
60+
<em>{{author.first}} {{author.last}}</em>
6161
{%- else -%}
62-
{%- unless forloop.last -%}
63-
{% if author_is_self %}
64-
<em>{{author.last}}, {{author.first}}</em>,&nbsp;
65-
{%- else -%}
66-
{% if coauthor_url -%}
67-
<a href="{{coauthor_url}}">{{author.last}}, {{author.first}}</a>,&nbsp;
68-
{%- else -%}
69-
{{author.last}}, {{author.first}},&nbsp;
70-
{%- endif -%}
71-
{%- endif -%}
62+
{%- if coauthor_url -%}
63+
<a href="{{coauthor_url}}">{{author.first}} {{author.last}}</a>
7264
{%- else -%}
73-
{%- if author_array_limit == author_array_size %} and {% endif %}
74-
{% if author_is_self -%}
75-
<em>{{author.last}}, {{author.first}}</em>
76-
{% else -%}
77-
{%- if coauthor_url -%}
78-
<a href="{{coauthor_url}}">{{author.last}}, {{author.first}}</a>
79-
{% else -%}
80-
{{author.last}}, {{author.first}}
81-
{%- endif -%}
82-
{%- endif -%}
83-
{%- endunless -%}
65+
{{author.first}} {{author.last}}
66+
{%- endif -%}
8467
{%- endif -%}
85-
{%- endfor %}
86-
87-
{% assign more_authors = author_array_size | minus: author_array_limit %}
88-
89-
{%- if more_authors > 0 %}
90-
{% assign more_authors_hide = more_authors | append: " more author" %}
91-
{% if more_authors > 1 %}
92-
{% assign more_authors_hide = more_authors_hide | append: "s" %}
93-
{% endif %}
94-
{% assign more_authors_show = '' %}
68+
{%- endfor -%}
69+
{%- assign more_authors = author_array_size | minus: author_array_limit -%}
70+
71+
{%- assign more_authors_hide = more_authors | append: " more author" -%}
72+
{%- if more_authors > 0 -%}
73+
{%- if more_authors > 1 -%}
74+
{%- assign more_authors_hide = more_authors_hide | append: "s" -%}
75+
{%- endif -%}
76+
{%- assign more_authors_show = '' -%}
9577
{%- for author in entry.author_array offset: author_array_limit -%}
96-
{% assign more_authors_show = more_authors_show | append: author.last | append: ", " | append: author.first %}
97-
{% unless forloop.last %}
98-
{% assign more_authors_show = more_authors_show | append: ",&nbsp;" %}
99-
{% endunless %}
78+
{%- assign more_authors_show = more_authors_show | append: author.first | append: " " | append: author.last -%}
79+
{%- unless forloop.last -%}
80+
{%- assign more_authors_show = more_authors_show | append: ", " -%}
81+
{%- endunless -%}
10082
{%- endfor -%}
101-
and
83+
, and
10284
<span
10385
class="more-authors"
10486
title="click to view {{more_authors_hide}}"
@@ -112,10 +94,10 @@
11294
if (++cursorPosition == more_authors_text.length){
11395
clearInterval(textAdder);
11496
}
115-
}, 15);
97+
}, '{{site.more_authors_animation_delay}}');
11698
"
11799
>{{more_authors_hide}}</span>
118-
{% endif %}
100+
{%- endif -%}
119101

120102
</div>
121103

0 commit comments

Comments
 (0)