Skip to content

Commit 79a1dfa

Browse files
tonnesfnpecey
authored andcommitted
Added bibtex filter to hide custom bibtex keywords from bib file output (alshedivat#652)
1 parent 3c936e5 commit 79a1dfa

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

_config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ scholar:
233233

234234
query: "@*"
235235

236+
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
236237

237238
# -----------------------------------------------------------------------------
238239
# Responsive WebP Images

_layouts/bib.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
{% if entry.bibtex_show -%}
154154
<!-- Hidden bibtex block -->
155155
<div class="bibtex hidden">
156-
{% highlight bibtex %}{{ entry.bibtex }}{% endhighlight %}
156+
{% highlight bibtex %}{{ entry.bibtex | hideCustomBibtex }}{% endhighlight %}
157157
</div>
158158
{%- endif %}
159159
</div>

_plugins/hideCustomBibtex.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module Jekyll
2+
module HideCustomBibtex
3+
def hideCustomBibtex(input)
4+
keywords = @context.registers[:site].config['filtered_bibtex_keywords']
5+
6+
keywords.each do |keyword|
7+
input = input.gsub(/^.*#{keyword}.*$\n/, '')
8+
end
9+
10+
return input
11+
end
12+
end
13+
end
14+
15+
Liquid::Template.register_filter(Jekyll::HideCustomBibtex)

0 commit comments

Comments
 (0)