How to use citeproc - 7 common examples

To help you get started, we’ve selected a few citeproc 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
_initProcessor () {
    try {
      // Load the engine with the current application language. As this citing
      // is only for preview purposes, it should follow the language like the
      // rest of the interface.
      this._engine = new citeproc.Engine(this._sys, this._mainStyle, this._lang)
      this._status = READY
      this._loadIdHint()
    } catch (e) {
      console.error(e)
      this._status = ERROR
    }
  }
github dsifford / academic-bloggers-toolkit / src / js / utils / processor.ts View on Github external
constructor(style: string) {
        const { instance } = Processor;
        if (instance) {
            if (instance.style !== style) {
                instance.style = style;
                instance.engine = new Engine(instance.sys, instance.style);
                instance.engine.opt.development_extensions.wrap_url_and_doi = true;
            }
            return instance;
        } else {
            Processor.instance = this;
            this.style = style;
            this.engine = new Engine(this.sys, this.style);
            this.engine.opt.development_extensions.wrap_url_and_doi = true;
        }
    }
    /* eslint-enable @typescript-eslint/camelcase */
github larsgw / citation.js / src / get / modules / csl / engines.js View on Github external
import CSL from 'citeproc'

import {templates} from './styles'
import {locales} from './locales'

// BEGIN add sys function
const getWrapperProxy = (original) => function (state, entry) {
  if (state.sys.wrapBibliographyEntry) {
    let [prefix, postfix] = state.sys.wrapBibliographyEntry(this.system_id)
    entry = [prefix, entry, postfix].join('')
  }
  return original(state, entry)
}

for (let format in CSL.Output.Formats) {
  let original = CSL.Output.Formats[format]['@bibliography/entry']
  CSL.Output.Formats[format]['@bibliography/entry'] = getWrapperProxy(original)
}
// END

/**
 * Object containing CSL Engines
 *
 * @access private
 * @constant
 */
const engines = {}

/**
 * Retrieve CSL parsing engine
 *
 * @access protected
github larsgw / citation.js / src / get / modules / csl / engines.js View on Github external
import CSL from 'citeproc'

import {templates} from './styles'
import {locales} from './locales'

// BEGIN add sys function
const getWrapperProxy = (original) => function (state, entry) {
  if (state.sys.wrapBibliographyEntry) {
    let [prefix, postfix] = state.sys.wrapBibliographyEntry(this.system_id)
    entry = [prefix, entry, postfix].join('')
  }
  return original(state, entry)
}

for (let format in CSL.Output.Formats) {
  let original = CSL.Output.Formats[format]['@bibliography/entry']
  CSL.Output.Formats[format]['@bibliography/entry'] = getWrapperProxy(original)
}
// END

/**
 * Object containing CSL Engines
 *
 * @access private
 * @constant
 */
const engines = {}

/**
 * Retrieve CSL parsing engine
 *
github larsgw / citation.js / src / get / modules / csl / engines.js View on Github external
const fetchEngine = function (style, lang, template, retrieveItem, retrieveLocale) {
  const engineHash = `${style}|${lang}`
  let engine

  if (engines.hasOwnProperty(engineHash)) {
    engine = engines[engineHash]
    engine.sys.retrieveItem = retrieveItem
  } else {
    engine = engines[engineHash] = new CSL.Engine({retrieveLocale, retrieveItem}, template, lang, true)
  }

  return engine
}
github larsgw / citation.js / index.js View on Github external
this.data = self.data
}

Cite.prototype = Object.create(core.Cite.prototype)

Cite.async = core.Cite.async
Cite.validateOptions = core.Cite.validateOptions
Cite.validateOutputOptions = core.Cite.validateOutputOptions

Cite.input = core.plugins.input.chain
Cite.inputAsync = core.plugins.input.chainAsync

Cite.util = Object.assign({ attr }, core.util)
Cite.version = {
  cite: core.version,
  citeproc: citeproc.PROCESSOR_VERSION
}

const CSL = core.plugins.config.get('@csl')

Cite.CSL = {
  engine: require('@citation-js/plugin-csl/lib/engines').fetchEngine,
  item (data) {
    return id => data.find(entry => entry.id === id)
  },
  locale (lang) {
    return CSL.styles.get(CSL.styles.has(lang) ? lang : 'en-US')
  },
  style (style) {
    return CSL.templates.get(CSL.templates.has(style) ? style : 'apa')
  },
  register: {
github larsgw / citation.js / lib / version.js View on Github external
get: function get() {
    return _citeproc.PROCESSOR_VERSION;
  }
});

citeproc

The citeproc-js citation formatting module, in CommonJS format. This version is based on citeproc-js 1.4.63

CPAL-1.0 OR AGPL-1.0
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis

Similar packages