jekyll-scholar 5.7.2 → 5.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c87d13eba6259db001b9e45d8c5e6be1880850eb
4
- data.tar.gz: 67cad6edde00f6385a32f062bcf5f0b88200dfdf
3
+ metadata.gz: 59e9726fd29959f5065efcb1c1a6948128f20eb2
4
+ data.tar.gz: 37a408bb19e1af81bb6884bc2a6abf37a4751f29
5
5
  SHA512:
6
- metadata.gz: 66076962697bcababa64494ad7f81a754c9e16b1c5cf81cfe69c56ea0dd89bf8893a7931085b2706ca7bbf76e54d2190597b4780edbeda0410896677a3c439f9
7
- data.tar.gz: 66a4ba75e7035dfd1413453ff34cf0e249bcf97eab03ba4233d21cd0814512864fec6968b3c5d47813ddcf887226cd8739735133406015a072bb72c4696c7459
6
+ metadata.gz: 4d0b131b2bea9952706288b62796f0c0acf25916ee796b38245e4ea8452dedc7d4ef183588a45980dcf8cb7907bcd5c51516143e2d4a0b2f2a9acd09942cdf86
7
+ data.tar.gz: 151bffaa573b6415f66e4ab6a9a092b3dbbf529b4f163dffdae8e4fb23d66451ba687031c4f29f59adc71d3ccdb6ad8a7c7164ba93beb47d2cb5c84fe6cb8976
data/README.md CHANGED
@@ -361,13 +361,18 @@ like: `...as Matz explains (2008, p. 42)`.
361
361
 
362
362
  #### Page numbers and locators
363
363
 
364
- If you would like to add page numbers to your citation, you can use the
365
- `-l` or `--locator` option. For example, `{% cite ruby -l 23-5 %}` would
364
+ If you would like to add page numbers or similar locators to your citation,
365
+ use the `-l` or `--locator` option. For example, `{% cite ruby --locator 23-5 %}` would
366
366
  produce a citation like `(Matsumoto, 2008, pp. 23-5)`.
367
367
 
368
368
  When quoting multiple items (see above) you can add multiple locators after
369
369
  the list of ids. For example, `{% cite ruby microscope -l 2 -l 24 & 32 %}`.
370
370
 
371
+ Page is the default locator, however, you can indicate the type of locator
372
+ by adding a `-L` or `--label` option (one for each locator) for instance,
373
+ `{% cite ruby microscope --label chapter --locator 3 -L figure -l 24 & 32 %}`
374
+ produces something like: `(Matsumoto, 2008, chap. 3; Shaughnessy, 2013, figs. 24 & 32)`.
375
+
371
376
  #### Displaying formatted references
372
377
 
373
378
  If you want to display the full formatted reference entry, you can use the
@@ -187,6 +187,36 @@ Feature: BibTeX
187
187
  And the "_site/scholar.html" file should exist
188
188
  And I should see "<abbr>1 book \[ruby\]</abbr>Matsumoto" in "_site/scholar.html"
189
189
 
190
+ @tags @bibliography @config @template @names
191
+ Scenario: Simple Bibliography With Custom Template and Name Parsing
192
+ Given I have a scholar configuration with:
193
+ | key | value |
194
+ | source | ./_bibliography |
195
+ | bibliography_template | <span>{{entry.author}}</span> |
196
+ And I have the following BibTeX options:
197
+ | key | value |
198
+ | parse_names | false |
199
+ And I have a "_bibliography" directory
200
+ And I have a file "_bibliography/references.bib":
201
+ """
202
+ @book{ruby,
203
+ title = {The Ruby Programming Language},
204
+ author = {David Flanagan and Matsumoto, Yukihiro},
205
+ year = {2008},
206
+ publisher = {O'Reilly Media}
207
+ }
208
+ """
209
+ And I have a page "scholar.html":
210
+ """
211
+ ---
212
+ ---
213
+ {% bibliography -f references %}
214
+ """
215
+ When I run jekyll
216
+ Then the _site directory should exist
217
+ And the "_site/scholar.html" file should exist
218
+ And I should see "David Flanagan and Matsumoto, Yukihiro" in "_site/scholar.html"
219
+
190
220
  @tags @filter
191
221
  Scenario: Filtered Bibliography Loaded From Default Directory
192
222
  Given I have a scholar configuration with:
@@ -235,6 +235,66 @@ Feature: Citations
235
235
  And the "_site/scholar.html" file should exist
236
236
  And I should see "Matsumoto, 2008, pp. 2-3; Shaughnessy, 2013, pp. 23 &amp; 42" in "_site/scholar.html"
237
237
 
238
+ @tags @cite @locator @label
239
+ Scenario: Citations with locator labels
240
+ Given I have a scholar configuration with:
241
+ | key | value |
242
+ | source | ./_bibliography |
243
+ | bibliography | my_references |
244
+ And I have a "_bibliography" directory
245
+ And I have a file "_bibliography/my_references.bib":
246
+ """
247
+ @book{ruby,
248
+ title = {The Ruby Programming Language},
249
+ author = {Flanagan, David and Matsumoto, Yukihiro},
250
+ year = {2008},
251
+ publisher = {O'Reilly Media}
252
+ }
253
+ @book{microscope,
254
+ title = {Ruby Under a Microscope},
255
+ author = {Pat Shaughnessy},
256
+ year = {2013},
257
+ publisher = {No Starch Press}
258
+ }
259
+ """
260
+ And I have a page "scholar.html":
261
+ """
262
+ ---
263
+ ---
264
+ {% cite ruby microscope --label chapter --locator 2-3 -L figure -l 4,5 %}
265
+ """
266
+ When I run jekyll
267
+ Then the _site directory should exist
268
+ And the "_site/scholar.html" file should exist
269
+ And I should see "Matsumoto, 2008, chaps. 2-3; Shaughnessy, 2013, figs. 4,5" in "_site/scholar.html"
270
+
271
+ @tags @cite @locator @label
272
+ Scenario: Citations with multiple locator labels
273
+ Given I have a scholar configuration with:
274
+ | key | value |
275
+ | source | ./_bibliography |
276
+ | bibliography | my_references |
277
+ And I have a "_bibliography" directory
278
+ And I have a file "_bibliography/my_references.bib":
279
+ """
280
+ @book{ruby,
281
+ title = {The Ruby Programming Language},
282
+ author = {Matsumoto, Yukihiro},
283
+ year = {2008},
284
+ publisher = {O'Reilly Media}
285
+ }
286
+ """
287
+ And I have a page "scholar.html":
288
+ """
289
+ ---
290
+ ---
291
+ {% cite ruby --label chapter --locator 3 %}
292
+ """
293
+ When I run jekyll
294
+ Then the _site directory should exist
295
+ And the "_site/scholar.html" file should exist
296
+ And I should see "Matsumoto, 2008, chap. 3" in "_site/scholar.html"
297
+
238
298
  @tags @cite @citation_number
239
299
  Scenario: Multiple citations using citation numbers
240
300
  Given I have a scholar configuration with:
@@ -41,9 +41,9 @@ Feature: BibTeX
41
41
  @tags @filters
42
42
  Scenario: Jekyll Filters
43
43
  Given I have a scholar configuration with:
44
- | key | value |
45
- | source | ./_bibliography |
46
- | bibliography_template | template |
44
+ | key | value |
45
+ | source | ./_bibliography |
46
+ | bibliography_template | template |
47
47
  And I have a "_bibliography" directory
48
48
  And I have a file "_bibliography/references.bib":
