jekyll-scholar 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 082fd7a25a1d8bec380e5311248c00a86680f5bc
4
- data.tar.gz: 34123cf9d4f87b7fad1d8d2312fa727df7ba3cd2
3
+ metadata.gz: c7d2bffb292d27ff2150ac22f4f08c16725933e1
4
+ data.tar.gz: df29da3988760f7cf35edfa13c147ff1a11b8a1d
5
5
  SHA512:
6
- metadata.gz: 41d977833e021bf6d06e42ab6eef3650c07eab7fd1ffdcdaf02595df83956a5cc238ca743f8847f65fef3082f0dec9f14efa4999832599835ca41c19c26ca21f
7
- data.tar.gz: 503c8db545f09233ea25239705778d3c724dc4180c21201672e574b00c0b5b40d7563d8ce2cde705204c469811dd0437dafe437add161fdabd137bbf80071cde
6
+ metadata.gz: a3e5ad5b114cc0b8c2ac03c79a3154964c32bc81f72d1187e304c0028e596775fd260ca674037cf59e9038f6b25e989d4f2a29b0ba9e52e8b57df2d7b6c9aa15
7
+ data.tar.gz: e4c94ec420ef8e67cd4fdbabf188dc79a08930b53461c151cb00a203fa680604f3e11f4e3926feb87eecb9ee70b35d3abae32d64cde1eb55d8d52d11aa116de3
@@ -0,0 +1,2 @@
1
+ service_name: travis-ci
2
+
data/.gitignore CHANGED
@@ -2,3 +2,4 @@ Gemfile.lock
2
2
  demo
