Skip to content

Commit

Permalink
Merge 5fe7924 into 1a193ed
Browse files Browse the repository at this point in the history
  • Loading branch information
rseac committed Aug 29, 2019
2 parents 1a193ed + 5fe7924 commit 8212cb2
Show file tree
Hide file tree
Showing 7 changed files with 129 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
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
15 changes: 15 additions & 0 deletions lib/jekyll/scholar/plugins/lowercase.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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.
puts "value:"
puts value.to_s
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
15 changes: 15 additions & 0 deletions lib/jekyll/scholar/plugins/textregistered.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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.
puts "value:"
puts value.to_s
value.to_s.gsub(/\\textregistered/) {
"&#0174"
}
end
end
end
end

0 comments on commit 8212cb2

Please sign in to comment.