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
9ba3a05e
Commit
9ba3a05e
authored
May 23, 2014
by
Sylvester Keil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add --cited_in_order option
see discussion at #44 for details
parent
86f7aee6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
13 deletions
+68
-13
features/citation.feature
features/citation.feature
+1
-1
features/sorting.feature
features/sorting.feature
+40
-0
lib/jekyll/scholar/tags/bibliography.rb
lib/jekyll/scholar/tags/bibliography.rb
+15
-7
lib/jekyll/scholar/utilities.rb
lib/jekyll/scholar/utilities.rb
+12
-5
No files found.
features/citation.feature
View file @
9ba3a05e
...
@@ -278,7 +278,7 @@ Feature: Citations
...
@@ -278,7 +278,7 @@ Feature: Citations
And
the
"_site/scholar.html"
file should exist
And
the
"_site/scholar.html"
file should exist
And
I should see
"Flanagan"
in
"_site/scholar.html"
And
I should see
"Flanagan"
in
"_site/scholar.html"
@tags
@cite
@variables
@data
@wip
@tags
@cite
@variables
@data
Scenario
:
Multiple Citations in a list using liquid variables
Scenario
:
Multiple Citations in a list using liquid variables
Given I have a scholar configuration with
:
Given I have a scholar configuration with
:
|
key
|
value
|
|
key
|
value
|
...
...
features/sorting.feature
View file @
9ba3a05e
...
@@ -150,3 +150,43 @@ Feature: Sorting BibTeX Bibliographies
...
@@ -150,3 +150,43 @@ Feature: Sorting BibTeX Bibliographies
Then
"Ruby Programming"
should come before
"Smalltalk"
in
"_site/scholar.html"
Then
"Ruby Programming"
should come before
"Smalltalk"
in
"_site/scholar.html"
And
I should not see
"<i>Ruby Not Cited</i>"
in
"_site/scholar.html"
And
I should not see
"<i>Ruby Not Cited</i>"
in
"_site/scholar.html"
@tags
@sorting
@cited_in_order
Scenario
:
Sort By Year Cited in Order
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 = {Ruby Not Cited},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2007},
publisher = {O'Reilly Media}
}
@book{smalltalk,
title = {Smalltalk Best Practice Patterns},
author = {Kent Beck},
year = {1996},
publisher = {Prentice Hall}
}
"""
And I have a page "scholar.html"
:
"""
---
---
{% cite ruby1 %}
{% cite smalltalk %}
{% bibliography --cited_in_order %}
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
Then
"Ruby Programming"
should come before
"Smalltalk"
in
"_site/scholar.html"
And
I should not see
"<i>Ruby Not Cited</i>"
in
"_site/scholar.html"
lib/jekyll/scholar/tags/bibliography.rb
View file @
9ba3a05e
...
@@ -15,15 +15,23 @@ module Jekyll
...
@@ -15,15 +15,23 @@ module Jekyll
def
render
(
context
)
def
render
(
context
)
set_context_to
context
set_context_to
context
references
=
entries
items
=
entries
references
.
select!
do
|
e
|
if
cited_only?
cited_references
.
include?
e
.
key
items
=
if
skip_sort?
end
if
cited_only?
cited_references
.
uniq
.
map
do
|
key
|
items
.
detect
{
|
e
|
e
.
key
==
key
}
end
else
entries
.
select
do
|
e
|
cited_references
.
include?
e
.
key
end
end
end
references
=
reference
s
.
take
(
max
.
to_i
)
if
limit_entries?
items
=
item
s
.
take
(
max
.
to_i
)
if
limit_entries?
bibliography
=
reference
s
.
each_with_index
.
map
{
|
entry
,
index
|
bibliography
=
item
s
.
each_with_index
.
map
{
|
entry
,
index
|
reference
=
bibliography_tag
(
entry
,
index
+
1
)
reference
=
bibliography_tag
(
entry
,
index
+
1
)
if
generate_details?
if
generate_details?
...
...
lib/jekyll/scholar/utilities.rb
View file @
9ba3a05e
...
@@ -35,6 +35,10 @@ module Jekyll
...
@@ -35,6 +35,10 @@ module Jekyll
@cited
=
true
@cited
=
true
end
end
opts
.
on
(
'-C'
,
'--cited_in_order'
)
do
|
cited
|
@cited
,
@skip_sort
=
true
,
true
end
opts
.
on
(
'-f'
,
'--file FILE'
)
do
|
file
|
opts
.
on
(
'-f'
,
'--file FILE'
)
do
|
file
|
@bibtex_files
||=
[]
@bibtex_files
||=
[]
@bibtex_files
<<
file
@bibtex_files
<<
file
...
@@ -69,7 +73,7 @@ module Jekyll
...
@@ -69,7 +73,7 @@ module Jekyll
end
end
end
end
argv
=
arguments
.
split
(
/(\B-[c
fqptTslm]|\B--(?:cited
|file|query|prefix|text|style|template|locator|max|))/
)
argv
=
arguments
.
split
(
/(\B-[c
CfqptTslm]|\B--(?:cited(_in_order)?
|file|query|prefix|text|style|template|locator|max|))/
)
parser
.
parse
argv
.
map
(
&
:strip
).
reject
(
&
:empty?
)
parser
.
parse
argv
.
map
(
&
:strip
).
reject
(
&
:empty?
)
end
end
...
@@ -128,7 +132,7 @@ module Jekyll
...
@@ -128,7 +132,7 @@ module Jekyll
end
end
def
sort
(
unsorted
)
def
sort
(
unsorted
)
return
unsorted
if
config
[
'sort_by'
]
==
'none'
return
unsorted
if
skip_sort?
sorted
=
unsorted
.
sort_by
{
|
e
|
e
[
config
[
'sort_by'
]].
to_s
}
sorted
=
unsorted
.
sort_by
{
|
e
|
e
[
config
[
'sort_by'
]].
to_s
}
sorted
.
reverse!
if
config
[
'order'
]
=~
/^(desc|reverse)/i
sorted
.
reverse!
if
config
[
'order'
]
=~
/^(desc|reverse)/i
...
@@ -167,6 +171,10 @@ module Jekyll
...
@@ -167,6 +171,10 @@ module Jekyll
!!
@cited
!!
@cited
end
end
def
skip_sort?
@skip_sort
||
config
[
'sort_by'
]
==
'none'
end
def
extend_path
(
name
)
def
extend_path
(
name
)
if
name
.
nil?
||
name
.
empty?
if
name
.
nil?
||
name
.
empty?
name
=
config
[
'bibliography'
]
name
=
config
[
'bibliography'
]
...
@@ -327,9 +335,6 @@ module Jekyll
...
@@ -327,9 +335,6 @@ module Jekyll
def
cite
(
keys
)
def
cite
(
keys
)
items
=
keys
.
map
do
|
key
|
items
=
keys
.
map
do
|
key
|
# dereference variables in current scope
key
=
context
.
scopes
.
last
[
key
]
||
key
if
bibliography
.
key?
(
key
)
if
bibliography
.
key?
(
key
)
entry
=
bibliography
[
key
]
entry
=
bibliography
[
key
]
entry
=
entry
.
convert
(
*
bibtex_filters
)
unless
bibtex_filters
.
empty?
entry
=
entry
.
convert
(
*
bibtex_filters
)
unless
bibtex_filters
.
empty?
...
@@ -375,6 +380,8 @@ module Jekyll
...
@@ -375,6 +380,8 @@ module Jekyll
def
keys
def
keys
# De-reference keys (in case they are variables)
# De-reference keys (in case they are variables)
# We need to do this every time, to support for loops,
# where the context can change for each invocation.
Array
(
@keys
).
map
do
|
key
|
Array
(
@keys
).
map
do
|
key
|
context
.
send
(
:resolve
,
key
)
||
key
context
.
send
(
:resolve
,
key
)
||
key
end
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