This remark-plugin allows to embed a QR-code from a given value into markdown files.
npm i @hanseartic/remark-qrcode-directive
yarn add @hanseartic/remark-qrcode-directive
This plugin needs the remark-directive
plugin to generally enable directives.
Given a markdown file example.md
:
# Example with QR-Code
::qr[Hi from qr-code-directive]
QR Code says: 'Hi from qr-code-directive'.
and a processing module example.js
:
import {read} from 'to-vfile'
import {unified} from 'unified'
import remarkParse from 'remark-parse'
// necessary to enable directives in general
import remarkDirective from 'remark-directive'
// the QR-Code directive itself
import qrCodeDirective from '@hanseartic/remark-qrcode-directive'
main()
async function main() {
const file = await unified()
.use(remarkParse)
.use(remarkDirective)
.use(qrCodeDirective)
.process(await read('example.md'))
console.log(String(file))
}
Following result could be rendered by node example
:
# Example with QR-Code

QR Code says: 'Hi from qr-code-directive'.
QR Code says: 'Hi from qr-code-directive'.
The underlying qr-code package is qrcode
and all options can be passed as directive attributes.
For example to make the background transparent use the following:
::qr[your data]{color.light=#00000000}