mdast-qrcode v0.4.0
mdast-qrcode
convert a URL etc. that contained in Image / Link of mdast by using qrcode package.
Install
npm:
npm install mdast-qrcodeUsage
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\ntext1');
await toImageDataURL(tree);
console.log(toMarkdown(tree));
})();yield:
# title1

text1qrcode: 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\ntext3'
);
await toImageDataURL(tree);
console.log(toMarkdown(tree));
})();yield:
# title3

text3The 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[](url5)\ntext5'
);
await toImageDataURL(tree);
console.log(toMarkdown(tree));
})();yield:
# title5
[](url5)
text5Pass 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\n\ntext7'
);
await toImageDataURL(tree);
console.log(toMarkdown(tree));
})();yield:
# title7

text7qrcode 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, thatimage 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.mdIn 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
- fork
- edit
slides/slide-deck.md
License
MIT License
Copyright (c) 2021 hankei6km
The word "QR Code" is registered trademark of: DENSO WAVE INCORPORATED
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago