jekyll-scholar 6.3.0 → 6.3.1

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
  SHA256:
3
- metadata.gz: d847e99be12f0d86a09c4c311c611ec75bc6acfc9c87b6153d12459b7f9739fc
4
- data.tar.gz: 7e6f5ccb6857f6b409625cc8dd295fa6c45ea886c8d32ceccfada77c4f58315e
3
+ metadata.gz: 452e18974fffbcc53b889b3c5669fbcd545a327462a72b3d331764019e9fc664
4
+ data.tar.gz: 90aab98a5f43f43c90a576b8eb1df3a2c05c9ca7581d6112871ad9172f4ddcb2
5
5
  SHA512:
6
- metadata.gz: af5f996147e731bdc6366b3c3fa57c80b14d4db68428e4ba96a06090b20c85b62fb82b7ab5d4bf28a7db8bf55ff06149eb75212ead0502c3b94dfc675b2376bc
7
- data.tar.gz: 0eadd4d81469a5ea5d2056f30c16c811acf8f29f70b93550720956ef9423f93394fd058abbfd1138b89c2b8af323b7252fa199f1181dd7915b7943781213b9cc
6
+ metadata.gz: 03156b59764f5e578aa60b227b4308d3590b96490a2a5ae2dd5bc4c50b689a3aedcfb98e98a1415207e59b7b60eba0fd7f0d6d8cf2d4b0d4e7b75d417e50e6d3
7
+ data.tar.gz: 6a626feb3f485af7d4f7ef8ff76064f520bf7351fed4ee764b27e0c2f5ea15b4046acd07a5520a7248b91d166300ff0372b25cba939f88ac82658f04a3575c5d
@@ -96,7 +96,7 @@ Feature: Cited-only Bibliographies
96
96
  ---
97
97
  ---
98
98
  {% cite smalltalk %}
99
- {% bibliography --cited --prefix one %}
99
+ {% bibliography --cited --clear --prefix one %}
100
100
 
101
101
  {% cite ruby %}
102
102
  {% bibliography --cited --prefix two %}
@@ -44,7 +44,7 @@ Feature: Interpolations ...
44
44
  Then the _site directory should exist
45
45
  And the "_site/scholar.html" file should exist
46
46
  And I should see "The Ruby Programming Language" in "_site/scholar.html"
47
-
47
+
48
48
 
49
49
  @tags @grouping
50
50
  Scenario: Local grouping override - grouping by year with interpolation
@@ -81,3 +81,95 @@ Feature: Interpolations ...
81
81
  Then I should see "<h2 class=\"bibliography\">2007</h2>" in "_site/scholar.html"
82
82
  And I should see "<h2 class=\"bibliography\">2008</h2>" in "_site/scholar.html"
83
83
  And "2008" should come before "2007" in "_site/scholar.html"
84
+
85
+ @tags @reference @liquid @interpolate
86
+ Scenario: Interpolate liquid variables in queries
87
+ Given I have a scholar configuration with:
88
+ | key | value |
89
+ | source | ./_bibliography |
90
+ | bibliography | my_references |
91
+ And I have a "_bibliography" directory
92
+ And I have a file "_bibliography/my_references.bib":
93
+ """
94
+ @book{a,
95
+ title = {Book A},
96
+ year = {2008}
97
+ }
98
+ @book{b,
99
+ title = {Book B},
100
+ year = {2018}
101
+ }
102
+ """
103
+ And I have a page "scholar.html":
104
+ """
105
+ ---
106
+ ---
107
+ {% assign from = 2000 %}
108
+ {% assign to = 2010 %}
109
+ {% bibliography --query @book[year >= {{from}} && year <= {{to}}] %}
110
+ """
111
+ When I run jekyll
112
+ Then the _site directory should exist
113
+ And the "_site/scholar.html" file should exist
114
+ And I should see "Book A" in "_site/scholar.html"
115
+ And I should not see "Book B" in "_site/scholar.html"
116
+
117
+ @tags @bibliography @liquid @interpolate
118
+ Scenario: Interpolate page variables in queries
119
+ Given I have a scholar configuration with:
120
+ | key | value |
121
+ | source | ./_bibliography |
122
+ And I have a "_bibliography" directory
123
+ And I have a file "_bibliography/references.bib":
124
+ """
125
+ @book{a,
126
+ title = {Book A},
127
+ year = {2008}
128
+ }
129
+ @book{b,
130
+ title = {Book B},
131
+ year = {2018}
132
+ }
133
+ """
134
+ And I have a page "scholar.html":
135
+ """
136
+ ---
137
+ bibquery: year >= 2000 && year <= 2010
138
+ ---
139
+ {% bibliography --query @*[{{page.bibquery}}] %}
140
+ """
141
+ When I run jekyll
142
+ Then the _site directory should exist
143
+ And the "_site/scholar.html" file should exist
144
+ And I should see "Book A" in "_site/scholar.html"
145
+ And I should not see "Book B" in "_site/scholar.html"
146
+
147
+ @tags @bibliography @liquid @interpolate
148
+ Scenario: Interpolate page variables in queries
149
+ Given I have a scholar configuration with:
150
+ | key | value |
151
+ | source | ./_bibliography |
152
+ And I have a "_bibliography" directory
153
+ And I have a file "_bibliography/references.bib":
154
+ """
155
+ @book{a,
156
+ title = {Book A},
157
+ year = {2008}
158
+ }
159
+ @book{b,
160
+ title = {Book B},
161
+ year = {2018}
162
+ }
163
+ """
164
+ And I have a page "scholar.html":
165
+ """
166
+ ---
167
+ bibquery: "@book[year >= 2000 && year <= 2010]"
168
+ ---
169
+ {% bibliography --query {{page.bibquery}} %}
170
+ """
171
+ When I run jekyll
172
+ Then the _site directory should exist
173
+ And the "_site/scholar.html" file should exist
174
+ And I should see "Book A" in "_site/scholar.html"
175
+ And I should not see "Book B" in "_site/scholar.html"
@@ -33,7 +33,7 @@ module Jekyll
33
33
 
34
34
  parser = OptionParser.new do |opts|
35
35
 
36
- opts.on('-c', '--cited') do |cited|
36
+ opts.on('-c', '--cited') do |cited|
37
37
  @cited = true
38
38
  end
39
39
 
@@ -41,6 +41,10 @@ module Jekyll
41
41
  @cited, @skip_sort = true, true
42
42
  end
43
43
 
44
+ opts.on('--clear') do |cited|
45
+ @clear = true
46
+ end
47
+
44
48
  opts.on('-r', '--remove_duplicates [MATCH_FIELDS]') do |match_field|
45
49
  @remove_duplicates = true
46
50
  @match_fields = match_field.split(/,\s+/) if not match_field.nil?
@@ -108,17 +112,17 @@ module Jekyll
108
112
  end
109
113
  end
110
114
 
111
- argv = arguments.split(/(\B-[cCfhqptTsgGOlLomAr]|\B--(?:cited(_in_order)?|bibliography_list_tag|file|query|prefix|text|style|group_(?:by|order)|type_order|template|locator|label|offset|max|suppress_author|remove_duplicates|))/)
115
+ argv = arguments.split(/(\B-[cCfhqptTsgGOlLomAr]|\B--(?:cited(_in_order)?|clear|bibliography_list_tag|file|query|prefix|text|style|group_(?:by|order)|type_order|template|locator|label|offset|max|suppress_author|remove_duplicates|))/)
112
116
 
113
117
  parser.parse argv.map(&:strip).reject(&:empty?)
114
118
  end
115
119
 
116
120
  def bibliography_list_tag
117
- if @bibliography_list_tag.nil?
118
- config['bibliography_list_tag']
119
- else
120
- @bibliography_list_tag
121
- end
121
+ if @bibliography_list_tag.nil?
122
+ config['bibliography_list_tag']
123
+ else
124
+ @bibliography_list_tag
125
+ end
122
126
  end
123
127
 
124
128
  def allow_locale_overrides?
@@ -128,7 +132,7 @@ module Jekyll
128
132
 
129
133
  def match_fields
130
134
  @match_fields ||= []
131
- end
135
+ end
132
136
 
133
137
  def locators
134
138
  @locators ||= []
@@ -163,8 +167,8 @@ module Jekyll
163
167
 
164
168
  def bibtex_paths
165
169
  @bibtex_paths ||= bibtex_files.map { |file|
166
- interpolated_file = interpolate file
167
- extend_path interpolated_file
170
+ interpolated_file = interpolate file
171
+ extend_path interpolated_file
168
172
  }
169
173
  end
170
174
 
@@ -215,14 +219,14 @@ module Jekyll
215
219
  sorted = unsorted.sort do |e1, e2|
216
220
  sort_keys
217
221
  .map.with_index do |key, idx|
218
- v1 = e1[key].nil? ? BibTeX::Value.new : e1[key]
219
- v2 = e2[key].nil? ? BibTeX::Value.new : e2[key]
220
- if (sort_order[idx] || sort_order.last) =~ /^(desc|reverse)/i
221
- v2 <=> v1
222
- else
223
- v1 <=> v2
224
- end
222
+ v1 = e1[key].nil? ? BibTeX::Value.new : e1[key]
223
+ v2 = e2[key].nil? ? BibTeX::Value.new : e2[key]
224
+ if (sort_order[idx] || sort_order.last) =~ /^(desc|reverse)/i
225
+ v2 <=> v1
226
+ else
227
+ v1 <=> v2
225
228
  end
229
+ end
226
230
  .find { |c| c != 0 } || 0
227
231
  end
228
232
 
@@ -420,6 +424,10 @@ module Jekyll
420
424
  !!@cited
421
425
  end
422
426
 
427
+ def clear?
428
+ !!@clear
429
+ end
430
+
423
431
  def skip_sort?
424
432
  @skip_sort || config['sort_by'] == 'none'
425
433
  end
@@ -498,15 +506,15 @@ module Jekyll
498
506
 
499
507
  tmp = liquid_template.render(
500
508
  reference_data(entry,index)
501
- .merge(site.site_payload)
502
- .merge({
503
- 'index' => index,
504
- 'details' => details_link_for(entry)
505
- }),
506
- {
507
- :registers => { :site => site },
508
- :filters => [Jekyll::Filters]
509
- }
509
+ .merge(site.site_payload)
510
+ .merge({
511
+ 'index' => index,
512
+ 'details' => details_link_for(entry)
513
+ }),
514
+ {
515
+ :registers => { :site => site },
516
+ :filters => [Jekyll::Filters]
517
+ }
510
518
  )
511
519
  # process the generated reference with Liquid, to get the same behaviour as
512
520
  # when it is used on a page
@@ -660,10 +668,10 @@ module Jekyll
660
668
  rescue
661
669
  # Locale failed to load; just use original one!
662
670
  end if allow_locale_overrides? &&
663
- entry['language'] != renderer.locale.language
671
+ entry['language'] != renderer.locale.language
664
672
 
665
673
  renderer.render citation_item_for(entry, index),
666
- styles(style).bibliography
674
+ styles(style).bibliography
667
675
  ensure
668
676
  renderer.locale = original_locale unless original_locale.nil?
669
677
  end
@@ -784,32 +792,32 @@ module Jekyll
784
792
  end
785
793
 
786
794
  def update_dependency_tree
787
- # Add bibtex files to dependency tree
788
- if context.registers[:page] and context.registers[:page].key? "path"
789
- bibtex_paths.each do |bibtex_path|
790
- site.regenerator.add_dependency(
791
- site.in_source_dir(context.registers[:page]["path"]),
792
- bibtex_path
793
- )
794
- end
795
- end
795
+ # Add bibtex files to dependency tree
796
+ if context.registers[:page] and context.registers[:page].key? "path"
797
+ bibtex_paths.each do |bibtex_path|
798
+ site.regenerator.add_dependency(
799
+ site.in_source_dir(context.registers[:page]["path"]),
800
+ bibtex_path
801
+ )
802
+ end
803
+ end
796
804
  end
797
805
 
798
806
  def cited_entries
799
807
  items = entries
800
808
  if cited_only?
801
809
  items = if skip_sort?
802
- cited_references.uniq.map do |key|
803
- items.detect { |e| e.key == key }
804
- end
805
- else
806
- entries.select do |e|
807
- cited_references.include? e.key
808
- end
809
- end
810
+ cited_references.uniq.map do |key|
811
+ items.detect { |e| e.key == key }
812
+ end
813
+ else
814
+ entries.select do |e|
815
+ cited_references.include? e.key
816
+ end
817
+ end
810
818
 
811
819
  # See #90
812
- cited_keys.clear
820
+ cited_keys.clear if clear?
813
821
  end
814
822
 
815
823
  items
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  class Scholar
3
- VERSION = '6.3.0'.freeze
3
+ VERSION = '6.3.1'.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: 6.3.0
4
+ version: 6.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-09 00:00:00.000000000 Z
11
+ date: 2019-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  - !ruby/object:Gem::Version
155
155
  version: 1.3.6
156
156
  requirements: []
157
- rubygems_version: 3.0.3
157
+ rubygems_version: 3.0.6
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Jekyll extensions for the academic blogger.