@riebeckite/plugin-qr-code 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -103
- package/README_ja.md +90 -90
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
# @riebeckite/plugin-qr-code
|
|
2
|
-
|
|
3
|
-
Renders ` ```qr ` fenced code blocks into inline SVG QR codes at build time.
|
|
4
|
-
|
|
5
|
-
[日本語](./README_ja.md)
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
`qrCode()` replaces each ` ```qr ` code block with a
|
|
10
|
-
`<figure class="rb-qr">` containing an inline `<svg>` QR code. Encoding happens
|
|
11
|
-
entirely at build time in Node; nothing is shipped to the browser. The plugin
|
|
12
|
-
runs with `order: -10`, before `code-enhance` and `code-tabs`.
|
|
13
|
-
|
|
14
|
-
## Usage
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
import { defineConfig } from "@riebeckite/core";
|
|
18
|
-
import { qrCode } from "@riebeckite/plugin-qr-code";
|
|
19
|
-
|
|
20
|
-
export default defineConfig({
|
|
21
|
-
// ...
|
|
22
|
-
plugins: [
|
|
23
|
-
qrCode({
|
|
24
|
-
level: "M",
|
|
25
|
-
margin: 1,
|
|
26
|
-
width: 160,
|
|
27
|
-
dark: "#000000",
|
|
28
|
-
light: "#ffffff",
|
|
29
|
-
}),
|
|
30
|
-
],
|
|
31
|
-
});
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
````md
|
|
35
|
-
```qr
|
|
36
|
-
# caption: Project page
|
|
37
|
-
https://example.com/
|
|
38
|
-
```
|
|
39
|
-
````
|
|
40
|
-
|
|
41
|
-
The fence body is the text or URL to encode (trimmed). An empty body leaves the
|
|
42
|
-
code block untouched and reports a `@riebeckite/plugin-qr-code` diagnostic.
|
|
43
|
-
|
|
44
|
-
## Behavior
|
|
45
|
-
|
|
46
|
-
Each block becomes:
|
|
47
|
-
|
|
48
|
-
```html
|
|
49
|
-
<figure class="rb-qr" data-qr="rendered" data-qr-level="M" data-qr-margin="1">
|
|
50
|
-
<figcaption class="rb-qr__caption">…</figcaption>
|
|
51
|
-
<div class="rb-qr__canvas" role="img"><svg>…</svg></div>
|
|
52
|
-
<details class="rb-qr__fallback">
|
|
53
|
-
<summary>QR source</summary>
|
|
54
|
-
<pre><code>…</code></pre>
|
|
55
|
-
</details>
|
|
56
|
-
</figure>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
- `data-qr` is `"rendered"` on success and `"error"` when the encoder is
|
|
60
|
-
unavailable or the block cannot be encoded.
|
|
61
|
-
- The raw text stays available in `details.rb-qr__fallback` (unless `fallback`
|
|
62
|
-
is `false`), so an error never loses content.
|
|
63
|
-
- Errors and empty blocks report a snippet diagnostic with
|
|
64
|
-
`source: "@riebeckite/plugin-qr-code"`.
|
|
65
|
-
|
|
66
|
-
### Encoder loading
|
|
67
|
-
|
|
68
|
-
The QR encoder (`qrcode`) is imported dynamically at build time, so bundlers
|
|
69
|
-
never pull it into the site or client bundle. When the plugin is bundled into a
|
|
70
|
-
temporary config module and the bare specifier no longer resolves, the loader
|
|
71
|
-
falls back to `node_modules` discovered from `process.cwd()` and the pnpm
|
|
72
|
-
virtual store.
|
|
73
|
-
|
|
74
|
-
## Options
|
|
75
|
-
|
|
76
|
-
| Option | Type | Default | Description |
|
|
77
|
-
| ------ | ---- | ------- | ----------- |
|
|
78
|
-
| `level` | `"L" \| "M" \| "Q" \| "H"` | `"M"` | Error-correction level |
|
|
79
|
-
| `margin` | `number` | `1` | Quiet-zone size in modules |
|
|
80
|
-
| `width` | `number` | `160` | Rendered size in pixels |
|
|
81
|
-
| `size` | `number` | — | Alias of `width` |
|
|
82
|
-
| `dark` | `string` | `"#000000"` | Dark-module colour |
|
|
83
|
-
| `light` | `string` | `"#ffffff"` | Light-module colour |
|
|
84
|
-
| `caption` | `boolean` | `true` | Show a caption from the title / `# caption:` line |
|
|
85
|
-
| `className` | `string` | `"rb-qr"` | Figure CSS class |
|
|
86
|
-
| `language` | `string` | `"qr"` | Fence language to intercept |
|
|
87
|
-
| `fallback` | `boolean` | `true` | Keep the raw text in `<details>` |
|
|
88
|
-
|
|
89
|
-
The caption comes from the code-block `title` (code meta) or a leading
|
|
90
|
-
`# caption: …` line. A leading caption line is removed from the encoded body.
|
|
91
|
-
|
|
92
|
-
## Exports
|
|
93
|
-
|
|
94
|
-
- `qrCode(options?)` — plugin factory
|
|
95
|
-
- `qrCodePlugin` — alias of `qrCode`
|
|
96
|
-
- `resolveQrCodeOptions(options?)` — normalise options
|
|
97
|
-
- `buildQrSvg(text, options)` — encode text into an SVG string
|
|
98
|
-
- Types: `QrCodeOptions`, `ResolvedQrCodeOptions`, `QrCodeLevel`,
|
|
99
|
-
`QrBuildResult`
|
|
100
|
-
|
|
101
|
-
## See also
|
|
102
|
-
|
|
103
|
-
- [Plugin guide](../../../docs/en/plugin-
|
|
1
|
+
# @riebeckite/plugin-qr-code
|
|
2
|
+
|
|
3
|
+
Renders ` ```qr ` fenced code blocks into inline SVG QR codes at build time.
|
|
4
|
+
|
|
5
|
+
[日本語](./README_ja.md)
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
`qrCode()` replaces each ` ```qr ` code block with a
|
|
10
|
+
`<figure class="rb-qr">` containing an inline `<svg>` QR code. Encoding happens
|
|
11
|
+
entirely at build time in Node; nothing is shipped to the browser. The plugin
|
|
12
|
+
runs with `order: -10`, before `code-enhance` and `code-tabs`.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { defineConfig } from "@riebeckite/core";
|
|
18
|
+
import { qrCode } from "@riebeckite/plugin-qr-code";
|
|
19
|
+
|
|
20
|
+
export default defineConfig({
|
|
21
|
+
// ...
|
|
22
|
+
plugins: [
|
|
23
|
+
qrCode({
|
|
24
|
+
level: "M",
|
|
25
|
+
margin: 1,
|
|
26
|
+
width: 160,
|
|
27
|
+
dark: "#000000",
|
|
28
|
+
light: "#ffffff",
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
````md
|
|
35
|
+
```qr
|
|
36
|
+
# caption: Project page
|
|
37
|
+
https://example.com/
|
|
38
|
+
```
|
|
39
|
+
````
|
|
40
|
+
|
|
41
|
+
The fence body is the text or URL to encode (trimmed). An empty body leaves the
|
|
42
|
+
code block untouched and reports a `@riebeckite/plugin-qr-code` diagnostic.
|
|
43
|
+
|
|
44
|
+
## Behavior
|
|
45
|
+
|
|
46
|
+
Each block becomes:
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<figure class="rb-qr" data-qr="rendered" data-qr-level="M" data-qr-margin="1">
|
|
50
|
+
<figcaption class="rb-qr__caption">…</figcaption>
|
|
51
|
+
<div class="rb-qr__canvas" role="img"><svg>…</svg></div>
|
|
52
|
+
<details class="rb-qr__fallback">
|
|
53
|
+
<summary>QR source</summary>
|
|
54
|
+
<pre><code>…</code></pre>
|
|
55
|
+
</details>
|
|
56
|
+
</figure>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- `data-qr` is `"rendered"` on success and `"error"` when the encoder is
|
|
60
|
+
unavailable or the block cannot be encoded.
|
|
61
|
+
- The raw text stays available in `details.rb-qr__fallback` (unless `fallback`
|
|
62
|
+
is `false`), so an error never loses content.
|
|
63
|
+
- Errors and empty blocks report a snippet diagnostic with
|
|
64
|
+
`source: "@riebeckite/plugin-qr-code"`.
|
|
65
|
+
|
|
66
|
+
### Encoder loading
|
|
67
|
+
|
|
68
|
+
The QR encoder (`qrcode`) is imported dynamically at build time, so bundlers
|
|
69
|
+
never pull it into the site or client bundle. When the plugin is bundled into a
|
|
70
|
+
temporary config module and the bare specifier no longer resolves, the loader
|
|
71
|
+
falls back to `node_modules` discovered from `process.cwd()` and the pnpm
|
|
72
|
+
virtual store.
|
|
73
|
+
|
|
74
|
+
## Options
|
|
75
|
+
|
|
76
|
+
| Option | Type | Default | Description |
|
|
77
|
+
| ------ | ---- | ------- | ----------- |
|
|
78
|
+
| `level` | `"L" \| "M" \| "Q" \| "H"` | `"M"` | Error-correction level |
|
|
79
|
+
| `margin` | `number` | `1` | Quiet-zone size in modules |
|
|
80
|
+
| `width` | `number` | `160` | Rendered size in pixels |
|
|
81
|
+
| `size` | `number` | — | Alias of `width` |
|
|
82
|
+
| `dark` | `string` | `"#000000"` | Dark-module colour |
|
|
83
|
+
| `light` | `string` | `"#ffffff"` | Light-module colour |
|
|
84
|
+
| `caption` | `boolean` | `true` | Show a caption from the title / `# caption:` line |
|
|
85
|
+
| `className` | `string` | `"rb-qr"` | Figure CSS class |
|
|
86
|
+
| `language` | `string` | `"qr"` | Fence language to intercept |
|
|
87
|
+
| `fallback` | `boolean` | `true` | Keep the raw text in `<details>` |
|
|
88
|
+
|
|
89
|
+
The caption comes from the code-block `title` (code meta) or a leading
|
|
90
|
+
`# caption: …` line. A leading caption line is removed from the encoded body.
|
|
91
|
+
|
|
92
|
+
## Exports
|
|
93
|
+
|
|
94
|
+
- `qrCode(options?)` — plugin factory
|
|
95
|
+
- `qrCodePlugin` — alias of `qrCode`
|
|
96
|
+
- `resolveQrCodeOptions(options?)` — normalise options
|
|
97
|
+
- `buildQrSvg(text, options)` — encode text into an SVG string
|
|
98
|
+
- Types: `QrCodeOptions`, `ResolvedQrCodeOptions`, `QrCodeLevel`,
|
|
99
|
+
`QrBuildResult`
|
|
100
|
+
|
|
101
|
+
## See also
|
|
102
|
+
|
|
103
|
+
- [Plugin guide](../../../docs/en/reference/plugin-api.md)
|
package/README_ja.md
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
# @riebeckite/plugin-qr-code
|
|
2
|
-
|
|
3
|
-
` ```qr ` コードブロックを、ビルド時にインライン SVG の QR コードへ変換するプラグインです。
|
|
4
|
-
|
|
5
|
-
[English](./README.md)
|
|
6
|
-
|
|
7
|
-
## 概要
|
|
8
|
-
|
|
9
|
-
`qrCode()` は QR コードのコードブロックを `<figure class="rb-qr">` に置き換え、インラインの `<svg>` を埋め込みます。エンコードはビルド時の Node 上で完結し、ブラウザには何も配信しません。`order: -10` で実行されるため、`code-enhance` や `code-tabs` より先に処理されます。
|
|
10
|
-
|
|
11
|
-
## 使い方
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import { defineConfig } from "@riebeckite/core";
|
|
15
|
-
import { qrCode } from "@riebeckite/plugin-qr-code";
|
|
16
|
-
|
|
17
|
-
export default defineConfig({
|
|
18
|
-
// ...
|
|
19
|
-
plugins: [
|
|
20
|
-
qrCode({
|
|
21
|
-
level: "M",
|
|
22
|
-
margin: 1,
|
|
23
|
-
width: 160,
|
|
24
|
-
dark: "#000000",
|
|
25
|
-
light: "#ffffff",
|
|
26
|
-
}),
|
|
27
|
-
],
|
|
28
|
-
});
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
````md
|
|
32
|
-
```qr
|
|
33
|
-
# caption: プロジェクトページ
|
|
34
|
-
https://example.com/
|
|
35
|
-
```
|
|
36
|
-
````
|
|
37
|
-
|
|
38
|
-
フェンス本文がエンコード対象のテキストまたは URL です(前後の空白は除去します)。本文が空の場合、コードブロックはそのまま残し、`@riebeckite/plugin-qr-code` を発行元とする診断を出します。
|
|
39
|
-
|
|
40
|
-
## 出力
|
|
41
|
-
|
|
42
|
-
各ブロックは次の形になります。
|
|
43
|
-
|
|
44
|
-
```html
|
|
45
|
-
<figure class="rb-qr" data-qr="rendered" data-qr-level="M" data-qr-margin="1">
|
|
46
|
-
<figcaption class="rb-qr__caption">…</figcaption>
|
|
47
|
-
<div class="rb-qr__canvas" role="img"><svg>…</svg></div>
|
|
48
|
-
<details class="rb-qr__fallback">
|
|
49
|
-
<summary>QR source</summary>
|
|
50
|
-
<pre><code>…</code></pre>
|
|
51
|
-
</details>
|
|
52
|
-
</figure>
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
- `data-qr` は成功時に `"rendered"`、エンコーダを読み込めない場合やエンコードに失敗した場合に `"error"` になります。
|
|
56
|
-
- 元のテキストは `details.rb-qr__fallback` に残ります(`fallback: false` の場合は除く)。エラー時も内容が失われることはありません。
|
|
57
|
-
- エラーと空ブロックは `source: "@riebeckite/plugin-qr-code"` の診断として報告されます。
|
|
58
|
-
|
|
59
|
-
### エンコーダの読み込み
|
|
60
|
-
|
|
61
|
-
QR エンコーダ(`qrcode`)はビルド時に動的インポートするため、サイト側・クライアント側のバンドルには含まれません。プラグインが一時的な設定モジュールへバンドルされ、ベア指定子が解決できなくなった場合は、`process.cwd()` と pnpm の仮想ストアから `node_modules` を探索してフォールバックします。
|
|
62
|
-
|
|
63
|
-
## オプション
|
|
64
|
-
|
|
65
|
-
| 項目 | 型 | 既定値 | 説明 |
|
|
66
|
-
| --- | --- | --- | --- |
|
|
67
|
-
| `level` | `"L" \| "M" \| "Q" \| "H"` | `"M"` | 誤り訂正レベル |
|
|
68
|
-
| `margin` | `number` | `1` | 余白(モジュール数) |
|
|
69
|
-
| `width` | `number` | `160` | 表示サイズ(px) |
|
|
70
|
-
| `size` | `number` | — | `width` の別名 |
|
|
71
|
-
| `dark` | `string` | `"#000000"` | 暗モジュールの色 |
|
|
72
|
-
| `light` | `string` | `"#ffffff"` | 明モジュールの色 |
|
|
73
|
-
| `caption` | `boolean` | `true` | タイトルまたは `# caption:` 行をキャプションとして表示する |
|
|
74
|
-
| `className` | `string` | `"rb-qr"` | figure の CSS クラス |
|
|
75
|
-
| `language` | `string` | `"qr"` | 対象とするフェンス言語 |
|
|
76
|
-
| `fallback` | `boolean` | `true` | 元のテキストを `<details>` に残す |
|
|
77
|
-
|
|
78
|
-
キャプションはコードブロックの `title`(コードメタ)または先頭の `# caption: …` 行から取得します。先頭のキャプション行はエンコード対象から取り除きます。
|
|
79
|
-
|
|
80
|
-
## 主なエクスポート
|
|
81
|
-
|
|
82
|
-
- `qrCode(options?)`: プラグインを作成する
|
|
83
|
-
- `qrCodePlugin`: `qrCode` の別名
|
|
84
|
-
- `resolveQrCodeOptions(options?)`: オプションを正規化する
|
|
85
|
-
- `buildQrSvg(text, options)`: テキストを SVG 文字列へエンコードする
|
|
86
|
-
- 型: `QrCodeOptions`、`ResolvedQrCodeOptions`、`QrCodeLevel`、`QrBuildResult`
|
|
87
|
-
|
|
88
|
-
## 関連資料
|
|
89
|
-
|
|
90
|
-
- [プラグインシステム](../../../docs/ja/plugin-
|
|
1
|
+
# @riebeckite/plugin-qr-code
|
|
2
|
+
|
|
3
|
+
` ```qr ` コードブロックを、ビルド時にインライン SVG の QR コードへ変換するプラグインです。
|
|
4
|
+
|
|
5
|
+
[English](./README.md)
|
|
6
|
+
|
|
7
|
+
## 概要
|
|
8
|
+
|
|
9
|
+
`qrCode()` は QR コードのコードブロックを `<figure class="rb-qr">` に置き換え、インラインの `<svg>` を埋め込みます。エンコードはビルド時の Node 上で完結し、ブラウザには何も配信しません。`order: -10` で実行されるため、`code-enhance` や `code-tabs` より先に処理されます。
|
|
10
|
+
|
|
11
|
+
## 使い方
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { defineConfig } from "@riebeckite/core";
|
|
15
|
+
import { qrCode } from "@riebeckite/plugin-qr-code";
|
|
16
|
+
|
|
17
|
+
export default defineConfig({
|
|
18
|
+
// ...
|
|
19
|
+
plugins: [
|
|
20
|
+
qrCode({
|
|
21
|
+
level: "M",
|
|
22
|
+
margin: 1,
|
|
23
|
+
width: 160,
|
|
24
|
+
dark: "#000000",
|
|
25
|
+
light: "#ffffff",
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
````md
|
|
32
|
+
```qr
|
|
33
|
+
# caption: プロジェクトページ
|
|
34
|
+
https://example.com/
|
|
35
|
+
```
|
|
36
|
+
````
|
|
37
|
+
|
|
38
|
+
フェンス本文がエンコード対象のテキストまたは URL です(前後の空白は除去します)。本文が空の場合、コードブロックはそのまま残し、`@riebeckite/plugin-qr-code` を発行元とする診断を出します。
|
|
39
|
+
|
|
40
|
+
## 出力
|
|
41
|
+
|
|
42
|
+
各ブロックは次の形になります。
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<figure class="rb-qr" data-qr="rendered" data-qr-level="M" data-qr-margin="1">
|
|
46
|
+
<figcaption class="rb-qr__caption">…</figcaption>
|
|
47
|
+
<div class="rb-qr__canvas" role="img"><svg>…</svg></div>
|
|
48
|
+
<details class="rb-qr__fallback">
|
|
49
|
+
<summary>QR source</summary>
|
|
50
|
+
<pre><code>…</code></pre>
|
|
51
|
+
</details>
|
|
52
|
+
</figure>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- `data-qr` は成功時に `"rendered"`、エンコーダを読み込めない場合やエンコードに失敗した場合に `"error"` になります。
|
|
56
|
+
- 元のテキストは `details.rb-qr__fallback` に残ります(`fallback: false` の場合は除く)。エラー時も内容が失われることはありません。
|
|
57
|
+
- エラーと空ブロックは `source: "@riebeckite/plugin-qr-code"` の診断として報告されます。
|
|
58
|
+
|
|
59
|
+
### エンコーダの読み込み
|
|
60
|
+
|
|
61
|
+
QR エンコーダ(`qrcode`)はビルド時に動的インポートするため、サイト側・クライアント側のバンドルには含まれません。プラグインが一時的な設定モジュールへバンドルされ、ベア指定子が解決できなくなった場合は、`process.cwd()` と pnpm の仮想ストアから `node_modules` を探索してフォールバックします。
|
|
62
|
+
|
|
63
|
+
## オプション
|
|
64
|
+
|
|
65
|
+
| 項目 | 型 | 既定値 | 説明 |
|
|
66
|
+
| --- | --- | --- | --- |
|
|
67
|
+
| `level` | `"L" \| "M" \| "Q" \| "H"` | `"M"` | 誤り訂正レベル |
|
|
68
|
+
| `margin` | `number` | `1` | 余白(モジュール数) |
|
|
69
|
+
| `width` | `number` | `160` | 表示サイズ(px) |
|
|
70
|
+
| `size` | `number` | — | `width` の別名 |
|
|
71
|
+
| `dark` | `string` | `"#000000"` | 暗モジュールの色 |
|
|
72
|
+
| `light` | `string` | `"#ffffff"` | 明モジュールの色 |
|
|
73
|
+
| `caption` | `boolean` | `true` | タイトルまたは `# caption:` 行をキャプションとして表示する |
|
|
74
|
+
| `className` | `string` | `"rb-qr"` | figure の CSS クラス |
|
|
75
|
+
| `language` | `string` | `"qr"` | 対象とするフェンス言語 |
|
|
76
|
+
| `fallback` | `boolean` | `true` | 元のテキストを `<details>` に残す |
|
|
77
|
+
|
|
78
|
+
キャプションはコードブロックの `title`(コードメタ)または先頭の `# caption: …` 行から取得します。先頭のキャプション行はエンコード対象から取り除きます。
|
|
79
|
+
|
|
80
|
+
## 主なエクスポート
|
|
81
|
+
|
|
82
|
+
- `qrCode(options?)`: プラグインを作成する
|
|
83
|
+
- `qrCodePlugin`: `qrCode` の別名
|
|
84
|
+
- `resolveQrCodeOptions(options?)`: オプションを正規化する
|
|
85
|
+
- `buildQrSvg(text, options)`: テキストを SVG 文字列へエンコードする
|
|
86
|
+
- 型: `QrCodeOptions`、`ResolvedQrCodeOptions`、`QrCodeLevel`、`QrBuildResult`
|
|
87
|
+
|
|
88
|
+
## 関連資料
|
|
89
|
+
|
|
90
|
+
- [プラグインシステム](../../../docs/ja/reference/plugin-api.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-qr-code",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"qrcode": "^1.5.4",
|
|
19
|
-
"@riebeckite/core": "0.0.
|
|
19
|
+
"@riebeckite/core": "0.0.13"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|