Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
caesr-pub
jekyll-scholar
Commits
0143eb4c
Commit
0143eb4c
authored
Apr 25, 2016
by
Sylvester Keil
Browse files
Support multiple locator labels
See #147
parent
a4adcb40
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
8 deletions
+48
-8
README.md
README.md
+7
-2
features/citation.feature
features/citation.feature
+34
-1
lib/jekyll/scholar/utilities.rb
lib/jekyll/scholar/utilities.rb
+7
-5
No files found.
README.md
View file @
0143eb4c
...
...
@@ -361,13 +361,18 @@ like: `...as Matz explains (2008, p. 42)`.
#### Page numbers and locators
If you would like to add page numbers to your citation,
you can use the
`-l`
or
`--locator`
option. For example,
`{% cite ruby -
l
23-5 %}`
would
If you would like to add page numbers
or similar locators
to your citation,
use the
`-l`
or
`--locator`
option. For example,
`{% cite ruby -
-locator
23-5 %}`
would
produce a citation like
`(Matsumoto, 2008, pp. 23-5)`
.
When quoting multiple items (see above) you can add multiple locators after
the list of ids. For example,
`{% cite ruby microscope -l 2 -l 24 & 32 %}`
.
Page is the default locator, however, you can indicate the type of locator
by adding a
`-L`
or
`--label`
option (one for each locator) for instance,
`{% cite ruby microscope --label chapter --locator 3 -L figure -l 24 & 32 %}`
produces something like:
`(Matsumoto, 2008, chap. 3; Shaughnessy, 2013, figs. 24 & 32)`
.
#### Displaying formatted references
If you want to display the full formatted reference entry, you can use the
...
...
features/citation.feature
View file @
0143eb4c
...
...
@@ -250,6 +250,39 @@ Feature: Citations
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 --label chapter --locator 2-3 -L figure -l 4,5 %}
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
And
I should see
"Matsumoto, 2008, chaps. 2-3; Shaughnessy, 2013, figs. 4,5"
in
"_site/scholar.html"
@tags
@cite
@locator
@label
Scenario
:
Citations with multiple locator labels
Given I have a scholar configuration with
:
|
key
|
value
|
|
source
|
./_bibliography
|
|
bibliography
|
my_references
|
And
I have a
"_bibliography"
directory
And I have a file "_bibliography/my_references.bib"
:
"""
@book{ruby,
title = {The Ruby Programming Language},
author = {Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
"""
And I have a page "scholar.html"
:
"""
...
...
@@ -260,7 +293,7 @@ Feature: Citations
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
And
I should see
"
Flanagan &
Matsumoto, 2008, chap. 3"
in
"_site/scholar.html"
And
I should see
"Matsumoto, 2008, chap. 3"
in
"_site/scholar.html"
@tags
@cite
@citation_number
Scenario
:
Multiple citations using citation numbers
...
...
lib/jekyll/scholar/utilities.rb
View file @
0143eb4c
...
...
@@ -18,9 +18,7 @@ module Jekyll
module
Utilities
attr_reader
:config
,
:site
,
:context
,
:prefix
,
:text
,
:offset
,
:max
,
:label
attr_reader
:config
,
:site
,
:context
,
:prefix
,
:text
,
:offset
,
:max
def
split_arguments
(
arguments
)
...
...
@@ -71,7 +69,7 @@ module Jekyll
end
opts
.
on
(
'-L'
,
'--label LABEL'
)
do
|
label
|
@
label
=
label
label
s
<<
label
end
opts
.
on
(
'-o'
,
'--offset OFFSET'
)
do
|
offset
|
...
...
@@ -112,6 +110,10 @@ module Jekyll
@locators
||=
[]
end
def
labels
@labels
||=
[]
end
def
bibtex_files
@bibtex_files
||=
[
config
[
'bibliography'
]]
end
...
...
@@ -568,7 +570,7 @@ module Jekyll
end
def
render_citation
(
items
)
renderer
.
render
items
.
zip
(
locators
).
map
{
|
entry
,
locator
|
renderer
.
render
items
.
zip
(
locators
.
zip
(
labels
)
).
map
{
|
entry
,
(
locator
,
label
)
|
cited_keys
<<
entry
.
key
cited_keys
.
uniq!
...
...
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