## 2018-05-15 Playing with #Bibtex

Parsing a bibtex file into JSON data structure... 

```javascript
import Parser from 'src/external/bibtexParse.js';

// var url = "http://localhost:9005/Dropbox/Thesis/webwerkstatt/BibliographyAll.bib"
// var url  = "https://lively-kernel.org/lively4/overleaf-cop18-promises/references.bib"
var url = "https://lively-kernel.org/lively4/overleaf-cop18-promises/incoming.bib"
var json
var bibtexInput
(async () => {
  bibtexInput = await fetch(url).then(res=>res.text());
  lively.notify('loaded')
  try {
    json= Parser.toJSON(bibtexInput);
  } catch(e) {
    lively.error(e)
  }
  var table = json.filter(ea => ea.entryTags && (ea.entryTags.Author || ea.entryTags.author)).map(ea => ({
    Key: ea.citationKey,
    Type: ea.entryType,
    Author: ea.entryTags.Author || ea.entryTags.author, // #DataStructure vs #Classes #OOP #Research
    Year: ea.entryTags.Year || ea.entryTags.year,
    Title: ea.entryTags.Title || ea.entryTags.title,
  }))
  
  var ui = await lively.openComponentInWindow("lively-table")
  ui.setFromJSO(table)
  ui.style.overflow = "scroll"
})()

```

Writing the parsed library back into a file.

```javascript
import Parser from 'src/external/bibtexParse.js';
var bib = _.sortBy(json, ea => ea.citationKey)
// var url  = "https://lively-kernel.org/lively4/overleaf-cop18-promises/test.bib"
var result = undefined
try {
  result = Parser.toBibtex(bib, false)
} catch(e) {
  lively.error(e)
}
if (result) {
  fetch(url, {
    method: "PUT",
    body: result
  })
}
```

### Finally,  we can do #Latex!



```javascript {.latexExample }
import latexconv from "src/external/latex-to-unicode-converter.js"
latexconv.convertLaTeXToUnicode("\\frak{A} + \\alpha = 5")
```

<lively-eval-element ref=".latexExample" />







