jekyll-scholar 5.8.5 → 5.9.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: 6a066765a98ef88cac6bde9f73aa707cdb71e938
4
- data.tar.gz: d342a9115b68215869dc61cd4ceb10a012db0526
3
+ metadata.gz: aa155858171a28430fabd6809b18b61b34afae48
4
+ data.tar.gz: 5b92a94a4abedb754108a1b8f5d7bdd5da7b5cdf
5
5
  SHA512:
6
- metadata.gz: dbb7afaca8fcfc7a51d1328ada1b8425f8f7240be048ee2b7f7dfde3b87365d75482ec1eef947f75ae69bcd6933f7e87498f4b20828ad65f0bc813348eab33f4
7
- data.tar.gz: 2c7c4e0857fa6bd5854954265faf2d495f0aebaafc710a5a4ee4b6e6e0d9f3c38089d5521d428b77198e996a670b5b42d0faf23b7cf8f30bec35735b41f50b72
6
+ metadata.gz: e72d369a92f0be6a3cbd7e931149b365437bc204a5d19b046fb987fbd0122e6f048fc8471f5bb3910328f325f2a51153869dc6cde4d2ae84b3c87dc7aa552344
7
+ data.tar.gz: 8f31ed291d15017d72d5d3772ff6aee88e90e73195ae971c62973f082ebf7662edc87ba0a6c0bb2cbce7d1a0ce8d75c774185d63960bb73125f97a148706dc0c
data/README.md CHANGED
@@ -53,92 +53,32 @@ configuration:
53
53
 
54
54
  gems: ['jekyll/scholar']
55
55
 
56
- In your configuration you can now adjust the Jekyll-Scholar settings. The
57
- default configuration is as follows:
56
+ ### Configuration
57
+
58
+ In your Jekyll configuration file you can adjust the Jekyll-Scholar settings
59
+ using the `scholar` key. For example, the following sets the bibliography style
60
+ to `mla`.
58
61
 
59
62
  scholar:
60
- style: apa
61
- locale: en
62
-
63
- sort_by: none
64
- order: ascending
65
-
66
- group_by: none
67
- group_order: ascending
68
-
69
- source: ./_bibliography
70
- bibliography: references.bib
71
- bibliography_template: "{{reference}}"
72
-
73
- replace_strings: true
74
- join_strings: true
75
-
76
- use_raw_bibtex_entry: true
77
- bibtex_filters:
78
- - superscript
79
- - latex
80
-
81
- details_dir: bibliography
82
- details_layout: bibtex.html
83
- details_link: Details
84
-
85
- query: "@*"
86
-
87
- You can use any style that ships with
88
- [CiteProc-Ruby](https://github.com/inukshuk/citeproc-ruby) by name (e.g.,
89
- apa, mla, chicago-fullnote-bibliography) which is usually the filename as seen
90
- [here](https://github.com/citation-style-language/styles)
91
- sans the `.csl` ending; note that you have to use `dependent/style` if you want
92
- to use one from that directory.
93
- Alternatively you can add a link to any CSL style (e.g., you could link to any of the styles available at
94
- the official [CSL style repository](https://github.com/citation-style-language/styles)).
95
-
96
- The `locale` settings defines what language to use when formatting
97
- your references (this typically applies to localized terms, e.g., 'Eds.' for
98
- editors in English).
99
-
100
- The `source` option indicates where your bibliographies are stored;
101
- `bibliography` is the name of your default bibliography. For best results,
102
- please ensure that your Bibliography is encoded as ASCII or UTF-8.
103
-
104
- The `use_raw_bibtex_entry` option by default disable parsing of Liquid tags
105
- embedded in the Bibtex fields. This option provides a way to circumvent the
106
- problem that (the conflicting syntax of) the double braces functionality of
107
- BibTex is accidentally parsed by Liquid, while it was intended to keep the
108
- exact capitalization style.
109
-
110
- The `sort_by` and `order` options specify if and how bibliography
111
- entries are sorted. Entries can be sorted on multiple fields, by using
112
- a list of keys, e.g. `sort_by: year,month`. Ordering can be specified
113
- per sort level, e.g. `order: descending,ascending` will sort the years
114
- descending, but per year the months are ascending. If there are more
115
- sort keys than order directives, the last order entry is used for the
116
- remaining keys.
117
-
118
- The `group_by` and `group_order` options specify how bibliography
119
- items are grouped. Grouping can be multi-level as well,
120
- e.g. `group_by: type, year` groups entries per publication type, and
121
- within those groups per year. Ordering for groups is specified in the
122
- same way as the sort order. Publication types -- specified with group
123
- key `type`, can be ordered by adding `type_order` to the
124
- configuration. For example, `type_order: article,techreport` lists
125
- journal articles before technical reports. Types not mentioned in
126
- `type_order` are considered smaller than types that are
127
- mentioned. Types can be merge in one group using the `type_aliases`
128
- setting. By default `phdthesis` and `mastersthesis` are grouped as
129
- `thesis`. By using, for example, `type_aliases: { inproceeding =>
130
- article}`, journal and conference articles appear in a single
131
- group. The display names for entry types are specified with
132
- `type_names`. Names for common types are provided, but they can be
133
- extended or overridden. For example, the default name for `article` is
134
- *Journal Articles*, but it can be changed to *Papers* using
135
- `type_name: { article => 'Papers' }`.
136
-
137
- The `bibtex_filters` option configures which
138
- [BibTeX-Ruby](https://github.com/inukshuk/bibtex-ruby) formatting filters
139
- values of entries should be passed through. This defaults to the `latex`
140
- filter which converts LaTeX character escapes into unicode, and `superscript`
141
- which converts the `\textsuperscript` command into a HTML `<sup>` tag.
63
+ style: mla
64
+
65
+ The table below describes some commonly used configuration options. For a
66
+ description of all options and their defaults, see
67
+ [`defaults.rb`](/lib/jekyll/scholar/defaults.rb).
68
+
69
+ | Option | Default | Description |
70
+ |--------|---------|-------------|
71
+ | `style` | `apa` | Indicates the style used for the bibliography and citations. You can use any style that ships with [CiteProc-Ruby](https://github.com/inukshuk/citeproc-ruby) by name (e.g., apa, mla, chicago-fullnote-bibliography) which is usually the filename as seen [here](https://github.com/citation-style-language/styles) without the `.csl` ending; note that you have to use `dependent/style` if you want to use one from that directory. Alternatively you can add a link to any CSL style (e.g., you could link to any of the styles available at the official [CSL style repository](https://github.com/citation-style-language/styles)). |
72
+ | `locale` | `en` | Defines what language to use when formatting your references (this typically applies to localized terms, e.g., 'Eds.' for editors in English). |
73
+ | `source` | `./_bibliography` | Indicates where your bibliographies are stored. |
74
+ | `bibliograpy` | `references.bib` | Indicates the name of your default bibliography. For best results, please ensure that your bibliography is encoded as ASCII or UTF-8. |
75
+ | `use_raw_bibtex_entry` | `true` | When `true`, disables parsing of Liquid tags embedded in the Bibtex fields. This option provides a way to circumvent the problem that (the conflicting syntax of) the double braces functionality of BibTex is accidentally parsed by Liquid, while it was intended to keep the exact capitalization style. |
76
+ | `sort_by` | `none` | Specifies if and how bibliography entries are sorted. Entries can be sorted on multiple fields, by using a list of keys, e.g. `year,month`. Ordering can be specified per sort level, e.g. `order: descending,ascending` will sort the years descending, but per year the months are ascending. If there are more sort keys than order directives, the last order entry is used for the remaining keys. |
77
+ | `order` | `ascending` | Specifies order bibliography entries are sorted in. Can be `ascending` or descending. Ordering can be specified per sort level, e.g. `descending,ascending` will sort in descending on the first key then ascending order on the second key. If there are more sort keys than order directives, the last order entry is used for the remaining keys. |
78
+ | `group_by` | `none` | Specifies how bibliography items are grouped. Grouping can be multi-level, e.g. `type, year` groups entries per publication type, and within those groups per year. |
79
+ | `group_order` | `ascending` | Ordering for groups is specified in the same way as the sort order. Publication types -- specified with group key `type`, can be ordered by adding `type_order` to the configuration. For example, `type_order: article,techreport` lists journal articles before technical reports. Types not mentioned in `type_order` are considered smaller than types that are mentioned. Types can be merge in one group using the `type_aliases` setting. By default `phdthesis` and `mastersthesis` are grouped as `thesis`. By using, for example, `type_aliases: { inproceedings: article}`, journal and conference articles appear in a single group. The display names for entry types are specified with `type_names`. Names for common types are provided, but they can be extended or overridden. For example, the default name for `article` is *Journal Articles*, but it can be changed to *Papers* using `type_names: { article: Papers }`. |
80
+ | `bibtex_filters` | `latex,superscript` | Configures which [BibTeX-Ruby](https://github.com/inukshuk/bibtex-ruby) formatting filters values of entries should be passed through. The default `latex` filter converts LaTeX character escapes into unicode, and `superscript` which converts the `\textsuperscript` command into a HTML `<sup>` tag. |
81
+
142
82
 
143
83
  ### Bibliographies
144
84
 
@@ -352,6 +292,19 @@ of the items you wish to quote separated by spaces. For example,
352
292
 
353
293
  <a href="#ruby">(Flanagan &amp; Matsumoto 2008; Shaughnessy 2013)</a>
354
294
 
295
+ #### Citations when there's more than one bibliography
296
+
297
+ Let's return to the example above where you have two bibliographies stored
298
+ in `_bibliography/books.bib` and `_bibliography/papers.bib`. We also must
299
+ have the main bibliography, e.g., `_bibliography/references.bib`. As we
300
+ know from above, it's possible to use bibliographies other than the main
301
+ bibliography by calling `{% bibliography --file books %}` or
302
+ `{% bibliography --file papers %}`.
303
+
304
+ Though what if we want to cite an article that's not in the main bibliography?
305
+ We use the same approach as above; to cite an article in the `books.bib`
306
+ bibliography, we simply call `{% cite ruby --file books %}`
307
+
355
308
  #### Suppressing author names
356
309
 
357
310
  Sometimes you want to suppress author names in a citation, because the
@@ -369,3 +369,49 @@ Feature: BibTeX
369
369
  Then the _site directory should exist
370
370
  And the "_site/scholar.html" file should exist
371
371
  And I should not see "{%[\w*]raw[\w*]%}" in "_site/scholar.html"
372
+
373
+ @config @bibliography @style
374
+ Scenario: A custom style with Jekyll source directory set
375
+ Given I have a configuration file with:
376
+ | key | value |
377
+ | source | src |
378
+ And I have a scholar configuration with:
379
+ | key | value |
380
+ | source | _bibliography |
381
+ | style | _styles/custom.csl |
382
+ And I have a "src" directory
383
+ And I have a "src/_bibliography" directory
384
+ And I have a "src/_styles" directory
385
+ And I have a file "src/_styles/custom.csl":
386
+ """
387
+ <style>
388
+ <citation>
389
+ <layout>
390
+ <text variable="title"/>
391
+ </layout>
392
+ </citation>
393
+ <bibliography>
394
+ <layout>
395
+ <text variable="title"/>
396
+ </layout>
397
+ </bibliography>
398
+ </style>
399
+ """
400
+ And I have a file "src/_bibliography/references.bib":
401
+ """
402
+ @book{ruby,
403
+ title = {The Ruby Programming Language},
404
+ author = {Flanagan, David and Matsumoto, Yukihiro},
405
+ year = {2008},
406
+ publisher = {O'Reilly Media}
407
+ }
408
+ """
409
+ And I have a page "src/scholar.html":
410
+ """
411
+ ---
412
+ ---
413
+ {% bibliography --style _styles/custom.csl %}
414
+ """
415
+ When I run jekyll
416
+ Then the _site directory should exist
417
+ And I should see "The Ruby Programming Language" in "_site/scholar.html"
@@ -98,3 +98,52 @@ Feature: PDF Repository
98
98
  And the "_site/papers/ruby.pdf" file should exist
99
99
  And I should see "Link: /papers/ruby.pdf" in "_site/scholar.html"
100
100
  And I should see "Slides: /papers/ruby.ppt" in "_site/scholar.html"
101
+
102
+ @repository
103
+ Scenario: A bibliography with a single entry and a repository with slides pdf
104
+ Given I have a scholar configuration with:
105
+ | key | value |
106
+ | source | ./_bibliography |
107
+ | repository | papers |
108
+ | bibliography_template | bibliography |
109
+ | file_delimit | '.' |
110
+
111
+ And I have a "_bibliography" directory
112
+ And I have a file "_bibliography/references.bib":
113
+ """
114
+ @book{ruby,
115
+ title = {The Ruby Programming Language},
116
+ author = {Flanagan, David and Matsumoto, Yukihiro},
117
+ year = {2008},
118
+ publisher = {O'Reilly Media}
119
+ }
120
+ """
121
+ And I have a "papers" directory
122
+ And I have a file "papers/ruby.pdf":
123
+ """
124
+ The PDF
125
+ """
126
+ And I have a file "papers/ruby.slides.pdf":
127
+ """
128
+ The Slides PDF
129
+ """
130
+ And I have a "_layouts" directory
131
+ And I have a file "_layouts/bibliography.html":
132
+ """
133
+ ---
134
+ ---
135
+ {{ reference }} Link: {{ link }} Slides: {{ links['slides.pdf'] }}
136
+ """
137
+ And I have a page "scholar.html":
138
+ """
139
+ ---
140
+ ---
141
+ {% bibliography %}
142
+ """
143
+ When I run jekyll
144
+ Then the _site directory should exist
145
+ And the "_site/papers/ruby.pdf" file should exist
146
+ And the "_site/papers/ruby.slides.pdf" file should exist
147
+ And I should see "The Ruby Programming Language" in "_site/scholar.html"
148
+ And I should see "Link: /papers/ruby.pdf" in "_site/scholar.html"
149
+ And I should see "Slides: /papers/ruby.slides.pdf" in "_site/scholar.html"
@@ -1,23 +1,40 @@
1
1
  module Jekyll
2
2
  class Scholar
3
3
  @defaults = {
4
+ # Style used for citations and bibliographies
4
5
  'style' => 'apa',
6
+ # Sets languages used in bibliography
5
7
  'locale' => 'en',
6
8
 
9
+ # Keys used to sort bibliography
7
10
  'sort_by' => 'none',
11
+ # Order used to sort biobliography
8
12
  'order' => 'ascending',
9
13
  'group_by' => 'none',
10
14
  'group_order' => 'ascending',
15
+ # HTML tags used for bibliography group names
11
16
  'bibliography_group_tag' => 'h2,h3,h4,h5',
17
+ # HTML tag used for list of bibliography entries
12
18
  'bibliography_list_tag' => 'ol',
19
+ # HTML tag used for individual bibliography entries
13
20
  'bibliography_item_tag' => 'li',
21
+ # Attributes applied to HTML tag for list of bibliography entries
14
22
  'bibliography_list_attributes' => {},
23
+ # Attributes applied to HTML tag for bibliography entries
15
24
  'bibliography_item_attributes' => {},
16
25
 
26
+ # Name of folder references files are stored in
17
27
  'source' => './_bibliography',
28
+ # Name of default references file
18
29
  'bibliography' => 'references.bib',
30
+
31
+ # The repository folder with your entries' attachemnts, slides, etc.
19
32
  'repository' => nil,
20
33
 
34
+ # Delimiter for files in repositories;
35
+ # this character may not be part of your entry keys!
36
+ 'repository_file_delimiter' => '.',
37
+
21
38
  'bibtex_options' => { :strip => false, :parse_months => true },
22
39
  'bibtex_filters' => [ :superscript, :latex ],
23
40
  'bibtex_skip_fields' => [ :abstract, :month_numeric ],
@@ -59,7 +76,8 @@ module Jekyll
59
76
  },
60
77
  'type_order' => [],
61
78
 
62
- 'month_names' => nil,
79
+ 'month_names' => nil
80
+
63
81
  }.freeze
64
82
 
65
83
  class << self
@@ -79,7 +79,7 @@ module Jekyll
79
79
  end
80
80
  group_renderer(groups,group_keys,group_order,group_tags)
81
81
  end
82
-
82
+
83
83
  def render_items(items)
84
84
  bibliography = items.each_with_index.map { |entry, index|
85
85
  reference = bibliography_tag(entry, index + 1)
@@ -96,7 +96,7 @@ module Jekyll
96
96
  { :class => config['bibliography_class'] }.merge(config['bibliography_list_attributes'])
97
97
 
98
98
  end
99
-
99
+
100
100
  end
101
101
 
102
102
  end
@@ -5,12 +5,7 @@ module Jekyll
5
5
  # Load styles into static memory.
6
6
  # They should be thread safe as long as they are
7
7
  # treated as being read-only.
8
- STYLES = Hash.new do |h, k|
9
- style = CSL::Style.load k
10
- style = style.independent_parent unless style.independent?
11
- h[k.to_s] = style
12
- end
13
-
8
+ STYLES = {}
14
9
 
15
10
  # Utility methods used by several Scholar plugins. The methods in this
16
11
  # module may depend on the presence of #config, #bibtex_files, and
@@ -239,6 +234,7 @@ module Jekyll
239
234
  grouper(ungrouped, group_keys, group_order)
240
235
  end
241
236
 
237
+
242
238
  def group_keys
243
239
  return @group_keys unless @group_keys.nil?
244
240
 
@@ -351,14 +347,15 @@ module Jekyll
351
347
  repo = Hash.new { |h,k| h[k] = {} }
352
348
 
353
349
  return repo unless repository?
354
-
355
- # ensure that the base directory format is literally
350
+
351
+ # ensure that the base directory format is literally
356
352
  # the same as the entries that are in the directory
357
- base = Dir[site.source][0]
358
-
353
+ base = Dir[site.source][0]
354
+
359
355
  Dir[File.join(site.source, repository_path, '**/*')].each do |path|
360
- extname = File.extname(path)
361
- repo[File.basename(path, extname)][extname[1..-1]] = Pathname(path).relative_path_from(Pathname(base))
356
+ parts = path.split(repository_file_delimiter, 2)
357
+ repo[File.basename(parts[0])][parts[1]] =
358
+ Pathname(path).relative_path_from(Pathname(base))
362
359
  end
363
360
 
364
361
  repo
@@ -368,6 +365,10 @@ module Jekyll
368
365
  config['repository']
369
366
  end
370
367
 
368
+ def repository_file_delimiter
369
+ config['repository_file_delimiter']
370
+ end
371
+
371
372
  def replace_strings?
372
373
  config['replace_strings']
373
374
  end
@@ -400,7 +401,7 @@ module Jekyll
400
401
 
401
402
  def scholar_source
402
403
  source = config['source']
403
-
404
+
404
405
  # Improve by using Pathname from stdlib?
405
406
  return source if source.start_with?('/') && File.exists?(source)
406
407
 
@@ -455,7 +456,7 @@ module Jekyll
455
456
 
456
457
  def bibliography_tag(entry, index)
457
458
  return missing_reference unless entry
458
-
459
+
459
460
  tmp = liquid_template.render(
460
461
  reference_data(entry,index)
461
462
  .merge(site.site_payload)
@@ -471,7 +472,7 @@ module Jekyll
471
472
  # process the generated reference with Liquid, to get the same behaviour as
472
473
  # when it is used on a page
473
474
  Liquid::Template.parse(tmp).render(
474
- site.site_payload,
475
+ site.site_payload,
475
476
  {
476
477
  :registers => { :site => site },
477
478
  :filters => [Jekyll::Filters]
@@ -592,12 +593,12 @@ module Jekyll
592
593
  item.label = label unless label.nil?
593
594
 
594
595
  item
595
- }, STYLES[style].citation
596
+ }, styles(style).citation
596
597
  end
597
598
 
598
599
  def render_bibliography(entry, index = nil)
599
600
  renderer.render citation_item_for(entry, index),
600
- STYLES[style].bibliography
601
+ styles(style).bibliography
601
602
  end
602
603
 
603
604
  def citation_item_for(entry, citation_number = nil)
@@ -687,6 +688,29 @@ module Jekyll
687
688
  config.merge!(site.config['scholar'] || {})
688
689
  self
689
690
  end
691
+
692
+ def load_style(uri)
693
+ begin
694
+ style = CSL::Style.load uri
695
+ rescue CSL::ParseError => error
696
+ # Try to resolve local style paths
697
+ # relative to Jekyll's source directory
698
+ site_relative_style = File.join(site.source, uri)
699
+
700
+ raise error unless File.exist?(site_relative_style)
701
+ style = CSL::Style.load site_relative_style
702
+ end
703
+
704
+ if style.independent?
705
+ style
706
+ else
707
+ style.independent_parent
708
+ end
709
+ end
710
+
711
+ def styles(style)
712
+ STYLES[style] ||= load_style(style)
713
+ end
690
714
  end
691
715
 
692
716
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  class Scholar
3
- VERSION = '5.8.5'.freeze
3
+ VERSION = '5.9.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.8.5
4
+ version: 5.9.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-10-03 00:00:00.000000000 Z
11
+ date: 2017-01-24 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.6.3
144
+ rubygems_version: 2.6.8
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Jekyll extensions for the academic blogger.