Nothing Particularly Magnificent

    @benrbray/remark-cite
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.0 • Public • Published

    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.

    Install

    npm i @benrbray/remark-cite

    DownloadsWeekly Downloads

    4

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    16.9 kB

    Total Files

    14

    Last publish

    Collaborators

    • avatar