Commit 30bedf1e authored by Sylvester Keil's avatar Sylvester Keil

expose index to bibliography template #19

parent 50c4ded7
......@@ -93,9 +93,9 @@ Feature: BibTeX
@tags @bibliography @config
Scenario: Simple Bibliography With Custom Template
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
| bibliography_template | <abbr>[%{key}]</abbr>%{reference} |
| key | value |
| source | ./_bibliography |
| bibliography_template | <abbr>%{index} [%{key}]</abbr>%{reference} |
And I have a "_bibliography" directory
And I have a file "_bibliography/references.bib":
"""
......@@ -116,7 +116,7 @@ Feature: BibTeX
Then the _site directory should exist
And the "_site/scholar.html" file should exist
And I should see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
And I should see "<abbr>\[ruby\]</abbr><span" in "_site/scholar.html"
And I should see "<abbr>1 \[ruby\]</abbr><span" in "_site/scholar.html"
@tags @filter
Scenario: Filtered Bibliography Loaded From Default Directory
......
......@@ -23,8 +23,8 @@ module Jekyll
end
end
references.map! do |entry|
reference = bibliography_tag entry
bibliography = references.map.with_index { |entry, index|
reference = bibliography_tag(entry, index + 1)
if generate_details?
reference << link_to(details_link_for(entry),
......@@ -32,9 +32,9 @@ module Jekyll
end
content_tag :li, reference
end
}.join("\n")
content_tag :ol, references.join("\n"), :class => config['bibliography_class']
content_tag :ol, bibliography, :class => config['bibliography_class']
end
end
......
......@@ -102,12 +102,13 @@ module Jekyll
config['bibliography_template'] || '%{reference}'
end
def bibliography_tag(entry)
def bibliography_tag(entry, index)
return missing_reference unless entry
bibliography_template % {
:reference => reference_tag(entry),
:key => entry.key
:key => entry.key,
:index => index
}
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