fiduswriter / biblatex-csl-converter

A set of JavaScript converters: bib(la)tex => json, json => csl, and json => biblatex
GNU Lesser General Public License v3.0
34 stars 10 forks source link

Part of title interpreted as variable? #52

Closed retorquere closed 7 years ago

retorquere commented 7 years ago

When I run this script:

var BibTeXParser, data, fs, parseReferences;

BibTeXParser = require('biblatex-csl-converter').BibLatexParser;

parseReferences = function(input) {
  var parser, references;
  parser = new BibTeXParser(input, {
    rawFields: true,
    processUnexpected: true,
    processUnknown: true
  });

  references = parser.output;

  return {
    references: references,
    groups: parser.groups,
    errors: parser.errors,
    warnings: parser.warnings
  };
};

data = `
@InProceedings{test_citation1,
  Title                    = {{T}est {T}itle {W}ith 100~$\mu\${J}, 200\,{\mbox{$\mu$}}{J} {E}nergy, and $\pm$0.1\% {A}ccuracy, 0.2\,mm$^2$ {S}ize, and $-$50\,d{B} {A}ttenuation},
}
`

console.log(JSON.stringify(parseReferences(data), null, 2));

the last part of the title comes out as

{
            "type": "variable",
            "attrs": {
              "variable": " {A}ccuracy, 0.2,mm$^2$ {S}ize, and $-$50,d{B} {A}ttenuation"
            }
          }
johanneswilm commented 7 years ago

Copying the bibtex string and pasting it here: https://fiduswriter.github.io/biblatex-csl-converter/ I cannot reproduce the issue. It seems to be processed correctly.

retorquere commented 7 years ago

tt.txt Even when I run my script with the settings in that page, I still get variable. What do you get when you run that script in node?

johanneswilm commented 7 years ago

I will try to set that up. Does it work for you if you paste it on the site though?

retorquere commented 7 years ago

(I've attached the full output I get when running the script. I'm on biblatex-csl-converter@0.21.8)

retorquere commented 7 years ago

Works for me if I paste it into the site.

retorquere commented 7 years ago

setup should be covered with going into an empty directory, running npm init (all defaults are OK), running npm install biblatex-csl-converter, and then running my script in that directory.

johanneswilm commented 7 years ago

Before I start going through setting up node, etc. -- You are aware that you are inserting the bibtex code as a template literal which probably means that the escaping backslashes are removed by JS before it is being given to the parser, right?

retorquere commented 7 years ago

That was it 😊

johanneswilm commented 7 years ago

:) Ok, so we can close this?