3
3
  **/*.swp
4
4
  .bundle
5
+ coverage
@@ -0,0 +1,4 @@
1
+ SimpleCov.start do
2
+ add_filter 'features/'
3
+ end
4
+
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  bundler_args: --without debug
3
+ script: bundle exec rake test_with_coveralls
3
4
  rvm:
4
5
  - 2.1.0
5
6
  - 2.0.0
data/Gemfile CHANGED
@@ -1,22 +1,26 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- group 'development' do
4
+ group :development do
5
+ gem 'minitest', '< 5.0'
5
6
  gem 'rake'
6
7
  gem 'redgreen', '~> 1.2'
7
- gem 'shoulda', '~> 3.3.2'
8
- gem 'rr', '~> 1.0.5'
9
- gem 'cucumber', '~> 1.2.1'
8
+ gem 'shoulda', '~> 3.5'
9
+ gem 'rr', '~> 1.1'
10
+ gem 'cucumber', '=1.3.10'
10
11
  gem 'RedCloth', '~> 4.2'
11
12
  gem 'rdiscount', '~> 1.6'
12
- gem 'redcarpet', '~> 2.2.2'
13
+ gem 'redcarpet', '~> 3.0'
13
14
  gem 'launchy', '~> 2.1.2'
14
15
 
15
16
  gem 'unicode_utils'
17
+
18
+ gem 'simplecov', '~>0.8', :require => false
19
+ gem 'rubinius-coverage', :platform => :rbx
20
+ gem 'coveralls', :require => false
16
21
  end
17
22
 
18
23
  group :debug do
19
- gem 'ruby-debug', :require => false, :platform => :jruby
20
24
  gem 'debugger', '~>1.6', :require => false, :platform => :mri
21
25
  gem 'rubinius-compiler', '~>2.0', :require => false, :platform => :rbx
22
26
  gem 'rubinius-debugger', '~>2.0', :require => false, :platform => :rbx
data/README.md CHANGED
@@ -10,7 +10,8 @@ For additional features you may also want to take a look at
10
10
  [jekyll-scholar-extras](https://github.com/jgoodall/jekyll-scholar-extras).
11
11
 
12
12
  [![Build Status](https://travis-ci.org/inukshuk/jekyll-scholar.png?branch=master)](https://travis-ci.org/inukshuk/jekyll-scholar)
13
-
13
+ [![Coverage Status](https://coveralls.io/repos/inukshuk/jekyll-scholar/badge.png)](https://coveralls.io/r/inukshuk/jekyll-scholar)
14
+ [![Dependency Status](https://gemnasium.com/inukshuk/jekyll-scholar.png)](https://gemnasium.com/inukshuk/jekyll-scholar)
14
15
 
15
16
  Installation
16
17
  ------------
@@ -253,6 +254,23 @@ For example, this could be rendered as:
253
254
  </cite>
254
255
  </blockquote>
255
256
 
257
+ #### Multiple citation
258
+
259
+ You can cite multiple items in a single citation by referencing all ids
260
+ of the items you wish to quote separated by spaces. For example,
261
+ `{% cite ruby microscope %}` would produce a cite tag like:
262
+
263
+ <a href="#ruby">(Flanagan, D. &amp; Matsumoto, Y. 2008; Shaughnessy, P. 2013)</a>
264
+
265
+ #### Page numbers and locators
266
+
267
+ If you would like to add page numbers to your citation, you can use the
268
+ `-l` or `--locator` option. For example, `{% cite ruby -l 23-5 %}` would
269
+ produce a citation like `(Matsumoto, Y., 2008, pp. 23-5)`.
270
+
271
+ When quoting multiple items (see above) you can add multiple locators after
272
+ the list of ids. For example, `{% cite ruby microscope -l 2 -l 24 & 32 %}`.
273
+
256
274
  #### Displaying formatted references
257
275
 
258
276
  If you want to display the full formatted reference entry, you can use the
@@ -336,7 +354,7 @@ document.
336
354
  ### File Repositories
337
355
 
338
356
  File repository support was added to Jekyll-Scholar starting at version
339
- 4.0. Currently, if you have a folder in your site that contains PDF or
357
+ 2.0. Currently, if you have a folder in your site that contains PDF or
340
358
  Postscript files of your papers, you can use the configuration option
341
359
  `repository` to indicate this directory. When generating bibliographies,
342
360
  Jekyll-Scholar will look in that folder to see if it contains a filename
data/Rakefile CHANGED
@@ -15,6 +15,10 @@ Cucumber::Rake::Task.new(:features)
15
15
 
16
16
  task :default => [:features]
17
17
 
18
+ require 'coveralls/rake/task'
19
+ Coveralls::RakeTask.new
20
+ task :test_with_coveralls => [:features, 'coveralls:push']
21
+
18
22
  task :release do |t|
19
23
  system "gem build jekyll-scholar.gemspec"
20
24
  system "git tag v#{Jekyll::Scholar::VERSION}"
@@ -24,7 +24,6 @@ Feature: BibTeX
24
24
  And the "_site/references.html" file should exist
25
25
  And I should see "<i>The Ruby Programming Language</i>" in "_site/references.html"
26
26
 
27
- @converters
28
27
  Scenario: Markdown Formatted Bibliography
29
28
  Given I have a scholar configuration with:
30
29
  | key | value |
@@ -205,7 +204,7 @@ Feature: BibTeX
205
204
  """
206
205
  ---
207
206
  ---
208
- {% bibliography --style mla %}
207
+ {% bibliography --style modern-language-association %}
209
208
  """
210
209
  When I run jekyll
211
210
  Then the _site directory should exist
@@ -111,3 +111,107 @@ Feature: Citations
111
111
  Then the _site directory should exist
112
112
  And the "_site/scholar.html" file should exist
113
113
  And I should see "#a-ruby" in "_site/scholar.html"
114
+
115
+ @tags @cite
116
+ Scenario: Multiple Citations
117
+ Given I have a scholar configuration with:
118
+ | key | value |
119
+ | source | ./_bibliography |
120
+ | bibliography | my_references |
121
+ And I have a "_bibliography" directory
122
+ And I have a file "_bibliography/my_references.bib":
123
+ """
124
+ @book{ruby,
125
+ title = {The Ruby Programming Language},
126
+ author = {Flanagan, David and Matsumoto, Yukihiro},
127
+ year = {2008},
128
+ publisher = {O'Reilly Media}
129
+ }
130
+
131
+ @book{microscope,
132
+ title = {Ruby Under a Microscope},
133
+ author = {Pat Shaughnessy},
134
+ year = {2013},
135
+ publisher = {No Starch Press}
136
+ }
137
+ """
138
+ And I have a page "scholar.html":
139
+ """
140
+ ---
141
+ ---
142
+ {% cite ruby microscope %}
143
+ """
144
+ When I run jekyll
145
+ Then the _site directory should exist
146
+ And the "_site/scholar.html" file should exist
147
+ And I should see "Flanagan &amp; Matsumoto, 2008; Shaughnessy, 2013" in "_site/scholar.html"
148
+
149
+ @tags @cite @locator
150
+ Scenario: Multiple Citations with locators
151
+ Given I have a scholar configuration with:
152
+ | key | value |
153
+ | source | ./_bibliography |
154
+ | bibliography | my_references |
155
+ And I have a "_bibliography" directory
156
+ And I have a file "_bibliography/my_references.bib":
157
+ """
158
+ @book{ruby,
159
+ title = {The Ruby Programming Language},
160
+ author = {Flanagan, David and Matsumoto, Yukihiro},
161
+ year = {2008},
162
+ publisher = {O'Reilly Media}
163
+ }
164
+
165
+ @book{microscope,
166
+ title = {Ruby Under a Microscope},
167
+ author = {Pat Shaughnessy},
168
+ year = {2013},
169
+ publisher = {No Starch Press}
170
+ }
171
+ """
172
+ And I have a page "scholar.html":
173
+ """
174
+ ---
175
+ ---
176
+ {% cite ruby microscope -l 2-3 --locator 23 & 42 %}
177
+ """
178
+ When I run jekyll
179
+ Then the _site directory should exist
180
+ And the "_site/scholar.html" file should exist
181
+ And I should see "Matsumoto, 2008, pp. 2-3; Shaughnessy, 2013, pp. 23 &amp; 42" in "_site/scholar.html"
182
+
183
+ @tags @cite @citation_number
184
+ Scenario: Multiple citations using citation numbers
185
+ Given I have a scholar configuration with:
186
+ | key | value |
187
+ | source | ./_bibliography |
188
+ | bibliography | my_references |
189
+ | style | ieee |
190
+ And I have a "_bibliography" directory
191
+ And I have a file "_bibliography/my_references.bib":
192
+ """
193
+ @book{ruby,
194
+ title = {The Ruby Programming Language},
195
+ author = {Flanagan, David and Matsumoto, Yukihiro},
196
+ year = {2008},
197
+ publisher = {O'Reilly Media}
198
+ }
199
+
200
+ @book{microscope,
201
+ title = {Ruby Under a Microscope},
202
+ author = {Pat Shaughnessy},
203
+ year = {2013},
204
+ publisher = {No Starch Press}
205
+ }
206
+ """
207
+ And I have a page "scholar.html":
208
+ """
209
+ ---
210
+ ---
211
+ {% cite ruby microscope %}
212
+ """
213
+ When I run jekyll
214
+ Then the _site directory should exist
215
+ And the "_site/scholar.html" file should exist
216
+ And I should see "\[1\], \[2\]" in "_site/scholar.html"
217
+
@@ -0,0 +1,72 @@
1
+ Feature: Cited-only Bibliographies
2
+ As a scholar who likes to blog
3
+ I want to cite references on my website
4
+ And generate bibliographies for the cited items
5
+
6
+ Scenario: Cited-only references from a single bibliography
7
+ Given I have a scholar configuration with:
8
+ | key | value |
9
+ | source | ./_bibliography |
10
+ And I have a "_bibliography" directory
11
+ And I have a file "_bibliography/references.bib":
12
+ """
13
+ @book{ruby,
14
+ title = {The Ruby Programming Language},
15
+ author = {Flanagan, David and Matsumoto, Yukihiro},
16
+ year = {2008},
17
+ publisher = {O'Reilly Media}
18
+ },
19
+ @book{smalltalk,
20
+ title = {Smalltalk Best Practice Patterns},
21
+ author = {Kent Beck},
22
+ year = {1996},
23
+ publisher = {Prentice Hall}
24
+ }
25
+
26
+ """
27
+ And I have a page "scholar.html":
28
+ """
29
+ ---
30
+ ---
31
+ {% cite smalltalk %}
32
+ {% bibliography --cited %}
33
+ """
34
+ When I run jekyll
35
+ Then the _site directory should exist
36
+ And the "_site/scholar.html" file should exist
37
+ And I should not see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
38
+ And I should see "<i>Smalltalk Best Practice Patterns</i>" in "_site/scholar.html"
39
+
40
+ Scenario: No-cited items result in empty bibliography
41
+ Given I have a scholar configuration with:
42
+ | key | value |
43
+ | source | ./_bibliography |
44
+ And I have a "_bibliography" directory
45
+ And I have a file "_bibliography/references.bib":
46
+ """
47
+ @book{ruby,
48
+ title = {The Ruby Programming Language},
49
+ author = {Flanagan, David and Matsumoto, Yukihiro},
50
+ year = {2008},
51
+ publisher = {O'Reilly Media}
52
+ },
53
+ @book{smalltalk,
54
+ title = {Smalltalk Best Practice Patterns},
55
+ author = {Kent Beck},
56
+ year = {1996},
57
+ publisher = {Prentice Hall}
58
+ }
59
+
60
+ """
61
+ And I have a page "scholar.html":
62
+ """
63
+ ---
64
+ ---
65
+ {% bibliography --cited %}
66
+ """
67
+ When I run jekyll
68
+ Then the _site directory should exist
69
+ And the "_site/scholar.html" file should exist
70
+ And I should not see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
71
+ And I should not see "<i>Smalltalk Best Practice Patterns</i>" in "_site/scholar.html"
72
+
@@ -0,0 +1,41 @@
1
+ Feature: BibTeX
2
+ As a scholar who likes to blog
3
+ I want to publish my BibTeX bibliography on my website
4
+ Based on multiple BibTeX files
5
+
6
+
7
+ Scenario: Multiple bibliography files
8
+ Given I have a scholar configuration with:
9
+ | key | value |
10
+ | source | ./_bibliography |
11
+ And I have a "_bibliography" directory
12
+ And I have a file "_bibliography/references1.bib":
13
+ """
14
+ @book{ruby,
15
+ title = {The Ruby Programming Language},
16
+ author = {Flanagan, David and Matsumoto, Yukihiro},
17
+ year = {2008},
18
+ publisher = {O'Reilly Media}
19
+ }
20
+ """
21
+ And I have a file "_bibliography/references2.bib":
22
+ """
23
+ @book{microscope,
24
+ title = {Ruby Under a Microscope},
25
+ author = {Pat Shaughnessy},
26
+ year = {2013},
27
+ publisher = {No Starch Press}
28
+ }
29
+ """
30
+ And I have a page "scholar.html":
31
+ """
32
+ ---
33
+ ---
34
+ {% bibliography -f references1 -f references2 %}
35
+ """
36
+ When I run jekyll
37
+ Then the _site directory should exist
38
+ And the "_site/scholar.html" file should exist
39
+ And I should see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
40
+ And I should see "<i>Ruby Under a Microscope</i>" in "_site/scholar.html"
41
+
@@ -1,16 +1,6 @@
1
- Before do
2
- FileUtils.rm_rf(TEST_DIR)
3
- FileUtils.mkdir(TEST_DIR)
4
- Dir.chdir(TEST_DIR)
5
- end
6
1
 
7
- After do
8
- Dir.chdir(TEST_DIR)
9
- FileUtils.rm_rf(TEST_DIR)
10
- end
11
-
12
2
  # Like "I have a foo file" but gives a yaml front matter so jekyll actually processes it
13
- Given /^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
3
+ Given(/^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/) do |file, key, value, text|
14
4
  File.open(file, 'w') do |f|
15
5
  f.write <<EOF
16
6
  ---
@@ -22,21 +12,21 @@ EOF
22
12
  end
23
13
  end
24
14
 
25
- Given /^I have an? "(.*)" file that contains "(.*)"$/ do |file, text|
15
+ Given(/^I have an? "(.*)" file that contains "(.*)"$/) do |file, text|
26
16
  File.open(file, 'w') do |f|
27
17
  f.write(text)
28
18
  f.close
29
19
  end
30
20
  end
31
21
 
32
- Given /^I have a configuration file with "(.*)" set to "(.*)"$/ do |key, value|
22
+ Given(/^I have a configuration file with "(.*)" set to "(.*)"$/) do |key, value|
33
23
  File.open('_config.yml', 'w') do |f|
34
24
  f.write("#{key}: #{value}\n")
35
25
  f.close
36
26
  end
37
27
  end
38
28
 
39
- Given /^I have a configuration file with:$/ do |table|
29
+ Given(/^I have a configuration file with:$/) do |table|
40
30
  File.open('_config.yml', 'w') do |f|
41
31
  table.hashes.each do |row|
42
32
  f.write("#{row["key"]}: #{row["value"]}\n")
@@ -45,28 +35,27 @@ Given /^I have a configuration file with:$/ do |table|
45
35
  end
46
36
  end
47
37
 
48
- When /^I run jekyll$/ do
38
+ When(/^I run jekyll$/) do
49
39
  run_jekyll
50
40
  end
51
41
 
52
- Then /^the (.*) directory should exist$/ do |dir|
42
+ Then(/^the (.*) directory should exist$/) do |dir|
53
43
  assert File.directory?(dir)
54
44
  end
55
45
 
56
- Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
57
- puts File.open(file).readlines.join
46
+ Then(/^I should see "(.*)" in "(.*)"$/) do |text, file|
58
47
  assert_match Regexp.new(text), File.open(file).readlines.join
59
48
  end
60
49
 
61
- Then /^I should not see "(.*)" in "(.*)"$/ do |text, file|
50
+ Then(/^I should not see "(.*)" in "(.*)"$/) do |text, file|
62
51
  assert !File.open(file).readlines.join.match(Regexp.new(text))
63
52
  end
64
53
 
65
54
 
66
- Then /^the "(.*)" file should exist$/ do |file|
55
+ Then(/^the "(.*)" file should exist$/) do |file|
67
56
  assert File.file?(file)
68
57
  end
69
58
 
70
- Then /^the "(.*)" file should not exist$/ do |file|
59
+ Then(/^the "(.*)" file should not exist$/) do |file|
71
60
  assert !File.exists?(file)
72
61
  end
@@ -1,15 +1,15 @@
1
1
 
2
- Given /^I have a "([^"]*)" directory/ do |dir|
2
+ Given(/^I have a "([^"]*)" directory/) do |dir|
3
3
  FileUtils.mkdir(dir)
4
4
  end
5
5
 
6
- Given /^I have a (?:page|file) "([^"]*)":$/ do |file, string|
6
+ Given(/^I have a (?:page|file) "([^"]*)":$/) do |file, string|
7
7
  File.open(file, 'w') do |f|
8
8
  f.write(string)
9
9
  end
10
10
  end
11
11
 
12
- Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table|
12
+ Given(/^I have a configuration file with "([^\"]*)" set to:$/) do |key, table|
13
13
  File.open('_config.yml', 'w') do |f|
14
14
  f.write("#{key}:\n")
15
15
  table.hashes.each do |row|
@@ -18,7 +18,7 @@ Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table|
18
18
  end
19
19
  end
20
20
 
21
- Given /^I have a scholar configuration with:$/ do |table|
21
+ Given(/^I have a scholar configuration with:$/) do |table|
22
22
  File.open('_config.yml', 'w') do |f|
23
23
  f.write("scholar:\n")
24
24
  table.hashes.each do |row|
@@ -28,7 +28,7 @@ Given /^I have a scholar configuration with:$/ do |table|
28
28
  end
29
29
 
30
30
 
31
- Then /^"(.*)" should come before "(.*)" in "(.*)"$/ do |p1, p2, file|
31
+ Then(/^"(.*)" should come before "(.*)" in "(.*)"$/) do |p1, p2, file|
32
32
  data = File.open(file).readlines.join('')
33
33
 
34
34
  m1 = data.match(p1)
@@ -1,7 +1,9 @@
1
- require 'rr'
2
- require 'test/unit'
3
-
4
- require 'jekyll/scholar'
1
+ begin
2
+ require 'simplecov'
3
+ require 'coveralls' if ENV['CI']
4
+ rescue LoadError
5
+ # ignore
6
+ end
5
7
 
6
8
  begin
7
9
  require 'debugger'
@@ -9,6 +11,10 @@ rescue LoadError
9
11
  # ignore
10
12
  end
11
13
 
14
+ require 'rr'
15
+ require 'test/unit'
16
+
17
+ require 'jekyll/scholar'
12
18
 
13
19
  World do
14
20
  include Test::Unit::Assertions
@@ -17,10 +23,10 @@ end
17
23
  TEST_DIR = File.join('/', 'tmp', 'jekyll')
18
24
 
19
25
  def run_jekyll(options = {})
20
-
26
+
21
27
  options['source'] ||= TEST_DIR
22
28
  options['destination'] ||= File.join(TEST_DIR, '_site')
23
-
29
+
24
30
  options = Jekyll.configuration(options)
25
31
 
26
32
  site = Jekyll::Site.new(options)
@@ -0,0 +1,10 @@
1
+ Before do
2
+ FileUtils.rm_rf(TEST_DIR) if File.exist?(TEST_DIR)
3
+ FileUtils.mkdir_p(TEST_DIR)
4
+ Dir.chdir(TEST_DIR)
5
+ end
6
+
7
+ After do
8
+ FileUtils.rm_rf(TEST_DIR) if File.exist?(TEST_DIR)
9
+ end
10
+
@@ -26,8 +26,9 @@ Gem::Specification.new do |s|
26
26
  s.rubyforge_project = s.name
27
27
 
28
28
  s.add_runtime_dependency('jekyll', '~> 1.0')
29
- s.add_runtime_dependency('citeproc-ruby', '~> 0.0.6')
30
- s.add_runtime_dependency('bibtex-ruby', '~> 2.3')
29
+ s.add_runtime_dependency('citeproc-ruby', '~> 1.0')
30
+ s.add_runtime_dependency('csl-styles', '~> 1.0')
31
+ s.add_runtime_dependency('bibtex-ruby', '~> 3.0')
31
32
 
32
33
  s.files = `git ls-files`.split("\n")
33
34
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -4,7 +4,8 @@ require 'jekyll'
4
4
  require 'optparse'
5
5
 
6
6
  require 'bibtex'
7
- require 'citeproc'
7
+ require 'citeproc/ruby'
8
+ require 'csl/styles'
8
9
 
9
10
  require 'jekyll/scholar/version'
10
11
  require 'jekyll/scholar/defaults'
@@ -1,45 +1,46 @@
1
1
  module Jekyll
2
2
  class Scholar
3
3
  class BibTeXConverter < Converter
4
+ include Scholar::Utilities
5
+
4
6
  safe true
5
7
  priority :highest
6
8
 
7
- attr_reader :config
8
-
9
+ attr_reader :config
10
+
9
11
  @pattern = (/bib(tex)?$/i).freeze
10
12
  @extension = '.html'.freeze
11
-
12
- class << self
13
- attr_reader :pattern, :extension
14
- end
15
-
13
+
14
+ class << self
15
+ attr_reader :pattern, :extension
16
+ end
17
+
16
18
  def initialize(config = {})
17
19
  super
18
20
  @config['scholar'] = Scholar.defaults.merge(@config['scholar'] || {})
19
21
  @markdown = Jekyll::Converters::Markdown.new(config)
20
22
  end
21
-
23
+
22
24
  def matches(extension)
23
- extension =~ BibTeXConverter.pattern
24
- end
25
-
25
+ extension =~ BibTeXConverter.pattern
26
+ end
27
+
26
28
  def output_ext(extension)
27
- BibTeXConverter.extension
28
- end
29
-
29
+ BibTeXConverter.extension
30
+ end
31
+
30
32
  def convert(content)
31
- content = BibTeX.parse(content, :strict => true, :include => [:meta_content], :filter => [:latex]).map do |b|
33
+ content = BibTeX.parse(content, :strict => true, :include => [:meta_content], :filter => [:latex]).map do |b|
32
34
  if b.respond_to?(:to_citeproc)
33
- CiteProc.process b.to_citeproc, :style => config['style'],
34
- :locale => config['locale'], :format => 'html'
35
+ render_bibliography b
35
36
  else
36
- b.is_a?(BibTeX::MetaContent) ? b.to_s : ''
37
+ b.is_a?(BibTeX::MetaContent) ? b.to_s : ''
37
38
  end
38
39
  end
39
40
 
40
41
  @markdown.convert(content.join("\n"))
41
42
  end
42
-
43
+
43
44
  end
44
45
  end
45
- end
46
+ end
@@ -38,15 +38,6 @@ module Jekyll
38
38
  end
39
39
  end
40
40
 
41
- private
42
-
43
- def citeproc
44
- @citeproc ||= CiteProc::Processor.new do |p|
45
- p.style = config['style']
46
- p.format = 'html'
47
- p.locale = config['locale']
48
- end
49
- end
50
41
  end
51
42
  end
52
43
 
@@ -10,14 +10,14 @@ module Jekyll
10
10
  super
11
11
 
12
12
  @config = Scholar.defaults.dup
13
- @key, arguments = arguments.strip.split(/\s+/, 2)
13
+ @keys, arguments = split_arguments(arguments)
14
14
 
15
15
  optparse(arguments)
16
16
  end
17
17
 
18
18
  def render(context)
19
19
  set_context_to context
20
- cite key
20
+ cite keys
21
21
  end
22
22
 
23
23
  end
@@ -25,4 +25,4 @@ module Jekyll
25
25
  end
26
26
  end
27
27
 
28
- Liquid::Template.register_tag('cite', Jekyll::Scholar::CiteTag)
28
+ Liquid::Template.register_tag('cite', Jekyll::Scholar::CiteTag)
@@ -8,14 +8,16 @@ module Jekyll
8
8
  super
9
9
 
10
10
  @config = Scholar.defaults.dup
11
- @key, arguments = arguments.strip.split(/\s+/, 2)
11
+ @keys, arguments = split_arguments arguments
12
12
 
13
13
  optparse(arguments)
14
14
  end
15
15
 
16
16
  def render(context)
17
17
  set_context_to context
18
- cite_details key, text
18
+ keys.map { |key|
19
+ cite_details key, text
20
+ }.join("\n")
19
21
  end
20
22
  end
21
23
 
@@ -3,32 +3,32 @@ module Jekyll
3
3
 
4
4
  class QuoteTag < Liquid::Block
5
5
  include Scholar::Utilities
6
-
6
+
7
7
  attr_reader :pages
8
-
8
+
9
9
  def initialize(tag_name, arguments, tokens)
10
10
  super
11
-
11
+
12
12
  @config = Scholar.defaults.dup
13
- @key, arguments = arguments.strip.split(/\s+/, 2)
13
+ @keys, arguments = split_arguments arguments
14
14
  end
15
15
 
16
16
  def render(context)
17
17
  set_context_to context
18
-
18
+
19
19
  quote = super.strip.gsub(/\n\n/, '</p><p>').gsub(/\n/, '<br/>')
20
20
  quote = content_tag :p, quote
21
-
22
- citation = cite key
23
-
21
+
22
+ citation = cite keys
23
+
24
24
  quote << content_tag(:cite, citation)
25
-
25
+
26
26
  content_tag :blockquote, quote
27
27
  end
28
-
28
+
29
29
  end
30
-
30
+
31
31
  end
32
32
  end
33
33
 
34
- Liquid::Template.register_tag('quote', Jekyll::Scholar::QuoteTag)
34
+ Liquid::Template.register_tag('quote', Jekyll::Scholar::QuoteTag)
@@ -8,16 +8,16 @@ module Jekyll
8
8
  super
9
9
 
10
10
  @config = Scholar.defaults.dup
11
- @key, arguments = arguments.strip.split(/\s+/, 2)
11
+ @keys, arguments = split_arguments arguments
12
12
 
13
13
  optparse(arguments)
14
14
  end
15
15
 
16
16
  def render(context)
17
17
  set_context_to context
18
- reference_tag bibliography[key]
19
- rescue
20
- "(#{key})"
18
+ keys.map { |key|
19
+ reference_tag bibliography[key]
20
+ }.join("\n")
21
21
  end
22
22
  end
23
23
 
@@ -1,13 +1,31 @@
1
1
  module Jekyll
2
2
  class Scholar
3
3
 
4
+ # Load styles into static memory.
5
+ # They should be thread safe as long as they are
6
+ # treated as being read-only.
7
+ STYLES = Hash.new do |h, k|
8
+ h[k.to_s] = CSL::Style.load k
9
+ end
10
+
11
+
4
12
  # Utility methods used by several Scholar plugins. The methods in this
5
- # module may depend on the presence of #config, #bibtex_file, and
13
+ # module may depend on the presence of #config, #bibtex_files, and
6
14
  # #site readers
7
15
  module Utilities
8
16
 
9
- attr_reader :bibtex_file, :config, :site, :query,
10
- :context, :prefix, :key, :text
17
+ attr_reader :config, :site, :query,
18
+ :context, :prefix, :keys, :text
19
+
20
+ def split_arguments(arguments)
21
+
22
+ tokens = arguments.strip.split(/\s+/)
23
+
24
+ args = tokens.take_while { |a| !a.start_with?('-') }
25
+ opts = (tokens - args).join(' ')
26
+
27
+ [args, opts]
28
+ end
11
29
 
12
30
  def optparse(arguments)
13
31
  return if arguments.nil? || arguments.empty?
@@ -18,7 +36,8 @@ module Jekyll
18
36
  end
19
37
 
20
38
  opts.on('-f', '--file FILE') do |file|
21
- @bibtex_file = file
39
+ @bibtex_files ||= []
40
+ @bibtex_files << file
22
41
  end
23
42
 
24
43
  opts.on('-q', '--query QUERY') do |query|
@@ -33,6 +52,10 @@ module Jekyll
33
52
  @text = text
34
53
  end
35
54
 
55
+ opts.on('-l', '--locator LOCATOR') do |locator|
56
+ locators << locator
57
+ end
58
+
36
59
  opts.on('-s', '--style STYLE') do |style|
37
60
  @style = style
38
61
  end
@@ -42,11 +65,24 @@ module Jekyll
42
65
  end
43
66
  end
44
67
 
45
- argv = arguments.split(/(\B-[cfqptTs]|\B--(?:cited|file|query|prefix|text|style|template|))/)
68
+ argv = arguments.split(/(\B-[cfqptTsl]|\B--(?:cited|file|query|prefix|text|style|template|locator|))/)
46
69
 
47
70
  parser.parse argv.map(&:strip).reject(&:empty?)
48
71
  end
49
72
 
73
+ def locators
74
+ @locators ||= []
75
+ end
76
+
77
+ def bibtex_files
78
+ @bibtex_files ||= [config['bibliography']]
79
+ end
80
+
81
+ # :nodoc: backwards compatibility
82
+ def bibtex_file
83
+ bibtex_files[0]
84
+ end
85
+
50
86
  def bibtex_options
51
87
  config['bibtex_options'] ||= {}
52
88
  end
@@ -55,13 +91,23 @@ module Jekyll
55
91
  config['bibtex_filters'] ||= []
56
92
  end
57
93
 
94
+ def bibtex_paths
95
+ @bibtex_paths ||= bibtex_files.map { |file|
96
+ extend_path file
97
+ }
98
+ end
99
+
100
+ # :nodoc: backwards compatibility
58
101
  def bibtex_path
59
- @bibtex_path ||= extend_path(bibtex_file)
102
+ bibtex_paths[0]
60
103
  end
61
104
 
62
105
  def bibliography
63
106
  unless @bibliography
64
- @bibliography = BibTeX.open(bibtex_path, bibtex_options)
107
+ @bibliography = BibTeX.parse(
108
+ bibtex_paths.reduce('') { |s, p| s << IO.read(p) },
109
+ bibtex_options
110
+ )
65
111
  @bibliography.replace_strings if replace_strings?
66
112
  end
67
113
 
@@ -120,12 +166,11 @@ module Jekyll
120
166
  p
121
167
  end
122
168
 
123
- def reference_tag(entry)
169
+ def reference_tag(entry, index = nil)
124
170
  return missing_reference unless entry
125
171
 
126
172
  entry = entry.convert(*bibtex_filters) unless bibtex_filters.empty?
127
- reference = CiteProc.process entry.to_citeproc,
128
- :style => style, :locale => config['locale'], :format => 'html'
173
+ reference = render_bibliography entry, index
129
174
 
130
175
  content_tag reference_tagname, reference,
131
176
  :id => [prefix, entry.key].compact.join('-')
@@ -167,7 +212,7 @@ module Jekyll
167
212
 
168
213
  liquid_template.render({
169
214
  'entry' => liquidify(entry),
170
- 'reference' => reference_tag(entry),
215
+ 'reference' => reference_tag(entry, index),
171
216
  'key' => entry.key,
172
217
  'type' => entry.type,
173
218
  'link' => repository_link_for(entry),
@@ -228,23 +273,55 @@ module Jekyll
228
273
  config['details_dir']
229
274
  end
230
275
 
231
- def cite(key)
232
- context['cited'] ||= []
233
- context['cited'] << key
276
+ def renderer
277
+ @renderer ||= CiteProc::Ruby::Renderer.new :format => 'html',
278
+ :style => style, :locale => config['locale']
279
+ end
234
280
 
235
- if bibliography.key?(key)
236
- entry = bibliography[key]
237
- entry = entry.convert(*bibtex_filters) unless bibtex_filters.empty?
281
+ def render_citation(items)
282
+ renderer.render items.zip(locators).map { |entry, locator|
283
+ cited_keys << entry.key
238
284
 
239
- citation = CiteProc.process entry.to_citeproc, :style => style,
240
- :locale => config['locale'], :format => 'html', :mode => :citation
285
+ item = citation_item_for entry, citation_number
286
+ item.locator = locator
241
287
 
242
- link_to "##{[prefix, entry.key].compact.join('-')}", citation.join
243
- else
244
- missing_reference
288
+ item
289
+ }, STYLES[style].citation
290
+ end
291
+
292
+ def render_bibliography(entry, index = nil)
293
+ renderer.render citation_item_for(entry, index),
294
+ STYLES[style].bibliography
295
+ end
296
+
297
+ def citation_item_for(entry, citation_number = nil)
298
+ CiteProc::CitationItem.new id: entry.id do |c|
299
+ c.data = CiteProc::Item.new entry.to_citeproc
300
+ c.data[:'citation-number'] = citation_number
301
+ end
302
+ end
303
+
304
+ def cited_keys
305
+ context['cited'] ||= []
306
+ end
307
+
308
+ def citation_number
309
+ number = context['citation_number'] || 1
310
+ context['citation_number'] = number.succ
311
+ number
312
+ end
313
+
314
+ def cite(keys)
315
+ items = keys.map do |key|
316
+ if bibliography.key?(key)
317
+ entry = bibliography[key]
318
+ entry = entry.convert(*bibtex_filters) unless bibtex_filters.empty?
319
+ else
320
+ return missing_reference
321
+ end
245
322
  end
246
- rescue
247
- "(#{key})"
323
+
324
+ link_to "##{[prefix, keys[0]].compact.join('-')}", render_citation(items)
248
325
  end
249
326
 
250
327
  def cite_details(key, text)
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  class Scholar
3
- VERSION = '2.0.0'.freeze
3
+ VERSION = '3.0.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-scholar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-21 00:00:00.000000000 Z
11
+ date: 2014-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -30,28 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.6
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.6
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: csl-styles
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bibtex-ruby
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '2.3'
61
+ version: '3.0'
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '2.3'
68
+ version: '3.0'
55
69
  description: " Jekyll-Scholar is for all the academic bloggers out there. It is a
56
70
  set of extensions for Jekyll the awesome, blog aware, static site generator; it
57
71
  formats your BibTeX bibliographies for the web using CSL citation styles and generally
@@ -61,7 +75,9 @@ executables: []
61
75
  extensions: []
62
76
  extra_rdoc_files: []
63
77
  files:
78
+ - ".coveralls.yml"
64
79
  - ".gitignore"
80
+ - ".simplecov"
65
81
  - ".travis.yml"
66
82
  - Gemfile
67
83
  - LICENSE
@@ -71,14 +87,17 @@ files:
71
87
  - features/bibtex.feature
72
88
  - features/citation.feature
73
89
  - features/cite_details.feature
90
+ - features/cited_only.feature
74
91
  - features/details.feature
75
92
  - features/filter.feature
93
+ - features/multiple_files.feature
76
94
  - features/reference.feature
77
95
  - features/repository.feature
78
96
  - features/sorting.feature
79
97
  - features/step_definitions/jekyll_steps.rb
80
98
  - features/step_definitions/scholar_steps.rb
81
99
  - features/support/env.rb
100
+ - features/support/hooks.rb
82
101
  - jekyll-scholar.gemspec
83
102
  - lib/jekyll/scholar.rb
84
103
  - lib/jekyll/scholar/converters/bibtex.rb
@@ -111,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
130
  version: 1.3.6
112
131
  requirements: []
113
132
  rubyforge_project: jekyll-scholar
114
- rubygems_version: 2.2.1
133
+ rubygems_version: 2.2.2
115
134
  signing_key:
116
135
  specification_version: 4
117
136
  summary: Jekyll extensions for the academic blogger.
@@ -119,11 +138,15 @@ test_files:
119
138
  - features/bibtex.feature
120
139
  - features/citation.feature
121
140
  - features/cite_details.feature
141
+ - features/cited_only.feature
122
142
  - features/details.feature
123
143
  - features/filter.feature
144
+ - features/multiple_files.feature
124
145
  - features/reference.feature
125
146
  - features/repository.feature
126
147
  - features/sorting.feature
127
148
  - features/step_definitions/jekyll_steps.rb
128
149
  - features/step_definitions/scholar_steps.rb
129
150
  - features/support/env.rb
151
+ - features/support/hooks.rb
152
+ has_rdoc: