Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@benrbray/remark-cite

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@benrbray/remark-cite

A `remark` plugin for pandoc-style citations.

latest
Source
npmnpm
Version
2.0.1-alpha.4
Version published
Maintainers
1
Created
Source

remark-cite

license

Plugin for remark to support pandoc-style citations. Relies on micromark-extension-cite for tokenization and mdast-util-cite for converting markdown to/from abstract syntax trees.

Note that this extension only parses the input -- it is up to you to assign meaning to these citations by looking up each key in a .bibtex file or other tagged citation database.

Install

Install @benrbray/remark-cite on npm.

npm install @benrbray/remark-cite

Usage

const unified = require('unified')
const markdown = require('remark-parse')
const { citePlugin } = require('@benrbray/remark-cite');

let defaultOptions = {
	syntax: {
		// see micromark-extension-cite
		enableAltSyntax: false,
		enablePandocSyntax: true,
	},
	toMarkdown: {
		// see mdast-util-cite
		standardizeAltSyntax: false,
		enableAuthorSuppression: true,
		useNodeValue: false
	}
};

let processor = unified()
    .use(markdown)
    .use(citePlugin, {})

Running the processor on the following markdown:

[see @wadler1989, sec. 1.3; and -@hughes1990, pp.4]

Will produce the following cite node:

{
	"type": "cite",
	"value": "[see @wadler1989, sec. 1.3; and -@hughes1990, pp.4]",
	"data": {
		"citeItems": [
			{
				"prefix": "see ",
				"key": "wadler1989",
				"suffix": ", sec. 1.3"
			},{
				"prefix": " and ",
				"suppressAuthor": true,
				"key": "hughes1990",
				"suffix": ", pp.4"
			}
		]
	}
}

Configuration

For details about the syntax tree structure, see mdast-util-cite. For details about the configuration and supported syntax, see micromark-extension-cite.

Keywords

markdown

FAQs

Package last updated on 11 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts