jekyll-scholar 6.6.0 → 7.0.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
  SHA256:
3
- metadata.gz: 553c6ce018f518f25bb57bd76a547da001554588f947d158db5630ca3a863294
4
- data.tar.gz: 8e18201f73e7157d096d84447c6fc526dbe6094b8bcf4f43a407d91b780ff3b9
3
+ metadata.gz: f0e78bd7c9317137c98678772de2dcc7299fcc02f44c9f425334100b87c2f369
4
+ data.tar.gz: f78feb1a7fccce706830d2a3956bdbf0b3ec4245576e2b454492b20bb6832877
5
5
  SHA512:
6
- metadata.gz: 98d42799eb2356464ef26cef26cff2de39e1e3b39352ec4bb77e41c5a70dc9fe39dafc4ad8b4fc0a261c90530ea9bc5152e5b66468c3715f422910bf96061a89
7
- data.tar.gz: '09f0301742a895a3cb8a1d09a604715bf79034cb08f55b946bf3733999700f69d4adc537befd01f376e9bd4d06bb26891f97ef290d1023acf4083c989ba08810'
6
+ metadata.gz: d6ee7f7510ca466d16ec3112ed47df4bfc02d8a17b736ab323d5ee5ac77d523ab3083dccf073bdb328be397006b67230cf7d8fcff4aaae4e9d8095ddd1665dd5
7
+ data.tar.gz: 5ea56025a3f93e3cbb3db96f81cc4bc7ffafa4524cdd53beec6b412b1c6d1fc331dc7b38c9d02e7704a89bc28dd51f4b377db8e97bc81805e1814a02deac1f21
data/README.md CHANGED
@@ -18,7 +18,7 @@ Installation
18
18
 
19
19
  Or add it to your `Gemfile`:
20
20
 
21
- gem 'jekyll-scholar'
21
+ gem 'jekyll-scholar', group: :jekyll_plugins
22
22
 
23
23
  ### Github Pages
24
24
 
@@ -53,10 +53,10 @@ configuration:
53
53
 
54
54
  In your Jekyll configuration file you can adjust the Jekyll-Scholar settings
55
55
  using the `scholar` key. For example, the following sets the bibliography style
56
- to `mla`.
56
+ to `modern-language-association`.
57
57
 
58
58
  scholar:
59
- style: mla
59
+ style: modern-language-association
60
60
 
61
61
  The table below describes some commonly used configuration options. For a
62
62
  description of all options and their defaults, see
@@ -64,7 +64,7 @@ description of all options and their defaults, see
64
64
 
65
65
  | Option | Default | Description |
66
66
  |--------|---------|-------------|
67
- | `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)). |
67
+ | `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, 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)). |
68
68
  | `locale` | `en` | Defines what language to use when formatting your references (this typically applies to localized terms, e.g., 'Eds.' for editors in English). |
69
69
  | `source` | `./_bibliography` | Indicates where your bibliographies are stored. |
70
70
  | `bibliography` | `references.bib` | Indicates the name of your default bibliography. For best results, please ensure that your bibliography is encoded as ASCII or UTF-8. A string that contains a `*` will be passed to `Dir::glob`, so `**/*.bib{,tex}` will find all files named `*.bib` and `*.bibtex` under `source`. |
@@ -74,6 +74,7 @@ description of all options and their defaults, see
74
74
  | `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. |
75
75
  | `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 }`. |
76
76
  | `bibtex_filters` | `latex,smallcaps,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, `smallcaps` converts the `\textsc` command into a HTML `<font style=\"font-variant: small-caps\">` tag, and `superscript` which converts the `\textsuperscript` command into a HTML `<sup>` tag. |
