Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
J
jekyll-scholar
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
caesr-pub
jekyll-scholar
Commits
9ecfd78c
Commit
9ecfd78c
authored
Jan 21, 2015
by
Sylvester Keil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert nil to bibtex value when sorting
fix #77
parent
be176478
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
features/sorting.feature
features/sorting.feature
+36
-0
lib/jekyll/scholar/utilities.rb
lib/jekyll/scholar/utilities.rb
+4
-1
No files found.
features/sorting.feature
View file @
9ecfd78c
...
...
@@ -34,6 +34,42 @@ Feature: Sorting BibTeX Bibliographies
And
the
"_site/scholar.html"
file should exist
Then
"2007"
should come before
"2008"
in
"_site/scholar.html"
@tags
@sorting
Scenario
:
Sort By Year With Nil Values
Given I have a scholar configuration with
:
|
key
|
value
|
|
sort_by
|
year
|
And
I have a
"_bibliography"
directory
And I have a file "_bibliography/references.bib"
:
"""
@book{ruby1,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
@book{ruby2,
title = {Nil}
}
@book{ruby3,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2007},
publisher = {O'Reilly Media}
}
"""
And I have a page "scholar.html"
:
"""
---
---
{% bibliography -f references %}
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
Then
"Nil"
should come before
"Ruby"
in
"_site/scholar.html"
And
"2007"
should come before
"2008"
in
"_site/scholar.html"
@tags
@sorting
Scenario
:
Reverse Sort Order
Given I have a scholar configuration with
:
...
...
lib/jekyll/scholar/utilities.rb
View file @
9ecfd78c
...
...
@@ -141,7 +141,10 @@ module Jekyll
def
sort
(
unsorted
)
return
unsorted
if
skip_sort?
sorted
=
unsorted
.
sort_by
{
|
e
|
e
.
values_at
(
*
sort_keys
)
}
sorted
=
unsorted
.
sort_by
do
|
e
|
e
.
values_at
(
*
sort_keys
).
map
{
|
v
|
v
.
nil?
?
BibTeX
::
Value
.
new
:
v
}
end
sorted
.
reverse!
if
config
[
'order'
]
=~
/^(desc|reverse)/i
sorted
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment