Skip to content

Commit

Permalink
Support superscripts in bibtex author names (alshedivat#2512)
Browse files Browse the repository at this point in the history
Implements alshedivat#2511
  • Loading branch information
garywei944 authored and Suraj-Bhor committed Aug 13, 2024
1 parent 0a8bd03 commit 5afa8a9
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CUSTOMIZE.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ You can easily create your own collections, apps, short stories, courses, or wha

To add publications create a new entry in the [\_bibliography/papers.bib](_bibliography/papers.bib) file. You can find the BibTeX entry of a publication in Google Scholar by clicking on the quotation marks below the publication title, then clicking on "BibTeX", or also in the conference page itself. By default, the publications will be sorted by year and the most recent will be displayed first. You can change this behavior and more in the `Jekyll Scholar` section in [\_config.yml](_config.yml) file.

You can add extra information to a publication, like a PDF file in the `assets/pdfs/` directory and add the path to the PDF file in the BibTeX entry with the `pdf` field. Some of the supported fields are: `abstract`, `altmetric`, `arxiv`, `bibtex_show`, `blog`, `code`, `dimensions`, `doi`, `eprint`, `html`, `isbn`, `pdf`, `pmid`, `poster`, `slides`, `supp`, `video`, and `website`.
You can add extra information to a publication, like a PDF file in the `assets/pdfs/` directory and add the path to the PDF file in the BibTeX entry with the `pdf` field. Some of the supported fields are: `abstract`, `altmetric`, `annotation`, `arxiv`, `bibtex_show`, `blog`, `code`, `dimensions`, `doi`, `eprint`, `html`, `isbn`, `pdf`, `pmid`, `poster`, `slides`, `supp`, `video`, and `website`.

### Author annotation

Expand Down Expand Up @@ -124,6 +124,7 @@ There are several custom bibtex keywords that you can use to affect how the entr
- `abbr`: Adds an abbreviation to the left of the entry. You can add links to these by creating a venue.yaml-file in the \_data folder and adding entries that match.
- `abstract`: Adds an "Abs" button that expands a hidden text field when clicked to show the abstract text
- `altmetric`: Adds an [Altmetric](https://www.altmetric.com/) badge (Note: if DOI is provided just use `true`, otherwise only add the altmetric identifier here - the link is generated automatically)
- `annotation`: Adds a popover info message to the end of the author list that can potentially be used to clarify superscripts. HTML is allowed.
- `arxiv`: Adds a link to the Arxiv website (Note: only add the arxiv identifier here - the link is generated automatically)
- `bibtex_show`: Adds a "Bib" button that expands a hidden text field with the full bibliography entry
- `blog`: Adds a "Blog" button redirecting to the specified link
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ group :jekyll_plugins do
gem 'jekyll-link-attributes'
gem 'jekyll-minifier'
gem 'jekyll-paginate-v2'
gem 'jekyll-regex-replace'
gem 'jekyll-scholar'
gem 'jekyll-sitemap'
gem 'jekyll-tabs'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ GEM
uglifier (~> 4.1)
jekyll-paginate-v2 (3.0.0)
jekyll (>= 3.0, < 5.0)
jekyll-regex-replace (1.1.0)
jekyll-sass-converter (3.0.0)
sass-embedded (~> 1.54)
jekyll-scholar (7.1.3)
Expand Down Expand Up @@ -205,6 +206,7 @@ DEPENDENCIES
jekyll-link-attributes
jekyll-minifier
jekyll-paginate-v2
jekyll-regex-replace
jekyll-scholar
jekyll-sitemap
jekyll-tabs
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Feel free to add your own page(s) by sending a PR.
<a href="https://jackjburnett.github.io/" target="_blank">★</a>
<a href="https://physics-morris.github.io/" target="_blank">★</a>
<a href="https://sraf.ir" target="_blank">★</a>
<a href="https://acad.garywei.dev/" target="_blank">★</a>
</td>
</tr>
<tr>
Expand Down
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ plugins:
- jekyll-link-attributes
- jekyll-minifier
- jekyll-paginate-v2
- jekyll-regex-replace
- jekyll/scholar
- jekyll-sitemap
- jekyll-tabs
Expand Down Expand Up @@ -349,6 +350,7 @@ filtered_bibtex_keywords:
abstract,
additional_info,
altmetric,
annotation,
arxiv,
award,
award_name,
Expand Down
22 changes: 17 additions & 5 deletions _layouts/bib.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@

{%- for author in entry.author_array limit: author_array_limit -%}
{% assign author_is_self = false %}
{%- assign author_last_name = author.last | remove: '¶' | remove: '&' | remove: '*' | remove: '†' | remove: '^' -%}
{%- assign author_last_name = author.last | regex_replace: '[*∗†‡§¶‖&^]', '' -%}
{%- assign author_last_html = author.last | regex_replace: '([*∗†‡§¶‖&^]+)', '<sup>\1</sup>' -%}
{% if site.scholar.last_name contains author_last_name %}
{% if site.scholar.first_name contains author.first %}
{% assign author_is_self = true %}
Expand All @@ -83,17 +84,17 @@
{%- if author_is_self -%}
<em>
{{- author.first }}
{{ author.last -}}
{{ author_last_html -}}
</em>
{%- else -%}
{%- if coauthor_url -%}
<a href="{{coauthor_url}}">
{{- author.first }}
{{ author.last -}}
{{ author_last_html -}}
</a>
{%- else -%}
{{- author.first }}
{{ author.last -}}
{{ author_last_html -}}
{% endif %}
{%- endif -%}
{% endfor %}
Expand All @@ -111,6 +112,7 @@
{% assign more_authors_show = more_authors_show | append: ', ' %}
{% endunless %}
{%- endfor -%}
{% assign more_authors_show = more_authors_show | regex_replace: '([*∗†‡§¶‖&^]+)', '<sup>\1</sup>' %}
, and
<span
class="more-authors"
Expand All @@ -121,7 +123,7 @@
var more_authors_text = element.text() == '{{more_authors_hide}}' ? '{{more_authors_show}}' : '{{more_authors_hide}}';
var cursorPosition = 0;
var textAdder = setInterval(function(){
element.text(more_authors_text.substring(0, cursorPosition + 1));
element.html(more_authors_text.substring(0, cursorPosition + 1));
if (++cursorPosition == more_authors_text.length){
clearInterval(textAdder);
}
Expand All @@ -131,6 +133,16 @@
{{- more_authors_hide -}}
</span>
{% endif %}
{% if entry.annotation %}
<i
class="fa-solid fa-circle-info ml-1"
data-toggle="popover"
data-placement="top"
data-html="true"
data-content="{{ entry.annotation | escape }}"
>
</i>
{% endif %}
</div>

<!-- Journal/Book title and date -->
Expand Down
3 changes: 3 additions & 0 deletions _plugins/hide-custom-bibtex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ def hideCustomBibtex(input)
input = input.gsub(/^.*\b#{keyword}\b *= *\{.*$\n/, '')
end

# Clean superscripts in author lists
input = input.gsub(/^.*\bauthor\b *= *\{.*$\n/) { |line| line.gsub(/[*†‡§¶‖&^]/, '') }

return input
end
end
Expand Down
34 changes: 34 additions & 0 deletions _sass/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1134,3 +1134,37 @@ ninja-keys::part(ninja-input) {
ninja-keys::part(ninja-input-wrapper) {
background: var(--global-bg-color);
}

// popover is used for annotation in bib.liquid
.popover {
background-color: var(--global-bg-color);
border-color: var(--global-divider-color);

.popover-header {
color: var(--global-text-color); // Header text color
border-bottom: 1px solid var(--global-divider-color);
}
.popover-body {
color: var(--global-text-color); // Body text color
}
}
.bs-popover-top {
// arrow fill color
.arrow::after {
border-top-color: var(--global-bg-color);
}
// arrow border color
.arrow:before {
border-top-color: var(--global-divider-color);
}
}
.bs-popover-bottom {
// arrow fill color
.arrow::after {
border-bottom-color: var(--global-bg-color);
}
// arrow border color
.arrow:before {
border-bottom-color: var(--global-divider-color);
}
}
5 changes: 5 additions & 0 deletions assets/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ $(document).ready(function () {
});
}
});

// trigger popovers
$('[data-toggle="popover"]').popover({
trigger: "hover",
});
});

0 comments on commit 5afa8a9

Please sign in to comment.