Class: Jekyll::Scholar::Superscript

Inherits:
BibTeX::Filter
  • Object
show all
Defined in:
lib/jekyll/scholar/plugins/superscript.rb

Instance Method Summary collapse

Instance Method Details

#apply(value) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/jekyll/scholar/plugins/superscript.rb', line 4

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(/\\textsuperscript(\{(?:[^{}]|\g<1>)*\})/) {
    "<sup>#{$1[1..-2]}</sup>"
  }
end