Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
caesr-pub
jekyll-scholar
Commits
30bedf1e
Commit
30bedf1e
authored
Apr 06, 2013
by
Sylvester Keil
Browse files
expose index to bibliography template #19
parent
50c4ded7
Changes
3
Hide whitespace changes
Inline
Side-by-side
features/bibtex.feature
View file @
30bedf1e
...
...
@@ -93,9 +93,9 @@ Feature: BibTeX
@tags
@bibliography
@config
Scenario
:
Simple Bibliography With Custom Template
Given I have a scholar configuration with
:
|
key
|
value
|
|
source
|
./_bibliography
|
|
bibliography_template
|
<abbr>[%{key}]</abbr>%{reference}
|
|
key
|
value
|
|
source
|
./_bibliography
|
|
bibliography_template
|
<abbr>
%{index}
[%{key}]</abbr>%{reference}
|
And
I have a
"_bibliography"
directory
And I have a file "_bibliography/references.bib"
:
"""
...
...
@@ -116,7 +116,7 @@ Feature: BibTeX
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
And
I should see
"<i>The Ruby Programming Language</i>"
in
"_site/scholar.html"
And
I should see
"<abbr>\[ruby\]</abbr><span"
in
"_site/scholar.html"
And
I should see
"<abbr>
1
\[ruby\]</abbr><span"
in
"_site/scholar.html"
@tags
@filter
Scenario
:
Filtered Bibliography Loaded From Default Directory
...
...
lib/jekyll/scholar/tags/bibliography.rb
View file @
30bedf1e
...
...
@@ -23,8 +23,8 @@ module Jekyll
end
end
references
.
map!
do
|
entry
|
reference
=
bibliography_tag
entry
bibliography
=
references
.
map
.
with_index
{
|
entry
,
index
|
reference
=
bibliography_tag
(
entry
,
index
+
1
)
if
generate_details?
reference
<<
link_to
(
details_link_for
(
entry
),
...
...
@@ -32,9 +32,9 @@ module Jekyll
end
content_tag
:li
,
reference
end
}.
join
(
"
\n
"
)
content_tag
:ol
,
references
.
join
(
"
\n
"
)
,
:class
=>
config
[
'bibliography_class'
]
content_tag
:ol
,
bibliography
,
:class
=>
config
[
'bibliography_class'
]
end
end
...
...
lib/jekyll/scholar/utilities.rb
View file @
30bedf1e
...
...
@@ -102,12 +102,13 @@ module Jekyll
config
[
'bibliography_template'
]
||
'%{reference}'
end
def
bibliography_tag
(
entry
)
def
bibliography_tag
(
entry
,
index
)
return
missing_reference
unless
entry
bibliography_template
%
{
:reference
=>
reference_tag
(
entry
),
:key
=>
entry
.
key
:key
=>
entry
.
key
,
:index
=>
index
}
end
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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