Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a tiny filter. #277

Merged
merged 3 commits into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions features/filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,28 @@ Feature: BibTeX
And the "_site/scholar.html" file should exist
And I should see "This is &#0174 to me." in "_site/scholar.html"

@tags @tiny
Scenario: LaTeX tiny as HTML registered symbol
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
And I have the following BibTeX filters:
| tiny |
And I have a "_bibliography" directory
And I have a file "_bibliography/references.bib":
"""
@misc{pickaxe,
title = {This is \tiny{i is tiny} 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 <span class="tiny">i is tiny</span> to me." in "_site/scholar.html"

1 change: 1 addition & 0 deletions lib/jekyll/scholar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
require 'jekyll/scholar/plugins/textit'
require 'jekyll/scholar/plugins/lowercase'
require 'jekyll/scholar/plugins/textregistered'
require 'jekyll/scholar/plugins/tiny'
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, :textit, :lowercase, :textregistered, :latex ],
'bibtex_filters' => [ :smallcaps, :superscript, :italics, :textit, :lowercase, :textregistered, :tiny, :latex ],
'bibtex_skip_fields' => [ :abstract, :month_numeric ],
'bibtex_quotes' => ['{', '}'],

Expand Down
13 changes: 13 additions & 0 deletions lib/jekyll/scholar/plugins/tiny.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Jekyll
class Scholar
class Tiny < 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(/\\tiny(\{(?:[^{}]|\g<1>)*\})/) {
"<span class="tiny">#{$1[1..-2]}</span>"
}
end
end
end
end