citation-style-language / csl-editor

cslEditorLib - A HTML 5 library for searching and editing CSL styles
http://editor.citationstyles.org
MIT License
188 stars 34 forks source link

cslExporter.csl exports malformed JSON on the author array #196

Closed mcshaz closed 7 years ago

mcshaz commented 8 years ago

when using the cslExporter.csl file from wiki/citation-style-editor/csl-editor/cslExporter.csl I get some malformed JSON in the author property:

"author": [{"family": "Moynihan", "given": "Katie"}]"}, {"family": "[{"family": "McSharry", "given": "Brent"}]"}, {"family": "[{"family": "Reed", "given": "Peter"}]"}, {"family": "[{"family": "Buckley", "given": "David"}]

it should be "author": [{"family": "Moynihan", "given": "Katie"}, {"family": "McSharry", "given": "Brent"}, {"family": "Reed", "given": "Peter"}, {"family": "Buckley", "given": "David"}]

that is each object within the collection is being serialised with: ]"}, {"family": "[ instead of just a comma

rmzelle commented 8 years ago

We might be able to fix this, but can you give the (wiki) page that links to https://raw.githubusercontent.com/wiki/citation-style-editor/csl-editor/cslExporter.csl? I've never heard of it before, and some context would be handy. What do you hope to use it for?

adam3smith commented 8 years ago

That's how you can see what Mendeley passes on to CSL. I think @cpina created it -- maybe he can fix?

mcshaz commented 8 years ago

link is from: support.mendeley.com/customer/en/portal/articles/960892-add-new-citation-example-in-the-visual-csl-editor

rmzelle commented 8 years ago

Looks like each

<group>
  <text prefix=" &quot;" value="author&quot;: " />
  <names variable="author">
    <name delimiter="&quot;}, {&quot;family&quot;: &quot;" prefix="[{&quot;family&quot;: &quot;" suffix="&quot;}]" name-as-sort-order="all" sort-separator="&quot;, &quot;given&quot;: &quot;" ></name>
  </names>
</group>

should look something like

<group>
  <text prefix=" &quot;" value="author" suffix="&quot;: " />
  <names variable="author" prefix="[" suffix="]">
    <name delimiter=", " prefix="{&quot;family&quot;: &quot;" suffix="&quot;}" name-as-sort-order="all" sort-separator="&quot;, &quot;given&quot;: &quot;"/>
  </names>
</group>

(this gives:

"author": [{"family": "Shih", "given": "T. Y."}, {"family": "Stokes", "given": "P. E."}, {"family": "Smythers", "given": "G. W."}, {"family": "Dhar", "given": "R."}, {"family": "Oroszlan", "given": "S."}]

)

cpina commented 8 years ago

I'll test and change it...

rmzelle commented 7 years ago

@mcshaz, sorry for the long wait, but I fixed up https://raw.githubusercontent.com/wiki/citation-style-editor/csl-editor/cslExporter.csl. I incorporated my suggested change above to fix the output of all CSL name variables.

If you still have any use for it, let us know if you run into any more issues.

P.S. There was also an issue with CSL number variables (such as "issue"), which were output twice (once with <text/> and once with <number/>), that I fixed, keeping only the <text/> output. I also added some style metadata so that the style properly validates, and reindented the style.