Skip to content

Commit

Permalink
Add a tiny filter. (#277)
Browse files Browse the repository at this point in the history
* Add a tiny filter.

* As suggested by @inukshuk, use span with tiny CSS.

* Add quotation marks.
  • Loading branch information
rseac authored and inukshuk committed Sep 9, 2019
1 parent 5af787d commit d453e7b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
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

0 comments on commit d453e7b

Please sign in to comment.