Commit f8e83b19 authored by Sylvester Keil's avatar Sylvester Keil

fix #66 citation numbers

parent e30c4da9
......@@ -215,6 +215,36 @@ Feature: Citations
And the "_site/scholar.html" file should exist
And I should see "\[1\], \[2\]" in "_site/scholar.html"
@tags @cite @citation_number
Scenario: Multiple citations of the same item using citation numbers
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
| bibliography | my_references |
| style | ieee |
And I have a "_bibliography" directory
And I have a file "_bibliography/my_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":
"""
---
---
{% cite ruby %}
{% cite ruby %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/scholar.html" file should exist
And I should see "\[1\]" in "_site/scholar.html"
And I should not see "\[2\]" in "_site/scholar.html"
@tags @cite @variables
Scenario: A Simple Citation using liquid variables
Given I have a scholar configuration with:
......
......@@ -322,7 +322,7 @@ module Jekyll
renderer.render items.zip(locators).map { |entry, locator|
cited_keys << entry.key
item = citation_item_for entry, citation_number
item = citation_item_for entry, citation_number(entry.key)
item.locator = locator
item
......@@ -345,10 +345,8 @@ module Jekyll
context['cited'] ||= []
end
def citation_number
number = context['citation_number'] || 1
context['citation_number'] = number.succ
number
def citation_number(key)
(context['citation_numbers'] ||= {})[key] ||= cited_keys.length
end
def cite(keys)
......
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