Commit a2c59ac7 authored by Thomas Wood's avatar Thomas Wood

Export authors into an array under entry.author_array

This permits easier iteration over an arbitrary number of authors.
parent 2932f98b
...@@ -142,6 +142,33 @@ Feature: BibTeX ...@@ -142,6 +142,33 @@ Feature: BibTeX
And the "_site/scholar.html" file should exist And the "_site/scholar.html" file should exist
And I should see "<abbr>1 book \[ruby\]</abbr>Matsumoto" in "_site/scholar.html" 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 @tags @filter
Scenario: Filtered Bibliography Loaded From Default Directory Scenario: Filtered Bibliography Loaded From Default Directory
Given I have a scholar configuration with: Given I have a scholar configuration with:
......
...@@ -485,10 +485,14 @@ module Jekyll ...@@ -485,10 +485,14 @@ module Jekyll
e[key.to_s] = value.to_s e[key.to_s] = value.to_s
if value.is_a?(BibTeX::Names) if value.is_a?(BibTeX::Names)
e["#{key}_array"] = arr = []
value.each.with_index do |name, idx| value.each.with_index do |name, idx|
parts = {}
name.each_pair do |k, v| name.each_pair do |k, v|
e["#{key}_#{idx}_#{k}"] = v.to_s e["#{key}_#{idx}_#{k}"] = v.to_s
parts[k.to_s] = v.to_s
end end
arr << parts
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment