Commit c7fba8be authored by Sylvester Keil's avatar Sylvester Keil

Add --raw_bibtex option

See #117
parent 953d112d
...@@ -270,3 +270,26 @@ Feature: BibTeX ...@@ -270,3 +270,26 @@ Feature: BibTeX
Then the _site directory should exist Then the _site directory should exist
And the "_site/scholar.html" file should exist And the "_site/scholar.html" file should exist
And I should see "<i>The Ruby Programming Language</i>. O’Reilly Media, 2008" in "_site/scholar.html" And I should see "<i>The Ruby Programming Language</i>. O’Reilly Media, 2008" in "_site/scholar.html"
@tags @bibliography @config @template
Scenario: Raw bibtex template
Given I have a scholar configuration with:
| key | value |
| bibliography_template | "{{entry.bibtex}}" |
And I have a "_bibliography" directory
And I have a file "_bibliography/references.bib":
"""
@book{ruby,
title = {The Ruby Programming Language}
}
"""
And I have a page "scholar.html":
"""
---
---
{% bibliography -f references --raw_bibtex %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/scholar.html" file should exist
And I should see "{%raw%}@book" in "_site/scholar.html"
...@@ -70,7 +70,6 @@ Feature: Cited-only Bibliographies ...@@ -70,7 +70,6 @@ Feature: Cited-only Bibliographies
And I should not see "<i>The Ruby Programming Language</i>" in "_site/scholar.html" And I should not see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
And I should not see "<i>Smalltalk Best Practice Patterns</i>" in "_site/scholar.html" And I should not see "<i>Smalltalk Best Practice Patterns</i>" in "_site/scholar.html"
@wip
Scenario: Cited items with prefix Scenario: Cited items with prefix
Given I have a scholar configuration with: Given I have a scholar configuration with:
| key | value | | key | value |
......
...@@ -209,7 +209,7 @@ Feature: Details ...@@ -209,7 +209,7 @@ Feature: Details
And the "_site/bibliography/august.html" file should exist And the "_site/bibliography/august.html" file should exist
And I should see "month = aug" in "_site/bibliography/august.html" And I should see "month = aug" in "_site/bibliography/august.html"
@generators @parse_months @wip @generators @parse_months
Scenario: Month parsing can be turned off Scenario: Month parsing can be turned off
Given I have a scholar configuration with: Given I have a scholar configuration with:
| key | value | | key | value |
......
...@@ -80,9 +80,13 @@ module Jekyll ...@@ -80,9 +80,13 @@ module Jekyll
opts.on('-T', '--template TEMPLATE') do |template| opts.on('-T', '--template TEMPLATE') do |template|
@bibliography_template = template @bibliography_template = template
end end
opts.on('-R', '--raw_bibtex') do |raw_bibtex|
@raw_bibtex = raw_bibtex
end
end end
argv = arguments.split(/(\B-[cCfqptTslomA]|\B--(?:cited(_in_order)?|file|query|prefix|text|style|template|locator|offset|max|suppress_author|))/) argv = arguments.split(/(\B-[cCfqptTslomAR]|\B--(?:cited(_in_order)?|file|query|prefix|text|style|template|locator|offset|max|suppress_author|raw_bibtex|))/)
parser.parse argv.map(&:strip).reject(&:empty?) parser.parse argv.map(&:strip).reject(&:empty?)
end end
...@@ -177,6 +181,10 @@ module Jekyll ...@@ -177,6 +181,10 @@ module Jekyll
!!@suppress_author !!@suppress_author
end end
def raw_bibtex?
!!@raw_bibtex
end
def repository? def repository?
!config['repository'].nil? && !config['repository'].empty? !config['repository'].nil? && !config['repository'].empty?
end end
...@@ -329,6 +337,10 @@ module Jekyll ...@@ -329,6 +337,10 @@ module Jekyll
e['bibtex'] = tmp.to_s e['bibtex'] = tmp.to_s
end end
if raw_bibtex?
e['bibtex'] = "{%raw%}#{e['bibtex']}{%endraw%}"
end
entry.fields.each do |key, value| entry.fields.each do |key, value|
value = value.convert(*bibtex_filters) unless bibtex_filters.empty? value = value.convert(*bibtex_filters) unless bibtex_filters.empty?
e[key.to_s] = value.to_s e[key.to_s] = value.to_s
......
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