Calibre does not create a valid .bib file

Bug #1228905 reported by Xwang on 2013-09-22
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
calibre
Undecided
sengian

Bug Description

When I create a .bib catalog, it is not valid if comments are added.
I presume that the problem is given by charcters/sequences of characters in the comments that are "reserved" in bibtex format.
Maybe the comment data should be cleaned/trasformed in plain test before writing the .bib file.

Kovid Goyal (kovid) on 2013-09-23
Changed in calibre:
assignee: nobody → sengian (sengian)
status: New → Triaged
sengian (sengian) wrote :

The data of the comments is already passed through html2text.
When you say "it is not valid if comments are added.", what do you mean?
Which program do you use?
Please join a catalog and a debug report showing your problem.

Changed in calibre:
status: Triaged → Incomplete
Xwang (xwang1976) wrote :

I use jabref.
I've foud that the problem was with a comment which contained a {.
Once I've removed such a characters, the problem has disappeared.
Moreover the presence of " in the comments creates a catalogue which is not correctly understood both from jabref and kbibtex as far as the comment are concerned even if the catalogue in such a case is understood (all the books are loaded even if the comments are lost).
The " is easily found because in the bi file is stored as a {"} so I can change it via a text editor.
The other one has been more difficult to find.
I've recreated the issue with a 2 books catalogue which is not readable by jabref which reports EOF in mid string in line 52.

Alex Biddle (alexbiddle) wrote :

html2text would not help this problem as far as I know, as it does not escape curly braces and quotations, which are special marks in bibtex.

I escaped the curly braces with a backslash, but it didn't work, at least using jabref. So maybe jabref isn't escaping properly either. The answer would be to either strip the curly braces, or escape curly braces that don't match, i.e. { or } separately, but not {}. Then the escaping issue would have to be picked up by jabref.

The problem is similar to this:
https://github.com/zotero/translators/pull/504

Alex Biddle (alexbiddle) wrote :

My pull request solution strips out orphan curly braces, while leaving matching curly braces in place. Users should use \leftbrace or \rightbrace in markup instead, as per this advice: http://tex.stackexchange.com/a/109066

https://github.com/kovidgoyal/calibre/pull/125

sengian (sengian) wrote :

Thanks for the fix.
Frankly one my main problem with BibTex is that I didn't find any real complete reference/standard.

Kovid Goyal (kovid) wrote :

@sengian: If you are ok with the fix, then please send me a pull request that I can merge. Apparently Alex closed his pull request.

Fixed in branch master. The fix will be in the next release. calibre is usually released every Friday.

 status fixreleased

Changed in calibre:
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers