Added bibtex filter to hide custom bibtex keywords from bib file output (#652)

This commit is contained in:
Tønnes Nygaard 2022-05-01 17:38:39 +02:00 committed by GitHub
parent e5c1012aeb
commit c4e170a545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -237,6 +237,7 @@ scholar:
query: "@*" query: "@*"
filtered_bibtex_keywords: [abbr, abstract, arxiv, bibtex_show, html, pdf, selected, supp, blog, code, poster, slides, website] # Filter out certain bibtex entry keywords used internally from the bib output
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Responsive WebP Images # Responsive WebP Images

View File

@ -153,7 +153,7 @@
{% if entry.bibtex_show -%} {% if entry.bibtex_show -%}
<!-- Hidden bibtex block --> <!-- Hidden bibtex block -->
<div class="bibtex hidden"> <div class="bibtex hidden">
{% highlight bibtex %}{{ entry.bibtex }}{% endhighlight %} {% highlight bibtex %}{{ entry.bibtex | hideCustomBibtex }}{% endhighlight %}
</div> </div>
{%- endif %} {%- endif %}
</div> </div>

View File

@ -0,0 +1,15 @@
module Jekyll
module HideCustomBibtex
def hideCustomBibtex(input)
keywords = @context.registers[:site].config['filtered_bibtex_keywords']
keywords.each do |keyword|
input = input.gsub(/^.*#{keyword}.*$\n/, '')
end
return input
end
end
end
Liquid::Template.register_filter(Jekyll::HideCustomBibtex)