Skip to content

Commit

Permalink
Merge 80bf524 into 1a193ed
Browse files Browse the repository at this point in the history
  • Loading branch information
rseac committed Aug 29, 2019
2 parents 1a193ed + 80bf524 commit e67ea07
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 4 deletions.
9 changes: 6 additions & 3 deletions features/186.feature
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,22 @@ Feature: BibTeX
title = {Smalltalk Best Practice Patterns},
author = {Kent Beck},
year = {1996},
publisher = {Prentice Hall}
publisher = {Prentice Hall},
public = {yes}
}
@book{ruby,
title = {The Ruby Programming Language v1},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {1998},
publisher = {O'Reilly Media}
publisher = {O'Reilly Media},
public = {yes}
}
@book{ruby2,
title = {The Ruby Programming Language v2},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
publisher = {O'Reilly Media},
public = {no}
}
"""
And I have a page "scholar.html":
Expand Down
43 changes: 43 additions & 0 deletions features/bibtex.feature
Original file line number Diff line number Diff line change
Expand Up @@ -557,3 +557,46 @@ Feature: BibTeX
And the "_site/scholar.html" file should exist
And I should see "Estudios de Asia y Africa</i>, n.º 22" in "_site/scholar.html"
And I should see "Estudios De Asia y Africa</i>, no. 22" in "_site/scholar.html"


@tags @bibliography @duplicates
Scenario: Non-english reference
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
| bibliography | my_references |
| allow_locale_overrides | true |
| style | chicago-fullnote-bibliography |
And I have a "_bibliography" directory
And I have a file "_bibliography/my_references.bib":
"""
@article{one,
title = {Ideología y narrativa en el Ramayana de Valmiki},
number = {22},
language = {es},
journal = {Estudios de Asia y Africa},
author = {Pollock, Sheldon I.},
year = {1987},
pages = {336--54}
}
@article{one,
title = {{Ideología y narrativa en el Ramayana de Valmiki}},
number = {22},
journal = {Estudios de Asia y Africa},
author = {Pollock, Sheldon I.},
year = {1987},
pages = {336--54}
}
"""
And I have a page "scholar.html":
"""
---
---
{% bibliography %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/scholar.html" file should exist
And I should see "Estudios de Asia y Africa</i>, n.º 22" in "_site/scholar.html"
And I should see "Estudios De Asia y Africa</i>, no. 22" in "_site/scholar.html"

76 changes: 76 additions & 0 deletions features/filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,79 @@ Feature: BibTeX
And the "_site/scholar.html" file should exist
And I should see "This is <i>italics</i>." in "_site/scholar.html"


@tags @italics @textit
Scenario: LaTeX textit as HTML italics
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
And I have the following BibTeX filters:
| textit |
And I have a "_bibliography" directory
And I have a file "_bibliography/references.bib":
"""
@misc{pickaxe,
title = {This is \textit{italics}.}
}
"""
And I have a page "scholar.html":
"""
---
---
{% bibliography %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/scholar.html" file should exist
And I should see "This is <i>italics</i>." in "_site/scholar.html"

@tags @lowercase
Scenario: LaTeX lowercase as lowercase
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
And I have the following BibTeX filters:
| lowercase |
And I have a "_bibliography" directory
And I have a file "_bibliography/references.bib":
"""
@misc{pickaxe,
title = {This is \lowercase{LOWERTHIS}.}
}
"""
And I have a page "scholar.html":
"""
---
---
{% bibliography %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/scholar.html" file should exist
And I should see "This is lowerthis." in "_site/scholar.html"

@tags @textregistered
Scenario: LaTeX textregistered as HTML registered symbol
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
And I have the following BibTeX filters:
| textregistered |
And I have a "_bibliography" directory
And I have a file "_bibliography/references.bib":
"""
@misc{pickaxe,
title = {This is \textregistered to me.}
}
"""
And I have a page "scholar.html":
"""
---
---
{% bibliography %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/scholar.html" file should exist
And I should see "This is &#0174 to me." in "_site/scholar.html"

3 changes: 3 additions & 0 deletions lib/jekyll/scholar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@
require 'jekyll/scholar/plugins/superscript'
require 'jekyll/scholar/plugins/smallcaps'
require 'jekyll/scholar/plugins/italics'
require 'jekyll/scholar/plugins/textit'
require 'jekyll/scholar/plugins/lowercase'
require 'jekyll/scholar/plugins/textregistered'
2 changes: 1 addition & 1 deletion lib/jekyll/scholar/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Scholar
'repository_file_delimiter' => '.',

'bibtex_options' => { :strip => false, :parse_months => true },
'bibtex_filters' => [ :smallcaps, :superscript, :italics, :latex ],
'bibtex_filters' => [ :smallcaps, :superscript, :italics, :textit, :lowercase, :textregistered, :latex ],
'bibtex_skip_fields' => [ :abstract, :month_numeric ],
'bibtex_quotes' => ['{', '}'],

Expand Down
13 changes: 13 additions & 0 deletions lib/jekyll/scholar/plugins/lowercase.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Jekyll
class Scholar
class Lowercase < BibTeX::Filter
def apply(value)
# Use of \g<1> pattern back-reference to allow for capturing nested {} groups.
# The first (outermost) capture of $1 is used.
value.to_s.gsub(/\\lowercase(\{(?:[^{}]|\g<1>)*\})/) {
"#{$1[1..-2].downcase}"
}
end
end
end
end
13 changes: 13 additions & 0 deletions lib/jekyll/scholar/plugins/textit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Jekyll
class Scholar
class Textit < BibTeX::Filter
def apply(value)
# Use of \g<1> pattern back-reference to allow for capturing nested {} groups.
# The first (outermost) capture of $1 is used.
value.to_s.gsub(/\\textit(\{(?:[^{}]|\g<1>)*\})/) {
"<i>#{$1[1..-2]}</i>"
}
end
end
end
end
13 changes: 13 additions & 0 deletions lib/jekyll/scholar/plugins/textregistered.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Jekyll
class Scholar
class Textregistered < BibTeX::Filter
def apply(value)
# Use of \g<1> pattern back-reference to allow for capturing nested {} groups.
# The first (outermost) capture of $1 is used.
value.to_s.gsub(/\\textregistered/) {
"&#0174"
}
end
end
end
end
6 changes: 6 additions & 0 deletions lib/jekyll/scholar/utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ def bibtex_path
bibtex_paths[0]
end

def remove_duplicates(bib)

end

def bibliography
unless @bibliography
@bibliography = BibTeX::Bibliography.parse(
Expand All @@ -173,6 +177,8 @@ def bibliography
@bibliography.join if join_strings? && replace_strings?
end

#remove_duplicates(@bibliography)

@bibliography
end

Expand Down

0 comments on commit e67ea07

Please sign in to comment.