Class: Vendor::Serrano::CrossRefLaTeX

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/vendor/serrano.rb

Instance Method Summary collapse

Instance Method Details

#apply(value) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vendor/serrano.rb', line 15

def apply(value)
  if value.is_a? String
    value = value.gsub(/(?:\$\\less|{\\&}lt\$\\mathsemicolon)\$\/?\w+(?:\$\\greater|{\\&}gt\$\\mathsemicolon)\$/,
      '$\less$i$\greater$' => ' <i>', '$\less$/i$\greater$' => '</i> ',
      '{\&}lt$\mathsemicolon$i{\&}gt$\mathsemicolon$' => ' <i>', '{\&}lt$\mathsemicolon$/i{\&}gt$\mathsemicolon$' => '</i> ',
      # Some times <em> is used for scientific names, making sense to translate to TW-supported <i>
      '$\less$em$\greater$' => ' <i>', '$\less$/em$\greater$' => '</i> ',
      '{\&}lt$\mathsemicolon$em{\&}gt$\mathsemicolon$' => ' <i>', '{\&}lt$\mathsemicolon$/em{\&}gt$\mathsemicolon$' => '</i> ',
    ).gsub('  ', ' ').gsub('> .', '>.').gsub('> ,', '>,')
  end
  ::LaTeX.decode(value)
end