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
2399deac
Commit
2399deac
authored
Apr 06, 2013
by
Sylvester Keil
Browse files
make bibtex filters configurable
fixes #17 see #16
parent
0998721a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
7 deletions
+82
-7
features/details.feature
features/details.feature
+65
-0
lib/jekyll/scholar/defaults.rb
lib/jekyll/scholar/defaults.rb
+3
-0
lib/jekyll/scholar/generators/details.rb
lib/jekyll/scholar/generators/details.rb
+3
-2
lib/jekyll/scholar/utilities.rb
lib/jekyll/scholar/utilities.rb
+11
-5
No files found.
features/details.feature
View file @
2399deac
...
...
@@ -36,6 +36,71 @@ Feature: BibTeX
And
the
"_site/bibliography/ruby.html"
file should exist
And
I should see
"The Ruby Programming Language"
in
"_site/bibliography/ruby.html"
@generators
Scenario
:
LaTeX conversion is applied to everything except the bibtex field
Given I have a scholar configuration with
:
|
key
|
value
|
|
source
|
./_bibliography
|
|
details_layout
|
details.html
|
And
I have a
"_bibliography"
directory
And I have a file "_bibliography/references.bib"
:
"""
@book{ruby,
title = {An Umlaut \"a!},
}
"""
And
I have a
"_layouts"
directory
And I have a file "_layouts/details.html"
:
"""
---
---
<html>
<head></head>
<body>
Title: {{ page.entry.title }}
{{ page.entry.bibtex }}
</body>
</html>
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/bibliography/ruby.html"
file should exist
And I should see "Title
:
An
Umlaut ä!" in
"_site/bibliography/ruby.html"
And
I should see
"title = {An Umlaut \\\"
a!}" in
"_site/bibliography/ruby.html"
@generators
Scenario
:
LaTeX conversion can be turned off
Given I have a scholar configuration with
:
|
key
|
value
|
|
source
|
./_bibliography
|
|
details_layout
|
details.html
|
|
bibtex_filters
|
|
And
I have a
"_bibliography"
directory
And I have a file "_bibliography/references.bib"
:
"""
@book{ruby,
title = {An Umlaut \"a!},
}
"""
And
I have a
"_layouts"
directory
And I have a file "_layouts/details.html"
:
"""
---
---
<html>
<head></head>
<body>
Title: {{ page.entry.title }}
{{ page.entry.bibtex }}
</body>
</html>
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/bibliography/ruby.html"
file should exist
And I should see "Title
:
An
Umlaut \\\"a!" in
"_site/bibliography/ruby.html"
And
I should see
"title = {An Umlaut \\\"
a!}" in
"_site/bibliography/ruby.html"
@tags
@details
Scenario
:
Links to Detail Pages are Generated Automatically
Given I have a scholar configuration with
:
...
...
lib/jekyll/scholar/defaults.rb
View file @
2399deac
...
...
@@ -10,6 +10,9 @@ module Jekyll
'source'
=>
'./_bibliography'
,
'bibliography'
=>
'references.bib'
,
'bibtex_options'
=>
{
:strip
=>
false
},
'bibtex_filters'
=>
[
:latex
],
'details_dir'
=>
'bibliography'
,
'details_layout'
=>
'bibtex.html'
,
'details_link'
=>
'Details'
,
...
...
lib/jekyll/scholar/generators/details.rb
View file @
2399deac
...
...
@@ -28,7 +28,8 @@ module Jekyll
data
[
'entry'
][
'bibtex'
]
=
entry
.
to_s
entry
.
fields
.
each
do
|
key
,
value
|
data
[
'entry'
][
key
.
to_s
]
=
value
.
convert
(
:latex
).
to_s
value
=
value
.
convert
(
*
bibtex_filters
)
unless
bibtex_filters
.
empty?
data
[
'entry'
][
key
.
to_s
]
=
value
.
to_s
end
end
...
...
lib/jekyll/scholar/utilities.rb
View file @
2399deac
...
...
@@ -40,7 +40,11 @@ module Jekyll
end
def
bibtex_options
@bibtex_options
||=
{
:strip
=>
false
}
config
[
'bibtex_options'
]
||=
{}
end
def
bibtex_filters
config
[
'bibtex_filters'
]
||=
[]
end
def
bibtex_path
...
...
@@ -82,7 +86,7 @@ module Jekyll
def
reference_tag
(
entry
)
return
missing_reference
unless
entry
entry
=
entry
.
convert
(
:latex
)
entry
=
entry
.
convert
(
*
bibtex_filters
)
unless
bibtex_filters
.
empty?
reference
=
CiteProc
.
process
entry
.
to_citeproc
,
:style
=>
config
[
'style'
],
:locale
=>
config
[
'locale'
],
:format
=>
'html'
...
...
@@ -142,13 +146,15 @@ module Jekyll
context
[
'cited'
]
<<
key
if
bibliography
.
key?
(
key
)
entry
=
bibliography
[
key
].
convert
(
:latex
)
entry
=
bibliography
[
key
]
entry
=
entry
.
convert
(
*
bibtex_filters
)
unless
bibtex_filters
.
empty?
citation
=
CiteProc
.
process
entry
.
to_citeproc
,
:style
=>
config
[
'style'
],
:locale
=>
config
[
'locale'
],
:format
=>
'html'
,
:mode
=>
:citation
link_to
"#
#{
[
prefix
,
entry
.
key
].
compact
.
join
(
'-'
)
}
"
,
citation
.
join
else
'(
missing
reference
)'
missing
_
reference
end
rescue
"(
#{
key
}
)"
...
...
@@ -158,7 +164,7 @@ module Jekyll
if
bibliography
.
key?
(
key
)
link_to
details_link_for
(
bibliography
[
key
]),
text
||
config
[
'details_link'
]
else
'(
missing
reference
)'
missing
_
reference
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