77
+ | `raw_bibtex_filters` | ` ` | Configures which [BibTeX-Ruby](https://github.com/inukshuk/bibtex-ruby) formatting filters the raw BiBTeX entry (i.e. that available through `{{ entry.bibtex }}`) should be passed through. This can be used to e.g. strip excess newlines by using the `linebreaks` filter. |
77
78
 
78
79
 
79
80
  ### Bibliographies
@@ -107,7 +107,7 @@ Feature: Details
107
107
  And I should see "Page title: An Umlaut \\\"a!" in "_site/bibliography/ruby.html"
108
108
  And I should see "Title: An Umlaut \\\"a!" in "_site/bibliography/ruby.html"
109
109
  And I should see "title = {An Umlaut \\\"a!}" in "_site/bibliography/ruby.html"
110
-
110
+
111
111
 
112
112
  @generators
113
113
  Scenario: Liquid tags should not be parsed inside the bibtex
@@ -438,8 +438,8 @@ Feature: Details
438
438
  And the "_site/scholar/index.html" file should exist
439
439
  And I should see "<a[^>]+href=\"/blog/bibliography/2008/10.0000/1111/\">" in "_site/scholar/index.html"
440
440
  And I should see "<a[^>]+href=\"/blog/bibliography/2018/ruby/\">" in "_site/scholar/index.html"
441
- And the "_site/blog/bibliography/2008/10.0000/1111/index.html" file should exist
442
- And the "_site/blog/bibliography/2018/ruby/index.html" file should exist
441
+ And the "_site/bibliography/2008/10.0000/1111/index.html" file should exist
442
+ And the "_site/bibliography/2018/ruby/index.html" file should exist
443
443
 
444
444
  @generators @parse_months
445
445
  Scenario: Months are parsed by default
@@ -609,3 +609,39 @@ Feature: BibTeX
609
609
  And the "_site/scholar.html" file should exist
610
610
  And I should see "This is <span class="tiny">i is tiny</span> to me." in "_site/scholar.html"
611
611
 
612
+ @tags @filters
613
+ Scenario: Apply raw BiBTeX filters
614
+ Given I have a scholar configuration with:
615
+ | key | value |
616
+ | source | ./_bibliography |
617
+ | bibliography_template | bibliography |
618
+ And I have the following raw BibTeX filters:
619
+ | linebreaks |
620
+ And I have a "_bibliography" directory
621
+ And I have a file "_bibliography/references.bib":
622
+ """
623
+ @misc{pickaxe,
624
+ title = {Long
625
+ line},
626
+ series = {Longer
627
+ line}
628
+ }
629
+ """
630
+ And I have a "_layouts" directory
631
+ And I have a file "_layouts/bibliography.html":
632
+ """
633
+ ---
634
+ ---
635
+ {{ entry.bibtex }}
636
+ """
637
+ And I have a page "scholar.html":
638
+ """
639
+ ---
640
+ ---
641
+ {% bibliography %}
642
+ """
643
+ When I run jekyll
644
+ Then the _site directory should exist
645
+ And the "_site/scholar.html" file should exist
646
+ And I should see "@misc{pickaxe,\n title = {Long line},\n series = {Longer line}" in "_site/scholar.html"
647
+
@@ -0,0 +1,72 @@
1
+ Feature: Page Configuration
2
+ As a scholar who likes to blog
3
+ I want to set local jekyll-scholar options per page
4
+ In order to override the global config
5
+
6
+ @tags @filters
7
+ Scenario: Filter by Year
8
+ Given I have a scholar configuration with:
9
+ | key | value |
10
+ | source | ./_bibliography |
11
+ | query | "@*[year=2009]" |
12
+ And I have a "_bibliography" directory
13
+ And I have a file "_bibliography/references.bib":
14
+ """
15
+ @book{ruby,
16
+ title = {The Ruby Programming Language},
17
+ author = {Flanagan, David and Matsumoto, Yukihiro},
18
+ year = {2008},
19
+ publisher = {O'Reilly Media}
20
+ }
21
+ @book{pickaxe,
22
+ title = {Programming Ruby 1.9: The Pragmatic Programmer's Guide},
23
+ author = {Thomas, Dave and Fowler, Chad and Hunt, Andy},
24
+ year = {2009},
25
+ edition = 3,
26
+ publisher = {Pragmatic Bookshelf}
27
+ }
28
+ """
29
+ And I have a page "scholar.html":
30
+ """
31
+ ---
32
+ scholar:
33
+ query: "@*[year=2008]"
34
+ ---
35
+ {% bibliography %}
36
+ """
37
+ When I run jekyll
38
+ Then the _site directory should exist
39
+ And the "_site/scholar.html" file should exist
40
+ And I should see "The Ruby Programming Language" in "_site/scholar.html"
41
+ And I should not see "Programming Ruby" in "_site/scholar.html"
42
+
43
+
44
+ @tags
45
+ Scenario: Template access to page config
46
+ Given I have a scholar configuration with:
47
+ | key | value |
48
+ | source | ./_bibliography |
49
+ | bibliography_template | <p>{{page.scholar.x}}</p> |
50
+ And I have a "_bibliography" directory
51
+ And I have a file "_bibliography/references.bib":
52
+ """
53
+ @book{ruby,
54
+ title = {The Ruby Programming Language},
55
+ author = {Flanagan, David and Matsumoto, Yukihiro},
56
+ year = {2008},
57
+ publisher = {O'Reilly Media}
58
+ }
59
+ """
60
+ And I have a page "scholar.html":
61
+ """
62
+ ---
63
+ scholar:
64
+ x: Asa-Nisi-Masa
65
+ ---
66
+ {% bibliography %}
67
+ """
68
+ When I run jekyll
69
+ Then the _site directory should exist
70
+ And the "_site/scholar.html" file should exist
71
+ And I should see "<p>Asa-Nisi-Masa</p>" in "_site/scholar.html"
72
+
@@ -36,6 +36,15 @@ Given(/^I have the following BibTeX filters:$/) do |table|
36
36
  end
37
37
  end
38
38
 
39
+ Given(/^I have the following raw BibTeX filters:$/) do |table|
40
+ File.open('_config.yml', 'a') do |f|
41
+ f.write(" raw_bibtex_filters:\n")
42
+ table.raw.flatten.each do |row|
43
+ f.write(" - #{row}\n")
44
+ end
45
+ end
46
+ end
47
+
39
48
  Then(/^"(.*)" should come before "(.*)" in "(.*)"$/) do |p1, p2, file|
40
49
  data = File.open(file).readlines.join('')
41
50
 
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.add_runtime_dependency('jekyll', '~> 4.0')
28
28
  s.add_runtime_dependency('citeproc-ruby', '~> 1.0')
29
29
  s.add_runtime_dependency('csl-styles', '~> 1.0')
30
- s.add_runtime_dependency('bibtex-ruby', '~> 5.0')
30
+ s.add_runtime_dependency('bibtex-ruby', '~> 6.0')
31
31
 
32
32
  s.files = `git ls-files`.split("\n")
33
33
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -37,6 +37,7 @@ module Jekyll
37
37
 
38
38
  'bibtex_options' => { :strip => false, :parse_months => true },
39
39
  'bibtex_filters' => [ :smallcaps, :superscript, :italics, :textit, :lowercase, :textregistered, :tiny, :latex ],
40
+ 'raw_bibtex_filters' => [ ],
40
41
  'bibtex_skip_fields' => [ :abstract, :month_numeric ],
41
42
  'bibtex_quotes' => ['{', '}'],
42
43
 
@@ -23,7 +23,7 @@ module Jekyll
23
23
 
24
24
  def url
25
25
  # Reuse the logic in the utilities module for deciding URLs
26
- details_link_for(@entry)
26
+ details_path_for(@entry)
27
27
  end
28
28
  end
29
29
 
@@ -1,6 +1,5 @@
1
1
  module Jekyll
2
2
  class Scholar
3
-
4
3
  class BibliographyTag < Liquid::Tag
5
4
  include Scholar::Utilities
6
5
 
@@ -34,7 +33,7 @@ module Jekyll
34
33
  def render_groups(groups)
35
34
  def group_renderer(groupsOrItems,keys,order,tags)
36
35
  if keys.count == 0
37
- renderer(true)
36
+ csl_renderer(true)
38
37
  render_items(groupsOrItems)
39
38
  else
40
39
  groupsOrItems
@@ -1,6 +1,5 @@
1
1
  module Jekyll
2
2
  class Scholar
3
-
4
3
  class BibTeXTag < Liquid::Block
5
4
  include Scholar::Utilities
6
5
 
@@ -15,16 +14,13 @@ module Jekyll
15
14
 
16
15
  def render(context)
17
16
  set_context_to context
18
-
17
+
19
18
  BibTeX.parse(super, bibtex_options).map { |entry|
20
19
  reference_tag entry
21
-
22
20
  }.join("\n")
23
21
  end
24
22
  end
25
-
26
23
  end
27
24
  end
28
25
 
29
26
  Liquid::Template.register_tag('bibtex', Jekyll::Scholar::BibTeXTag)
30
-
@@ -165,6 +165,10 @@ module Jekyll
165
165
  config['bibtex_filters'] ||= []
166
166
  end
167
167
 
168
+ def raw_bibtex_filters
169
+ config['raw_bibtex_filters'] ||= []
170
+ end
171
+
168
172
  def bibtex_paths
169
173
  bibtex_files.map { |file|
170
174
  interpolated_file = interpolate file
@@ -523,10 +527,11 @@ module Jekyll
523
527
  .merge(site.site_payload)
524
528
  .merge({
525
529
  'index' => index,
530
+ 'page' => context.registers[:page],
526
531
  'details' => details_link_for(entry)
527
532
  }),
528
533
  {
529
- :registers => { :site => site },
534
+ :registers => context.registers,
530
535
  :filters => [Jekyll::Filters]
531
536
  })
532
537
  end
@@ -548,8 +553,13 @@ module Jekyll
548
553
  e['key'] = entry.key
549
554
  e['type'] = entry.type.to_s
550
555
 
556
+ conv_opts = { quotes: config['bibtex_quotes'] }
557
+ if !raw_bibtex_filters.empty?
558
+ conv_opts[:filter] = *raw_bibtex_filters
559
+ end
560
+
551
561
  if entry.field_names(config['bibtex_skip_fields']).empty?
552
- e['bibtex'] = entry.to_s({ quotes: config['bibtex_quotes'] })
562
+ e['bibtex'] = entry.to_s(conv_opts)
553
563
  else
554
564
  tmp = entry.dup
555
565
 
@@ -557,7 +567,7 @@ module Jekyll
557
567
  tmp.delete name if tmp.field?(name)
558
568
  end
559
569
 
560
- e['bibtex'] = tmp.to_s({ quotes: config['bibtex_quotes'] })
570
+ e['bibtex'] = tmp.to_s(conv_opts)
561
571
  end
562
572
 
563
573
  #e['raw_bibtex'] = "{%raw%}#{e['bibtex']}{%endraw%}"
@@ -606,6 +616,10 @@ module Jekyll
606
616
  end
607
617
 
608
618
  def details_link_for(entry, base = base_url)
619
+ File.join(base, details_path_for(entry))
620
+ end
621
+
622
+ def details_path_for(entry)
609
623
  # Expand the details_permalink template into the complete URL for this entry.
610
624
 
611
625
  # First generate placeholders for all items in the bibtex entry
@@ -615,29 +629,30 @@ module Jekyll
615
629
  value = Jekyll::Utils::slugify(value, :mode => 'pretty') unless k == :doi
616
630
  url_placeholders[k] = value
617
631
  end
618
- # Maintain the same URLs are previous versions of jekyll-scholar by replicating the way that it
619
- # processed the key.
632
+ # Maintain the same URLs are previous versions of jekyll-scholar
633
+ # by replicating the way that it processed the key.
620
634
  url_placeholders[:key] = entry.key.to_s.gsub(/[:\s]+/, '_')
621
635
  url_placeholders[:details_dir] = details_path
622
- # Autodetect the appropriate file extension based upon the site config, using the same rules as
623
- # previous versions of jekyll-scholar. Uses can override these settings by defining a details_permalink
636
+
637
+ # Autodetect the appropriate file extension based upon the site config,
638
+ # using the same rules as previous versions of jekyll-scholar. Users can
639
+ # override these settings by defining a details_permalink
624
640
  # without the :extension field.
625
641
  if (site.config['permalink'] == 'pretty') || (site.config['permalink'].end_with? '/')
626
642
  url_placeholders[:extension] = '/'
627
643
  else
628
644
  url_placeholders[:extension] = '.html'
629
645
  end
630
- # Overwrite the 'doi' key with the citation key if the DOI field is empty or missing
646
+
647
+ # Overwrite 'doi' key with the citation key if DOI field is empty or missing
631
648
  if !entry.has_field?('doi') || entry.doi.empty?
632
649
  url_placeholders[:doi] = url_placeholders[:key]
633
650
  end
634
651
 
635
- # generate the URL
636
- File.join(base,
637
- URL.new(
638
- :template => config['details_permalink'],
639
- :placeholders => url_placeholders
640
- ).to_s)
652
+ URL.new(
653
+ template: config['details_permalink'],
654
+ placeholders: url_placeholders
655
+ ).to_s
641
656
  end
642
657
 
643
658
  def base_url
@@ -648,15 +663,15 @@ module Jekyll
648
663
  config['details_dir']
649
664
  end
650
665
 
651
- def renderer(force = false)
652
- return @renderer if @renderer && !force
666
+ def csl_renderer(force = false)
667
+ return @csl_renderer if @csl_renderer && !force
653
668
 
654
- @renderer = CiteProc::Ruby::Renderer.new :format => 'html',
669
+ @csl_renderer = CiteProc::Ruby::Renderer.new :format => 'html',
655
670
  :style => style, :locale => config['locale']
656
671
  end
657
672
 
658
673
  def render_citation(items)
659
- renderer.render items.zip(locators.zip(labels)).map { |entry, (locator, label)|
674
+ csl_renderer.render items.zip(locators.zip(labels)).map { |entry, (locator, label)|
660
675
  cited_keys << entry.key
661
676
  cited_keys.uniq!
662
677
 
@@ -670,17 +685,17 @@ module Jekyll
670
685
 
671
686
  def render_bibliography(entry, index = nil)
672
687
  begin
673
- original_locale, renderer.locale =
674
- renderer.locale, locales(entry.language)
688
+ original_locale = csl_renderer.locale
689
+ csl_renderer.locale = locales(entry.language)
675
690
  rescue
676
691
  # Locale failed to load; just use original one!
677
692
  end if allow_locale_overrides? &&
678
- entry['language'] != renderer.locale.language
693
+ entry['language'] != csl_renderer.locale.language
679
694
 
680
- renderer.render citation_item_for(entry, index),
695
+ csl_renderer.render citation_item_for(entry, index),
681
696
  styles(style).bibliography
682
697
  ensure
683
- renderer.locale = original_locale unless original_locale.nil?
698
+ csl_renderer.locale = original_locale unless original_locale.nil?
684
699
  end
685
700
 
686
701
  def citation_item_for(entry, citation_number = nil)
@@ -774,8 +789,9 @@ module Jekyll
774
789
  end
775
790
 
776
791
  def set_context_to(context)
777
- @context, @site, = context, context.registers[:site]
792
+ @context, @site, page, = context, *context.registers.values_at(:site, :page)
778
793
  config.merge!(site.config['scholar'] || {})
794
+ config.merge!(page['scholar'] || {})
779
795
  self
780
796
  end
781
797
 
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  class Scholar
3
- VERSION = '6.6.0'.freeze
3
+ VERSION = '7.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: 6.6.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-24 00:00:00.000000000 Z
11
+ date: 2021-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '5.0'
61
+ version: '6.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '5.0'
68
+ version: '6.0'
69
69
  description: " Jekyll-Scholar is for all the academic bloggers out there. It is a
70
70
  set of extensions for Jekyll the awesome, blog aware, static site generator; it
71
71
  formats your BibTeX bibliographies for the web using CSL citation styles and generally
@@ -97,6 +97,7 @@ files:
97
97
  - features/interpolate.feature
98
98
  - features/layout.feature
99
99
  - features/multiple_files.feature
100
+ - features/page_config.feature
100
101
  - features/reference.feature
101
102
  - features/removeduplicate.feature
102
103
  - features/repository.feature
@@ -134,7 +135,7 @@ homepage: http://github.com/inukshuk/jekyll-scholar
134
135
  licenses:
135
136
  - MIT
136
137
  metadata: {}
137
- post_install_message:
138
+ post_install_message:
138
139
  rdoc_options: []
139
140
  require_paths:
140
141
  - lib
@@ -149,8 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
150
  - !ruby/object:Gem::Version
150
151
  version: 1.3.6
151
152
  requirements: []
152
- rubygems_version: 3.1.2
153
- signing_key:
153
+ rubygems_version: 3.2.3
154
+ signing_key:
154
155
  specification_version: 4
155
156
  summary: Jekyll extensions for the academic blogger.
156
157
  test_files:
@@ -167,6 +168,7 @@ test_files:
167
168
  - features/interpolate.feature
168
169
  - features/layout.feature
169
170
  - features/multiple_files.feature
171
+ - features/page_config.feature
170
172
  - features/reference.feature
171
173
  - features/removeduplicate.feature
172
174
  - features/repository.feature