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 +4 -4
- data/.coveralls.yml +2 -0
- data/.gitignore +1 -0
- data/.simplecov +4 -0
- data/.travis.yml +1 -0
- data/Gemfile +10 -6
- data/README.md +20 -2
- data/Rakefile +4 -0
- data/features/bibtex.feature +1 -2
- data/features/citation.feature +104 -0
- data/features/cited_only.feature +72 -0
- data/features/multiple_files.feature +41 -0
- data/features/step_definitions/jekyll_steps.rb +10 -21
- data/features/step_definitions/scholar_steps.rb +5 -5
- data/features/support/env.rb +12 -6
- data/features/support/hooks.rb +10 -0
- data/jekyll-scholar.gemspec +3 -2
- data/lib/jekyll/scholar.rb +2 -1
- data/lib/jekyll/scholar/converters/bibtex.rb +21 -20
- data/lib/jekyll/scholar/tags/bibliography.rb +0 -9
- data/lib/jekyll/scholar/tags/cite.rb +3 -3
- data/lib/jekyll/scholar/tags/cite_details.rb +4 -2
- data/lib/jekyll/scholar/tags/quote.rb +12 -12
- data/lib/jekyll/scholar/tags/reference.rb +4 -4
- data/lib/jekyll/scholar/utilities.rb +101 -24
- data/lib/jekyll/scholar/version.rb +1 -1
- metadata +30 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7d2bffb292d27ff2150ac22f4f08c16725933e1
|
4
|
+
data.tar.gz: df29da3988760f7cf35edfa13c147ff1a11b8a1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3e5ad5b114cc0b8c2ac03c79a3154964c32bc81f72d1187e304c0028e596775fd260ca674037cf59e9038f6b25e989d4f2a29b0ba9e52e8b57df2d7b6c9aa15
|
7
|
+
data.tar.gz: e4c94ec420ef8e67cd4fdbabf188dc79a08930b53461c151cb00a203fa680604f3e11f4e3926feb87eecb9ee70b35d3abae32d64cde1eb55d8d52d11aa116de3
|
data/.coveralls.yml
ADDED
data/.gitignore
CHANGED
data/.simplecov
ADDED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,22 +1,26 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
group
|
4
|
+
group :development do
|
5
|
+
gem 'minitest', '< 5.0'
|
5
6
|
gem 'rake'
|
6
7
|
gem 'redgreen', '~> 1.2'
|
7
|
-
gem 'shoulda', '~> 3.
|
8
|
-
gem 'rr', '~> 1.
|
9
|
-
gem 'cucumber', '
|
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', '~>
|
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
|
[](https://travis-ci.org/inukshuk/jekyll-scholar)
|
13
|
-
|
13
|
+
[](https://coveralls.io/r/inukshuk/jekyll-scholar)
|
14
|
+
[](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. & 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
|
-
|
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}"
|
data/features/bibtex.feature
CHANGED
@@ -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
|
207
|
+
{% bibliography --style modern-language-association %}
|
209
208
|
"""
|
210
209
|
When I run jekyll
|
211
210
|
Then the _site directory should exist
|
data/features/citation.feature
CHANGED
@@ -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 & 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 & 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
|
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
|
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
|
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
|
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
|
38
|
+
When(/^I run jekyll$/) do
|
49
39
|
run_jekyll
|
50
40
|
end
|
51
41
|
|
52
|
-
Then
|
42
|
+
Then(/^the (.*) directory should exist$/) do |dir|
|
53
43
|
assert File.directory?(dir)
|
54
44
|
end
|
55
45
|
|
56
|
-
Then
|
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
|
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
|
55
|
+
Then(/^the "(.*)" file should exist$/) do |file|
|
67
56
|
assert File.file?(file)
|
68
57
|
end
|
69
58
|
|
70
|
-
Then
|
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
|
2
|
+
Given(/^I have a "([^"]*)" directory/) do |dir|
|
3
3
|
FileUtils.mkdir(dir)
|
4
4
|
end
|
5
5
|
|
6
|
-
Given
|
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
|
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
|
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
|
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)
|
data/features/support/env.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
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)
|
data/jekyll-scholar.gemspec
CHANGED
@@ -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', '~>
|
30
|
-
s.add_runtime_dependency('
|
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")
|
data/lib/jekyll/scholar.rb
CHANGED
@@ -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
|
-
|
8
|
-
|
9
|
+
attr_reader :config
|
10
|
+
|
9
11
|
@pattern = (/bib(tex)?$/i).freeze
|
10
12
|
@extension = '.html'.freeze
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
25
|
+
extension =~ BibTeXConverter.pattern
|
26
|
+
end
|
27
|
+
|
26
28
|
def output_ext(extension)
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
BibTeXConverter.extension
|
30
|
+
end
|
31
|
+
|
30
32
|
def convert(content)
|
31
|
-
|
33
|
+
content = BibTeX.parse(content, :strict => true, :include => [:meta_content], :filter => [:latex]).map do |b|
|
32
34
|
if b.respond_to?(:to_citeproc)
|
33
|
-
|
34
|
-
:locale => config['locale'], :format => 'html'
|
35
|
+
render_bibliography b
|
35
36
|
else
|
36
|
-
|
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
|
@@ -10,14 +10,14 @@ module Jekyll
|
|
10
10
|
super
|
11
11
|
|
12
12
|
@config = Scholar.defaults.dup
|
13
|
-
@
|
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
|
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
|
-
@
|
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
|
-
|
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
|
-
@
|
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
|
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
|
-
@
|
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
|
-
|
19
|
-
|
20
|
-
"
|
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, #
|
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 :
|
10
|
-
:context, :prefix, :
|
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
|
-
@
|
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-[
|
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
|
-
|
102
|
+
bibtex_paths[0]
|
60
103
|
end
|
61
104
|
|
62
105
|
def bibliography
|
63
106
|
unless @bibliography
|
64
|
-
@bibliography = BibTeX.
|
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 =
|
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
|
232
|
-
|
233
|
-
|
276
|
+
def renderer
|
277
|
+
@renderer ||= CiteProc::Ruby::Renderer.new :format => 'html',
|
278
|
+
:style => style, :locale => config['locale']
|
279
|
+
end
|
234
280
|
|
235
|
-
|
236
|
-
|
237
|
-
|
281
|
+
def render_citation(items)
|
282
|
+
renderer.render items.zip(locators).map { |entry, locator|
|
283
|
+
cited_keys << entry.key
|
238
284
|
|
239
|
-
|
240
|
-
|
285
|
+
item = citation_item_for entry, citation_number
|
286
|
+
item.locator = locator
|
241
287
|
|
242
|
-
|
243
|
-
|
244
|
-
|
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
|
-
|
247
|
-
"(
|
323
|
+
|
324
|
+
link_to "##{[prefix, keys[0]].compact.join('-')}", render_citation(items)
|
248
325
|
end
|
249
326
|
|
250
327
|
def cite_details(key, text)
|
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:
|
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-
|
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:
|
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:
|
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: '
|
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: '
|
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.
|
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:
|