Closed tnhh closed 12 years ago
The braces in BibTeX entries are typically part of LaTeX directives (just as in your example). We're not processing LaTeX in bibtex-ruby by default because many users do not require it, but there's a filter you can use.
require 'bibtex'
BibTeX.parse(DATA) do |bib|
puts bib[:nasa].title
bib.convert :latex
puts bib[:nasa].title
end
__END__
@Article{nasa,
author = {Neil Armstrong},
title = {I was a {NASA} astronaut},
journal = {Journal of {CAPITALISATION}},
year = 2011
}
This should give you the following output:
I was a {NASA} astronaut
I was a NASA astronaut
As you can see, braces are automatically stripped when using the LaTeX converter. Additionally, the filter will convert many LaTeX directives to unicode. You should also be able to apply the filter when parsing by using the :filter option. For example:
BibTeX.open 'nasa.bib', :filter => :latex
Hope that helps!
Thanks for the quick reply! How curious that LaTeX output is not the default - I would have assumed that most BibTeX users would also want their LaTeX directives processed. I now have some HTML output issues but I think that those are citeproc-ruby issues, not bibtex-ruby.
Since we moved the latex filter to a separate gem, the rationale was to not make it the default, in order to not force the additional dependency. Other than that, you're right, of course, it would make a sensible default option.
citeproc-ruby probably produces HTML output, but you can turn that off and use plain text instead (you will not have italics and similar style features in that case though).
I have only just come across this project so excuse me if I have missed something obvious. How do I remove braces from BibTeX entries? e.g., given a file nasa.bib containing
the code
gives
whereas I would have expected to see
which is what BibTeX gives me. I am not familiar with citeproc so I don't know if the problem is in bibtex-ruby or citeproc-ruby. Any help would be appreciated.