Hi all,
It seems the "Citation based on current selection" (Esc or Alt+Esc) command doesn't show the entries of a .bib file that contain commas in any field.
Example. LaTeX file with
\bibliographystyle{plain} \bibliography{sample} % to get sample.bib
The entry (in sample.bib):
@book{knuth79, author = "Donald E. Knuth", title = "Tex and Metafont, New Directions in Typesetting", year = "1979", publisher = "American Mathematical Society and Digital Press", address = "Stanford" }
doesn't show up unless the comma in "title" is removed or replace by another symbol such as _ (underscore).
TextMate 1.5.7 (1436) Mac OS X 10.4.11 (PPC G4)
Cheers,
AgusN
On Mar 24, 2008, at 8:27 PM, Agus N wrote:
Hi all,
It seems the "Citation based on current selection" (Esc or Alt+Esc) command doesn't show the entries of a .bib file that contain commas in any field.
Example. LaTeX file with
\bibliographystyle{plain} \bibliography{sample} % to get sample.bib
The entry (in sample.bib):
@book{knuth79, author = "Donald E. Knuth", title = "Tex and Metafont, New Directions in Typesetting", year = "1979", publisher = "American Mathematical Society and Digital Press", address = "Stanford" }
doesn't show up unless the comma in "title" is removed or replace by another symbol such as _ (underscore).
TextMate 1.5.7 (1436) Mac OS X 10.4.11 (PPC G4)
The parser we use, for good or for bad, expects the files to be in the format output by BibDesk, so if you open the bib file in BibDesk and save it, it should work. The above entry in that case would look as follows:
@book{knuth79, Address = {Stanford}, Author = {Donald E. Knuth}, Publisher = {American Mathematical Society and Digital Press}, Title = {Tex and Metafont, New Directions in Typesetting}, Year = {1979}}
I would not expect the parser to work in general in other cases.
Cheers,
AgusN
Haris Skiadas Department of Mathematics and Computer Science Hanover College
On 25/03/2008, Charilaos Skiadas cskiadas@gmail.com wrote:
The parser we use, for good or for bad, expects the files to be in the format output by BibDesk,
Is there any reason not to replace it with a proper parser? If not, I'll have a go at doing it. This problem seems to come up so often!
Robin
On Mar 25, 2008, at 6:56 AM, Robin Houston wrote:
On 25/03/2008, Charilaos Skiadas cskiadas@gmail.com wrote:
The parser we use, for good or for bad, expects the files to be in the format output by BibDesk,
Is there any reason not to replace it with a proper parser? If not, I'll have a go at doing it. This problem seems to come up so often!
You are welcome to try and write such a parser, I would be quite happy to apply it. It is not something that I find worth the effort, especially compared to all the other changes I'd like to do to the LaTeX bundle and my very limited time resources. I don't think it is an easy task at all actually. I could not find a specification for the BibTeX syntax when I was looking into it. There were way too many edge cases, so I decided to rely on the more consistent output of BibDesk.
Actually the problem that shows up usually is not this one, since most MacOSX users, I believe, use BIbDesk for bib files. The problem that often occurs is that "at signs" are not allowed by the parser anywhere but at the beginning of new entries, so things like email addresses make the parser choke. That is indeed a big annoyance, and something I'd much like to see fixed. A full-blown BibTeX parser would be wonderful as well.
BibDesk has of course such a parser, perhaps you can convince them to share the details with you.
Robin
Haris Skiadas Department of Mathematics and Computer Science Hanover College
On 25/03/2008, Charilaos Skiadas cskiadas@gmail.com wrote:
You are welcome to try and write such a parser, I would be quite happy to apply it.
Cool, thanks.
I don't think it is an easy task at all actually. I could not find a specification for the BibTeX syntax when I was looking into it.
That's okay. I prefer difficult tasks to easy ones. :-)
Lack of a formal spec is no problem. The bibtex source code is very clear, and as long as we use the same parsing logic as bibtex itself, the parser is guaranteed to be 100% compatible.
Robin
On Mar 25, 2008, at 7:44 AM, Robin Houston wrote:
I don't think it is an easy task at all actually. I could not find a specification for the BibTeX syntax when I was looking into it.
That's okay. I prefer difficult tasks to easy ones. :-)
Lack of a formal spec is no problem. The bibtex source code is very clear, and as long as we use the same parsing logic as bibtex itself, the parser is guaranteed to be 100% compatible.
I like the way you think ;)
Just to warn you, if you accomplish this, then we'll have you write a full parser for tex log files. And that's even more of a challenge, each package can pretty much write whatever it wants on them ;).
Robin
Haris Skiadas Department of Mathematics and Computer Science Hanover College
On Tuesday, March 25, 2008, at 04:45AM, "Robin Houston" robin.houston@gmail.com wrote:
On 25/03/2008, Charilaos Skiadas cskiadas@gmail.com wrote:
I don't think it is an easy task at all actually. I could not find a specification for the BibTeX syntax when I was looking into it.
That's okay. I prefer difficult tasks to easy ones. :-)
Lack of a formal spec is no problem. The bibtex source code is very clear, and as long as we use the same parsing logic as bibtex itself, the parser is guaranteed to be 100% compatible.
Right, the formal specification is in the WEB source for BibTeX itself. There are some subtleties in the grammar that I'm sure you'll have fun with.
Haris made a comment about convincing the BibDesk guys to share their parser: I believe I've mentioned before on this list that BibDesk uses Greg Ward's libbtparse; its documentation and grammar are worth investigating if you really want to write your own. Nelson Beebe's TUGBoat article on bibclean is also quite helpful, since he documents various problems that he discovered while writing bibclean. An alternative, of course, is just to use BibDesk's DO connection after it's handled the full parse and cached all the results...but I find that reinventing the wheel is most of the fun of software development :).
On 25/03/2008, Adam R. Maxwell amaxwell@mac.com wrote:
[...] BibDesk uses Greg Ward's libbtparse [...] Nelson Beebe's TUGBoat article on bibclean is also quite helpful,
That's amazingly useful information. Thanks!
I'll look into both of these. Perhaps it will turn out that the best solution is to write a Ruby binding for btparse.
Robin
On Mar 25, 2008, at 7:42 AM, Robin Houston wrote:
On 25/03/2008, Adam R. Maxwell amaxwell@mac.com wrote:
[...] BibDesk uses Greg Ward's libbtparse [...] Nelson Beebe's TUGBoat article on bibclean is also quite helpful,
That's amazingly useful information. Thanks!
I'll look into both of these. Perhaps it will turn out that the best solution is to write a Ruby binding for btparse.
I'd definitely recommend that route if you can; it's a pretty good parser. Beware that >8 bit encodings aren't supported, though (and I think there's a Japanese encoding that fails as well). We work around that by converting problematic data to UTF-8 internally.