inukshuk / citeproc-ruby

A Citation Style Language (CSL) Cite Processor
103 stars 23 forks source link

latex code in author names #14

Closed ghost closed 11 years ago

ghost commented 11 years ago

When Latex code for accents is given in author names, citeproc does not include the comma, space at the end of the name. The code below generates the following output:

Brown, J., & L\'{e}ssS. (2013). A book. Lawrence Erlbaum.
Brown, J., & Less, S. (2013). A book. Lawrence Erlbaum.

The first line should be:

Brown, J., & L\'{e}ss, S. (2013). A book. Lawrence Erlbaum.

Code example:

require 'bibtex'
require 'citeproc'

biblio = BibTeX.parse <<-END
@book{sample1,
  author = {J. Brown and S. L\\'{e}ss},
  title = {A book},
  publisher = {Lawrence Erlbaum},
  year = {2013}
}
@book{sample2,
  author = {J. Brown and S. Less},
  title = {A book},
  publisher = {Lawrence Erlbaum},
  year = {2013}
}
END

item = biblio['sample1']
puts CiteProc.process item.to_citeproc
item = biblio['sample2']
puts CiteProc.process item.to_citeproc
inukshuk commented 11 years ago

There seems to be a problem with the name normalization going on. The citeproc-ruby rewrite is pretty far advanced so this is something that should be fixed in the upcoming release.

However, could you work with unicode, too? BibTeX-Ruby has a converter built-in so you could do this:

b = BibTeX.parse <<-END
  @book{sample1,
    author = {J. Brown and S. L\\'{e}ss},
    title = {A book},
    publisher = {Lawrence Erlbaum},
    year = {2013}
  }
END

b['sample1'].convert_latex
b['sample1'].author.to_s
#-> "Brown, J. and Léss, S."

CiteProc.process b['sample1'].to_citeproc
=> "Brown, J., & Léss, S. (2013). A book. Lawrence Erlbaum."

You can also apply the LaTeX filter right when parsing. See the BibTeX-Ruby Readme for more details.

If you unicode does not work in your case let me know and I'll take another look – otherwise I this is something that will be much easier to debug and customize with the new release.

ghost commented 11 years ago

convert_latex is working, thanks.