diff --git a/features/filter.feature b/features/filter.feature index a74991a..32c980c 100644 --- a/features/filter.feature +++ b/features/filter.feature @@ -584,3 +584,28 @@ Feature: BibTeX And the "_site/scholar.html" file should exist And I should see "This is ® 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 i is tiny to me." in "_site/scholar.html" + diff --git a/lib/jekyll/scholar.rb b/lib/jekyll/scholar.rb index 149f9bd..39076de 100644 --- a/lib/jekyll/scholar.rb +++ b/lib/jekyll/scholar.rb @@ -28,3 +28,4 @@ require 'jekyll/scholar/plugins/textit' require 'jekyll/scholar/plugins/lowercase' require 'jekyll/scholar/plugins/textregistered' +require 'jekyll/scholar/plugins/tiny' diff --git a/lib/jekyll/scholar/defaults.rb b/lib/jekyll/scholar/defaults.rb index b82c7f9..105af66 100644 --- a/lib/jekyll/scholar/defaults.rb +++ b/lib/jekyll/scholar/defaults.rb @@ -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' => ['{', '}'], diff --git a/lib/jekyll/scholar/plugins/tiny.rb b/lib/jekyll/scholar/plugins/tiny.rb new file mode 100644 index 0000000..5072544 --- /dev/null +++ b/lib/jekyll/scholar/plugins/tiny.rb @@ -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>)*\})/) { + "#{$1[1..-2]}" + } + end + end + end +end