inukshuk / bibtex-ruby

A BibTeX library, parser, and converter for Ruby.
http://inukshuk.github.com/bibtex-ruby
GNU General Public License v3.0
155 stars 35 forks source link

Latex filter in BibTeX.open prevents string replacement #122

Closed hermanndetz closed 7 years ago

hermanndetz commented 7 years ago

Take the following bib example:

@string {somejournal = "Some Intl. Journal" } @article{art1, title = {Title including chemical elements {CuAu} or names like {Einstein}}, author = {{J. Doe} and {T. Joad}}, journal = somejournal, volume = 1, year = 1984, pages = {1--3}}

The title string needs the braces around chemical elements and names to preserve capitalization. I have the following observation:

If I open this file with BibTex.open('path_to_file.bib'), I do get the string replacement for the journal field, but the braces of the chemical alloys and names in the title remain in the string then.

If I on the other hand open the file with BibTex.open('path_to_file.bib', :filter => 'latex'), the braces are removed, therefore the title appears correctly in the resulting structure, but the journal name is not replaced anymore.

Is this intended behavior? Is there a way to open such a file, first replace all bibtex strings and then process these as latex strings?

inukshuk commented 7 years ago

Yes, just open or parse the file without any filters or string replacements. Then call bib.replace for string replacement (bib.join if you need to combine strings) and then bib.convert(:latex) to apply the latex filter.

hermanndetz commented 7 years ago

Thank you for your fast response!