Skip to content

Commit

Permalink
Export authors into an array under entry.author_array
Browse files Browse the repository at this point in the history
This permits easier iteration over an arbitrary number of authors.
  • Loading branch information
IgnoredAmbience committed Feb 2, 2016
1 parent 2932f98 commit a2c59ac
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions features/bibtex.feature
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,33 @@ Feature: BibTeX
And the "_site/scholar.html" file should exist
And I should see "<abbr>1 book \[ruby\]</abbr>Matsumoto" in "_site/scholar.html"

@tags @bibliography @config @template
Scenario: Simple Bibliography With Custom Template
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
| bibliography_template | <abbr>{{index}} {{entry.type}} [{{key}}]</abbr>{{entry.author_array[1].last}} |
And I have a "_bibliography" directory
And I have a file "_bibliography/references.bib":
"""
@book{ruby,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
"""
And I have a page "scholar.html":
"""
---
---
{% bibliography -f references %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/scholar.html" file should exist
And I should see "<abbr>1 book \[ruby\]</abbr>Matsumoto" in "_site/scholar.html"

@tags @filter
Scenario: Filtered Bibliography Loaded From Default Directory
Given I have a scholar configuration with:
Expand Down
4 changes: 4 additions & 0 deletions lib/jekyll/scholar/utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,14 @@ def liquidify(entry)
e[key.to_s] = value.to_s

if value.is_a?(BibTeX::Names)
e["#{key}_array"] = arr = []
value.each.with_index do |name, idx|
parts = {}
name.each_pair do |k, v|
e["#{key}_#{idx}_#{k}"] = v.to_s
parts[k.to_s] = v.to_s
end
arr << parts
end
end
end
Expand Down

0 comments on commit a2c59ac

Please sign in to comment.