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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mdast-qrcode

v0.4.0

Published

convert "qrcode:" to dataURL

Downloads

8

Readme

mdast-qrcode

convert a URL etc. that contained in Image / Link of mdast by using qrcode package.

Install

npm:

npm install mdast-qrcode

Usage

qrcode: in URL of Image

code:

import fromMarkdown from 'mdast-util-from-markdown';
import toMarkdown from 'mdast-util-to-markdown';
import { toImageDataURL } from './qrcode';

(async () => {
  const tree = fromMarkdown('# title1\n\n![alt1](qrcode:test1)\ntext1');
  await toImageDataURL(tree);
  console.log(toMarkdown(tree));
})();

yield:

# title1

![alt1](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHQAA ...snip ...=)
text1

qrcode: in alt with filename is mdast-qrcode.*

code:

import fromMarkdown from 'mdast-util-from-markdown';
import toMarkdown from 'mdast-util-to-markdown';
import { toImageDataURL } from './qrcode';

(async () => {
  const tree = fromMarkdown(
    '# title3\n\n![alt3:qrcode:test3](/path/to/mdast-qrcode.png)\ntext3'
  );
  await toImageDataURL(tree);
  console.log(toMarkdown(tree));
})();

yield:

# title3

![alt3](data:image/png;base64,iVBORw0KGgoAAAA ...snip ...=)
text3

The URL of link that surrounds image with filename is mdast-qrcode.*

code:

import fromMarkdown from 'mdast-util-from-markdown';
import toMarkdown from 'mdast-util-to-markdown';
import { toImageDataURL } from './qrcode';

(async () => {
  const tree = fromMarkdown(
    '# title5\n\n[![alt5](/path/to/mdast-qrcode.png)](url5)\ntext5'
  );
  await toImageDataURL(tree);
  console.log(toMarkdown(tree));
})();

yield:

# title5

[![alt5](data:image/png;base64,iVBORw0KGgoAAAAN ...snip ...=)](url5)
text5

Pass options from file name / alt

code:

import fromMarkdown from 'mdast-util-from-markdown';
import toMarkdown from 'mdast-util-to-markdown';
import { toImageDataURL } from './qrcode';

(async () => {
  const tree = fromMarkdown(
    '# title7\n\n![alt7:qrcode:test7](/path/to/mdast-qrcode-width-250.png)\n\ntext7'
  );
  await toImageDataURL(tree);
  console.log(toMarkdown(tree));
})();

yield:

# title7

![alt7](data:image/png;base64,iVBORw0KGgoAAAAN ...snip ...=)
text7

qrcode options:

  • margin: -margin-<number>
  • scale: -scale-<number>
  • width: -width-<number>
  • colorr.light: -color_light-<RRGGBBAA>
  • color.dark: -color_light-<RRGGBBAA>

mdqr format options:

  • type: -format_type-<png | jpeg>
  • quality: -format_quality-<number> (unit: %)

API

toImageDataURL(tree[, options, mdqrOptions])

convert "qrcode:" to dataURL in Image URL of mdast. Images only support root / paragraph / image or root / paragraph / link / image hierarchy.

If image is exist after the QRCode, that image will be converted as logo image.

options

Options are passed to QRCode.toDataURL.

mdqrOptions

Options to mdast-qrcode.

format

Options to encode QR code to DataURL.

type

type: png | jpeg

default: png

quality

type: number

default: 0.92

returns

Promise<MdNode>

CLI

$ cat example/qrcode-deck.md  | md-qr > qrcode-embedded-deck.md

In addition to :qrcode convertion, Markdown string are also affected by toMarkdown serialized.

JSON config file

{
  "toMarkdown": { "bullet": "-", "rule": "-" }
}

toMarkdown.bullet / toMarkdown.rule field are pass to toMarkdown.

Live Demo

Live Demo

  1. fork
  2. edit slides/slide-deck.md

License

MIT License

Copyright (c) 2021 hankei6km

The word "QR Code" is registered trademark of: DENSO WAVE INCORPORATED