How to use astrocite-bibtex - 3 common examples

To help you get started, we’ve selected a few astrocite-bibtex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Zettlr / Zettlr / source / main / providers / citeproc-provider.js View on Github external
_parse (cslData) {
    try {
      this._cslData = JSON.parse(cslData)
    } catch (e) {
      try {
        // Didn't work, so let's try to parse it as BibTex data.
        this._cslData = BibTexParser.parse(cslData)
      } catch (e) {
        console.error(e)
        // Nopey.
        global.ipc.notify(trans('gui.citeproc.error_db'))
        this._status = ERROR
        return
      }
    }
    // First we need to reorder the read data so that it can be passed to the
    // sys object
    for (let i = 0, ilen = this._cslData.length; i < ilen; i++) {
      let item = this._cslData[i]
      // if (!item.issued) continue
      let id = item.id
      this._items[id] = item
      this._ids[id] = true // Create a fast accessible object (instead of slow array)
github dsifford / academic-bloggers-toolkit / src / js / utils / file.ts View on Github external
export async function readReferencesFile(file: File): Promise {
    const extension = file.name
        .substring(file.name.lastIndexOf('.'))
        .toLowerCase();
    const content = await readFile(file);
    switch (extension) {
        case '.ris':
            return parseRis(content);
        case '.bib':
        case '.bibtex':
            return parseBibtex(content);
        default:
            throw new Error(`Invalid file extension: ${extension}`);
    }
}
github dsifford / academic-bloggers-toolkit / src / js / _legacy / dialogs / import / index.tsx View on Github external
parseFile = (content: string, fileExtension: string): void => {
        let payload: CSL.Data[];
        try {
            switch (fileExtension) {
                case '.ris':
                    payload = parseRis(content);
                    break;
                case '.bib':
                case '.bibtex':
                    payload = parseBibtex(content);
                    break;
                default:
                    throw new Error('Invalid FileType');
            }
        } catch (e) {
            this.setErrorMessage(ImportDialog.errors.filetype_error);
            this.setFile();
            this.setPayload([]);
            return;
        }

        if (payload.length === 0) {
            this.setErrorMessage(ImportDialog.errors.filetype_error);
            this.setFile();
        }

astrocite-bibtex

Parser and AST for converting BibTeX to CSL JSON

MIT
Latest version published 4 years ago

Package Health Score

55 / 100
Full package analysis

Popular astrocite-bibtex functions