Class: AsciidoctorBibliography::Databases::BibTeX::LatexFilter
- Inherits:
-
BibTeX::Filter
- Object
- BibTeX::Filter
- AsciidoctorBibliography::Databases::BibTeX::LatexFilter
- Defined in:
- lib/asciidoctor-bibliography/databases/bibtex.rb
Overview
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`.
Instance Method Summary collapse
-
#apply(value) ⇒ Object
rubocop:disable Metrics/MethodLength; keep this a list, though!.
Instance Method Details
#apply(value) ⇒ Object
rubocop:disable Metrics/MethodLength; keep this a list, though!
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/asciidoctor-bibliography/databases/bibtex.rb', line 32 def apply(value) # rubocop:disable Metrics/MethodLength; keep this a list, though! 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) # TODO: could we be doing something smarter with some macros, e.g. \url? text.gsub!(/\\url\{(.+?)\}/, ' \\1 ') text.gsub!(/\\\w+(?=\s+\w)/, "") text.gsub!(/\\\w+(?:\[.+?\])?\s*\{(.+?)\}/, '\\1') LaTeX::Decode::Base.strip_braces(text) LaTeX.normalize_C(text) end |