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
ab9e4ad5
Commit
ab9e4ad5
authored
Apr 13, 2014
by
Sylvester Keil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add citation number support
fix #34
parent
b99e77ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
9 deletions
+53
-9
features/citation.feature
features/citation.feature
+35
-0
lib/jekyll/scholar/utilities.rb
lib/jekyll/scholar/utilities.rb
+18
-9
No files found.
features/citation.feature
View file @
ab9e4ad5
...
...
@@ -180,3 +180,38 @@ Feature: Citations
And
the
"_site/scholar.html"
file should exist
And
I should see
"Matsumoto, 2008, pp. 2-3; Shaughnessy, 2013, pp. 23 & 42"
in
"_site/scholar.html"
@tags
@cite
@citation_number
Scenario
:
Multiple citations using citation numbers
Given I have a scholar configuration with
:
|
key
|
value
|
|
source
|
./_bibliography
|
|
bibliography
|
my_references
|
|
style
|
ieee
|
And
I have a
"_bibliography"
directory
And I have a file "_bibliography/my_references.bib"
:
"""
@book{ruby,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
@book{microscope,
title = {Ruby Under a Microscope},
author = {Pat Shaughnessy},
year = {2013},
publisher = {No Starch Press}
}
"""
And I have a page "scholar.html"
:
"""
---
---
{% cite ruby microscope %}
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
And
I should see
"\[1\], \[2\]"
in
"_site/scholar.html"
lib/jekyll/scholar/utilities.rb
View file @
ab9e4ad5
...
...
@@ -166,11 +166,11 @@ module Jekyll
p
end
def
reference_tag
(
entry
)
def
reference_tag
(
entry
,
index
=
nil
)
return
missing_reference
unless
entry
entry
=
entry
.
convert
(
*
bibtex_filters
)
unless
bibtex_filters
.
empty?
reference
=
render_bibliography
entry
reference
=
render_bibliography
entry
,
index
content_tag
reference_tagname
,
reference
,
:id
=>
[
prefix
,
entry
.
key
].
compact
.
join
(
'-'
)
...
...
@@ -212,7 +212,7 @@ module Jekyll
liquid_template
.
render
({
'entry'
=>
liquidify
(
entry
),
'reference'
=>
reference_tag
(
entry
),
'reference'
=>
reference_tag
(
entry
,
index
),
'key'
=>
entry
.
key
,
'type'
=>
entry
.
type
,
'link'
=>
repository_link_for
(
entry
),
...
...
@@ -280,19 +280,24 @@ module Jekyll
def
render_citation
(
items
)
renderer
.
render
items
.
zip
(
locators
).
map
{
|
entry
,
locator
|
item
=
citation_item_for
entry
cited_keys
<<
entry
.
key
item
=
citation_item_for
entry
,
citation_number
item
.
locator
=
locator
item
},
STYLES
[
style
].
citation
end
def
render_bibliography
(
entry
)
renderer
.
render
citation_item_for
(
entry
),
STYLES
[
style
].
bibliography
def
render_bibliography
(
entry
,
index
=
nil
)
renderer
.
render
citation_item_for
(
entry
,
index
),
STYLES
[
style
].
bibliography
end
def
citation_item_for
(
entry
)
def
citation_item_for
(
entry
,
citation_number
=
nil
)
CiteProc
::
CitationItem
.
new
id:
entry
.
id
do
|
c
|
c
.
data
=
CiteProc
::
Item
.
new
entry
.
to_citeproc
c
.
data
[
:'citation-number'
]
=
citation_number
end
end
...
...
@@ -300,10 +305,14 @@ module Jekyll
context
[
'cited'
]
||=
[]
end
def
citation_number
number
=
context
[
'citation_number'
]
||
1
context
[
'citation_number'
]
=
number
.
succ
number
end
def
cite
(
keys
)
items
=
keys
.
map
do
|
key
|
cited_keys
<<
key
if
bibliography
.
key?
(
key
)
entry
=
bibliography
[
key
]
entry
=
entry
.
convert
(
*
bibtex_filters
)
unless
bibtex_filters
.
empty?
...
...
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