class AsciidoctorBibtex::LatexFilter
This filter extends the original latex filter in bibtex-ruby to handle unknown latex macros more gracefully. We could have used latex-decode gem together with our custom replacement rules, but latex-decode eats up all braces after it finishes all decoding. So we hack over the LaTeX.decode function and insert our rules before `strip_braces`.
Public Instance Methods
apply(value)
click to toggle source
# File lib/asciidoctor-bibtex/processor.rb, line 32 def apply(value) text = value.to_s LaTeX::Decode::Base.normalize(text) LaTeX::Decode::Maths.decode!(text) LaTeX::Decode::Accents.decode!(text) LaTeX::Decode::Diacritics.decode!(text) LaTeX::Decode::Punctuation.decode!(text) LaTeX::Decode::Symbols.decode!(text) LaTeX::Decode::Greek.decode!(text) text = text.gsub(/\\url\{(.+?)\}/, ' \\1 ').gsub(/\\\w+(?=\s+\w)/, '').gsub(/\\\w+(?:\[.+?\])?\s*\{(.+?)\}/, '\\1') LaTeX::Decode::Base.strip_braces(text) LaTeX.normalize_C(text) end