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
b80839d7
Commit
b80839d7
authored
Feb 07, 2013
by
Sylvester Keil
Browse files
add filter to bibliography tag #9
parent
bc6dc0d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/jekyll/scholar/tags/bibliography.rb
View file @
b80839d7
...
...
@@ -3,12 +3,20 @@ module Jekyll
class
BibliographyTag
<
Liquid
::
Tag
include
Scholar
::
Utilities
def
initialize
(
tag_name
,
arguments
,
tokens
)
super
@config
=
Scholar
.
defaults
.
dup
@bibtex_file
=
arguments
.
strip
path_or_query
=
arguments
.
strip
case
when
path_or_query
.
start_with?
(
'@'
)
@query
=
path_or_query
when
!
path_or_query
.
empty?
@bibtex_file
=
path_or_query
end
end
def
render
(
context
)
...
...
@@ -17,23 +25,23 @@ module Jekyll
references
=
entries
.
map
do
|
entry
|
reference
=
CiteProc
.
process
entry
.
to_citeproc
,
:style
=>
config
[
'style'
],
:locale
=>
config
[
'locale'
],
:format
=>
'html'
reference
=
content_tag
:span
,
reference
,
:id
=>
entry
.
key
if
generate_details?
reference
<<
link_to
(
details_link_for
(
entry
),
config
[
'details_link'
],
:class
=>
config
[
'details_link_class'
])
end
content_tag
:li
,
reference
end
content_tag
:ol
,
references
.
join
(
"
\n
"
),
:class
=>
config
[
'bibliography_class'
]
end
end
end
private
def
citeproc
@citeproc
||=
CiteProc
::
Processor
.
new
do
|
p
|
p
.
style
=
config
[
'style'
]
...
...
lib/jekyll/scholar/utilities.rb
View file @
b80839d7
...
...
@@ -6,7 +6,7 @@ module Jekyll
# #site readers
module
Utilities
attr_reader
:bibtex_file
,
:config
,
:site
attr_reader
:bibtex_file
,
:config
,
:site
,
:query
def
bibtex_options
@bibtex_options
||=
{
:filter
=>
:latex
}
...
...
@@ -21,7 +21,7 @@ module Jekyll
end
def
entries
b
=
bibliography
[
config
[
'query'
]]
b
=
bibliography
[
query
||
config
[
'query'
]]
unless
config
[
'sort_by'
]
==
'none'
b
=
b
.
sort_by
{
|
e
|
e
[
config
[
'sort_by'
]].
to_s
}
...
...
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