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

@bernardjoseph/micromark-extension-citekey

v0.1.2

Published

micromark extension to support Pandoc-style citation keys

Downloads

5

Readme

micromark-extension-citekey

micromark extension to support Pandoc-style citation keys.

When to use this

If you’re using micromark or mdast-util-from-markdown, use this package. Alternatively, if you’re using remark, use remark-citekey.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install @bernardjoseph/micromark-extension-citekey

Use

Say we have the following file, example.md:

@wadler1989. @{hughes1990.}

And our script, example.js, looks as follows:

import fs from 'node:fs'
import {micromark} from 'micromark'
import {citekey, citekeyHtml} from '@bernardjoseph/micromark-extension-citekey'

const out = micromark(fs.readFileSync('example.md'), {
  extensions: [citekey()],
  htmlExtensions: [citekeyHtml]
})

console.log(out)

Now, running node example yields:

<p><span class="citekey">@<span class="citeid=">wadler1989</span></span>. <span class="citekey">@{<span class="citeid=">hughes1990.</span>}</span></p>

API

This package exports the following identifiers: citekey, citekeyHtml. There is no default export.

The export map supports the endorsed development condition. Run node --conditions development module.js to get instrumented dev code. Without this condition, production code is loaded.

citekey(options?)

Function that can be called with options to get an extension for micromark to parse Pandoc-style citation keys (can be passed in extensions).

options.strict

A boolean option to restrict citation keys to ASCII.

If set to true, citation keys end at the first non-ASCII character. For example, running the script:

import {micromark} from 'micromark'
import {citekey, citekeyHtml} from '@bernardjoseph/micromark-extension-citekey'

const out = micromark('@müller', {
  extensions: [citekey({strict: true})],
  htmlExtensions: [citekeyHtml]
})

console.log(out)

Yields:

<p><span class="citekey">@<span class="citeid=">m</span></span>üller</p>

The default value is false.

citekeyHtml

Extension for micromark to compile Pandoc-style citation keys to HTML (can be passed in htmlExtensions).

Caveats

Labeled item markers of Pandoc numbered example lists look like Pandoc-style citation keys:

(@good) This is a good example.

As (@good) illustrates, ...

Currently, there exists no micromark extension for Pandoc numbered example lists. Without such an extension, all labeled item markers are parsed as citation keys.

Syntax

The syntax of Pandoc-style citation keys is described in the Pandoc manual.

The Pandoc manual does not specify what characters are allowed to precede a citation key. This extension imitates the behavior of the Pandoc parser and allows all characters except alphanumerics and periods to precede a citation key.

Related

Contribute

See contributing.md in micromark/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Bernd Rellermeyer