npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@citation-js/plugin-bibtex

v0.7.11

Published

Plugin for BibTeX formats for Citation.js

Downloads

58,467

Readme

@citation-js/plugin-bibtex

Plugin for BibTeX formats for Citation.js.

NPM version NPM total downloads License Dependency status

Install

npm install @citation-js/plugin-bibtex

Usage

Register by importing the package:

require('@citation-js/plugin-bibtex')

Formats

Formats and other features added by this plugin.

BibTeX

This plugin adds input and output support for BibTeX, both in text form and as a JSON representation. Input types are called @bibtex/text and @bibtex/entry+object, output format is bibtex. The output has format dictionary support.

BibLaTeX

This plugin adds input and output support for BibLaTeX, both in text form and as a JSON representation. Input types are called @biblatex/text and @biblatex/entry+object, output format is biblatex. The output has format dictionary support.

Bib.TXT

This plugin adds input and output support for Bib.TXT, a simplified and modernised version of BibTeX. Input types are called @bibtxt/text and @biblatex/entry+object, output format is bibtxt. The output has format dictionary support.

Configuration

Configuration can be accessed like the following:

const { plugins } = require('@citation-js/core')
const config = plugins.config.get('@bibtex')

| Property | Values [default] | Description | |----------|------------------|-------------| | config.parse.strict | true, [false] | When true, entries are checked for required fields. | | config.parse.sentenceCase | 'always', 'english', ['never'] | Convert titles to sentence case when parsing. | | config.format.useIdAsLabel | true, [false] | Use the entry ID as the label instead of generating one. |

Type mappings

Entry type mappings between BibLaTeX or BibTeX and CSL-JSON are available through config.types.biblatex and config.types.bibtex. In both cases, the Bib(La)TeX mappings are in the source field and the reverse mappings in the target field.

config.types.biblatex.source.inproceedings = 'paper-conference'
config.types.biblatex.target['paper-conference'] = 'inproceedings'

Required types

The list of required fields for each type for BibLaTeX and BibTeX is available under config.required.biblatex and config.required.bibtex respectively. In both cases, the list consists of strings for required fields and arrays for sets of fields where at least one should be present (year OR date for BibLaTeX for example).

config.required.biblatex.book = [
  'title',
  ['author', 'editor'],
  'publisher',
  ['year', 'date']
]

Field types

Field types (used for both BibLaTeX and BibTeX) are available through config.constants.fieldTypes. This returns an object mapping Bib(La)TeX field names to an array containing a field type and a value type. The former is either field, list (" and "-delimited), or separated (comma-delimited). As for the latter:

| Value type | Description | |------------|-------------| | literal | Normal text or numeric content | | title | Like literal but can be affected by config.parse.sentenceCase | | name | A personal or organizational name | | date | An EDTF Level 1 date | | verbatim | Unaltered text (no expansion of commands, etc.) | | uri | Same as verbatim but if needed the URL is encoded | | other | No special behaviour, treated like literal |

// Add `daturl` for dat:// URLs
config.constants.fieldTypes.daturl = ['field', 'uri']
// Do not treat `publisher` as a list
config.constants.fieldTypes.publisher = ['field', 'literal']

Unicode

  • config.constants.diacritics maps commands (\") to diacritics
  • config.constants.commands maps commands (\textinterrobangdown) to general unicode characters ()
  • config.constants.ligatures maps non-command character sequences (---, ~, etc.) to their replacements (emdash, no-breaking space, etc.)
  • config.constants.ligaturePattern is a RegExp that recognizes the ligatures mapped above
  • config.constants.mathScripts maps superscript and subscript (in properties ^ and _ respectively)
config.constants.diacritics['"'] = '\u0308'
config.constants.commands.textinterrobangdown = '⸘'
config.constants.ligatures = {
  '---': '\u2014',
  '~': '\u00A0'
}
config.constants.ligaturePattern = /---|~/g // Don't forget the (g)lobal flag
config.constants.mathScripts = {
  '^': { '1': '¹' },
  '_': { '1': '₁' }
}

Formatting

  • config.constants.formattingEnvs maps environment commands to formatting
  • config.constants.formattingCommands maps regular commands to formatting
  • config.constants.mathScriptFormatting maps ^ and _ to resp. super- and subscript
  • config.constants.formatting maps formatting to HTML (though RTF or Markdown could be substituted)
config.constants.formattingEnvs.bf = 'bold'
config.constants.formattingCommands.textbf = 'bold'
config.constants.mathScriptFormatting['^'] = 'superscript'
config.constants.formatting = {
  bold: ['<b>', '</b>'],
  superscript: ['<sup>', '</sup>']
}

Other commands

The object config.constants.argumentCommands maps command names to functions handling them. This does not include commands used above. Braced arguments are parsed automatically based on how many arguments the function takes. It does not support optional arguments (i.e. those in square braces) yet.

config.constants.argumentCommands.href = function (url, displayText) {
  // Note: <a> tags are not supported by CSL so watch out if you use this
  return `<a href="${url}">${displayText}</a>`
}

// You can also use it to replace commands that produce text
config.constants.argumentCommands.LaTeX = () => 'LaTeX'

English languages

The array config.constants.sentenceCaseLanguages affects which languages are eligible for sentence-casing when config.parse.sentenceCase is set to 'english'. All entries should be lowercase.

config.constants.sentenceCaseLanguages = [
  'english',
  'en-us',
  'en-gb'
]

Replacement strings

The object config.constants.defaultStrings determines which strings are defined by default.

config.constants.defaultStrings.larsgw = "Willighagen, Lars G"