49
49
  """
@@ -279,3 +279,79 @@ Feature: BibTeX
279
279
  Then the _site directory should exist
280
280
  And the "_site/scholar.html" file should exist
281
281
  And I should see "<sup>ü ü ž</sup>" in "_site/scholar.html"
282
+
283
+ @tags @superscript
284
+ Scenario: LaTeX Superscript as HTML with embedded LaTeX chars left untouched
285
+ Given I have a scholar configuration with:
286
+ | key | value |
287
+ | source | ./_bibliography |
288
+ And I have the following BibTeX filters:
289
+ | superscript |
290
+ And I have a "_bibliography" directory
291
+ And I have a file "_bibliography/references.bib":
292
+ """
293
+ @misc{pickaxe,
294
+ title = {\textsuperscript{\"u \"{u} \v{z}}}
295
+ }
296
+ """
297
+ And I have a page "scholar.html":
298
+ """
299
+ ---
300
+ ---
301
+ {% bibliography %}
302
+ """
303
+ When I run jekyll
304
+ Then the _site directory should exist
305
+ And the "_site/scholar.html" file should exist
306
+ And I should see "<sup>\\"u \\"\{u\} \\v\{z\}</sup>" in "_site/scholar.html"
307
+
308
+ @tags @superscript
309
+ Scenario: LaTeX Superscript with subsequent groups as HTML
310
+ Given I have a scholar configuration with:
311
+ | key | value |
312
+ | source | ./_bibliography |
313
+ And I have the following BibTeX filters:
314
+ | superscript |
315
+ | latex |
316
+ And I have a "_bibliography" directory
317
+ And I have a file "_bibliography/references.bib":
318
+ """
319
+ @misc{pickaxe,
320
+ title = {This is \textsuperscript{superscript text} this should not be superscript {even} {with {additional} groups}.}
321
+ }
322
+ """
323
+ And I have a page "scholar.html":
324
+ """
325
+ ---
326
+ ---
327
+ {% bibliography %}
328
+ """
329
+ When I run jekyll
330
+ Then the _site directory should exist
331
+ And the "_site/scholar.html" file should exist
332
+ And I should see "This is <sup>superscript text</sup> this should not be superscript even with additional groups." in "_site/scholar.html"
333
+
334
+ @tags @superscript
335
+ Scenario: LaTeX Superscript with subsequent groups untouched in HTML
336
+ Given I have a scholar configuration with:
337
+ | key | value |
338
+ | source | ./_bibliography |
339
+ And I have the following BibTeX filters:
340
+ | superscript |
341
+ And I have a "_bibliography" directory
342
+ And I have a file "_bibliography/references.bib":
343
+ """
344
+ @misc{pickaxe,
345
+ title = {This is \textsuperscript{superscript text} this should not be superscript {even} {with {additional} groups}.}
346
+ }
347
+ """
348
+ And I have a page "scholar.html":
349
+ """
350
+ ---
351
+ ---
352
+ {% bibliography %}
353
+ """
354
+ When I run jekyll
355
+ Then the _site directory should exist
356
+ And the "_site/scholar.html" file should exist
357
+ And I should see "This is <sup>superscript text</sup> this should not be superscript \{even\} \{with \{additional\} groups\}." in "_site/scholar.html"
@@ -2,9 +2,10 @@ module Jekyll
2
2
  class Scholar
3
3
  class Superscript < BibTeX::Filter
4
4
  def apply(value)
5
- # Use of \g<1> pattern back-reference to allow for capturing nested {} groups
6
- value.to_s.gsub(/\\textsuperscript(\{((?:.|\g<1>)*)\})/) {
7
- "<sup>#{$2}</sup>"
5
+ # Use of \g<1> pattern back-reference to allow for capturing nested {} groups.
6
+ # The first (outermost) capture of $1 is used.
7
+ value.to_s.gsub(/\\textsuperscript(\{(?:[^{}]|\g<1>)*\})/) {
8
+ "<sup>#{$1[1..-2]}</sup>"
8
9
  }
9
10
  end
10
11
  end
@@ -21,7 +21,6 @@ module Jekyll
21
21
  attr_reader :config, :site, :context, :prefix, :text, :offset, :max
22
22
 
23
23
 
24
-
25
24
  def split_arguments(arguments)
26
25
 
27
26
  tokens = arguments.strip.split(/\s+/)
@@ -69,6 +68,10 @@ module Jekyll
69
68
  locators << locator
70
69
  end
71
70
 
71
+ opts.on('-L', '--label LABEL') do |label|
72
+ labels << label
73
+ end
74
+
72
75
  opts.on('-o', '--offset OFFSET') do |offset|
73
76
  @offset = offset.to_i
74
77
  end
@@ -98,7 +101,7 @@ module Jekyll
98
101
  end
99
102
  end
100
103
 
101
- argv = arguments.split(/(\B-[cCfqptTsgGOlomA]|\B--(?:cited(_in_order)?|file|query|prefix|text|style|group_(?:by|order)|type_order|template|locator|offset|max|suppress_author|))/)
104
+ argv = arguments.split(/(\B-[cCfqptTsgGOlLomA]|\B--(?:cited(_in_order)?|file|query|prefix|text|style|group_(?:by|order)|type_order|template|locator|label|offset|max|suppress_author|))/)
102
105
 
103
106
  parser.parse argv.map(&:strip).reject(&:empty?)
104
107
  end
@@ -107,6 +110,10 @@ module Jekyll
107
110
  @locators ||= []
108
111
  end
109
112
 
113
+ def labels
114
+ @labels ||= []
115
+ end
116
+
110
117
  def bibtex_files
111
118
  @bibtex_files ||= [config['bibliography']]
112
119
  end
@@ -512,9 +519,6 @@ module Jekyll
512
519
  e
513
520
  end
514
521
 
515
- def bibtex_skip_fields
516
- end
517
-
518
522
  def generate_details?
519
523
  site.layouts.key?(File.basename(config['details_layout'], '.html'))
520
524
  end
@@ -566,12 +570,13 @@ module Jekyll
566
570
  end
567
571
 
568
572
  def render_citation(items)
569
- renderer.render items.zip(locators).map { |entry, locator|
573
+ renderer.render items.zip(locators.zip(labels)).map { |entry, (locator, label)|
570
574
  cited_keys << entry.key
571
575
  cited_keys.uniq!
572
576
 
573
577
  item = citation_item_for entry, citation_number(entry.key)
574
578
  item.locator = locator
579
+ item.label = label unless label.nil?
575
580
 
576
581
  item
577
582
  }, STYLES[style].citation
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  class Scholar
3
- VERSION = '5.7.2'.freeze
3
+ VERSION = '5.8.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: 5.7.2
4
+ version: 5.8.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: 2016-03-06 00:00:00.000000000 Z
11
+ date: 2016-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  version: 1.3.6
142
142
  requirements: []
143
143
  rubyforge_project: jekyll-scholar
144
- rubygems_version: 2.4.5.1
144
+ rubygems_version: 2.6.3
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Jekyll extensions for the academic blogger.