Zotero encounters a bug when trying to read a CSL file.

For example, taking the American Chemical Society as an example (id: http://www.zotero.org/styles/american-chemical-society).

The content of the macro related to the author from lines 58-63 is as follows:

```
58 macro name="author"
59 names variable="author" suffix="."
60 name sort-separator=", " initialize-with=". " name-as-sort-order="all" delimiter="; " delimiter-precedes-last="always"
61 label form="short" prefix=", " text-case="capitalize-first" /label
62 /names
63 /macro
```

If I set the delimiter attribute to empty in line 60 for the name field (without changing any other attributes), like this:
```
60 name sort-separator=", " initialize-with=". " name-as-sort-order="all" delimiter=" " delimiter-precedes-last="always"
```

The following error message will be displayed:
```
There is an error generating in-text citations and/or the reference list:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
```

This problem has prevented Zotero from recognizing my self-edited CSL file, and it has been bothering me for a long time.

Eventually, I found the issue and I hope it can be fixed to prevent more people from experiencing the same problem.

If the problem description is not clear enough due to the inability to upload code and images, you can contact me by email: wangguanjienao@gmail.com.
  • Your custom style validates correctl?
    validator.citationstyles.org/
  • Of course, the customized CSL file has already been validated on this website: https://validator.citationstyles.org/.

    No errors are found on the website recommended by the official CSL validation tool (https://validator.citationstyles.org/).

    However, when adding the file to Zotero, an error prompt is displayed.
    "SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"

    As mentioned earlier, the error can be fixed by modifying the delimiter attribute in line 60.

    Therefore, I believe this is a bug in the Zotero software.

    I'm not sure how to upload the source code to the forum, so I saved the document on Google Docs. If you're interested, you can try it out yourself.

    https://docs.google.com/document/d/1Re4HjPRfhIyFIiPOI7a8xYxJomgWwAKchdSzMjanWzQ/edit?usp=sharing
  • I have no problem importing your CSL file into zotero (while it creates an error when generating an error, probably because of invalid delimiter).

    Try to import it again after you disabled all the add-ons you have installed in zotero.
  • Thanks.

    I didn't have any problems during the import CSL file either.

    If I don't want to add any symbols between two adjacent authors in bibliography, I have to set delimiter="". However, this causes an error in Zotero, which is why I raised this issue.
  • Well, you say you want delimiter=" ", but in the CSL file you have shared, it is delimiter="", which is not valid I guess. If I change for delimiter=" ", it works
Sign In or Register to comment.