Skip to content

Commit 3e05727

Browse files
authored
fix: replace markdown-toc with remark-toc (#118)
`markdown-toc` appears somewhat abandoned, with a PR I raised to upgrade `remarkable` going unlooked at ~6 months. (ref: jonschlinkert/markdown-toc#199) replace it with `remark` / `remark-toc` to clear CVE warnings.
1 parent d5ef2e0 commit 3e05727

4 files changed

Lines changed: 543 additions & 408 deletions

File tree

README.md

Lines changed: 62 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,61 @@
66
Easy to use QR code generator for Angular projects.
77

88
**Features:**
9+
910
* Compatible with Angular 20, uses `standalone` components
10-
* Leverages the widely used [qrcode](https://www.npmjs.com/package/qrcode)
11+
* Leverages the widely used [qrcode](https://www.npmjs.com/package/qrcode)
1112
package to do the heavy lifting
1213
* Renders to HTML Canvas
1314

1415
**[Change Log](CHANGES.md)**
1516

1617
<!-- toc -->
1718

18-
- [Installation](#installation)
19-
- [Importing](#importing)
20-
- [Standalone Component](#standalone-component)
21-
- [NgModule](#ngmodule)
22-
- [Usage](#usage)
23-
- [Component](#component)
24-
- [value: string (required)](#value-string-required)
25-
- [size: string | number (optional)](#size-string--number-optional)
26-
- [darkColor: RGBAColor (optional)](#darkcolor-rgbacolor-optional)
27-
- [lightColor: RGBAColor (optional)](#lightcolor-rgbacolor-optional)
28-
- [style: { [klass: string]: any; } (optional)](#style--klass-string-any--optional)
29-
- [styleClass: string (optional)](#styleclass-string-optional)
30-
- [errorCorrectionLevel: string (optional)](#errorcorrectionlevel-string-optional)
31-
- [centerImageSrc: string (optional)](#centerimagesrc-string-optional)
32-
- [centerImageSize: string | number (optional)](#centerimagesize-string--number-optional)
33-
- [margin: number (optional)](#margin-number-optional)
34-
- [scale: number (optional)](#scale-number-optional)
35-
- [maskPattern: number (optional)](#maskpattern-number-optional)
36-
- [Directive](#directive)
37-
- [Demo](#demo)
38-
- [Angular compatibility matrix](#angular-compatibility-matrix)
39-
- [Known / Common Issues](#known--common-issues)
40-
- [Reference Error 'global' is not defined](#reference-error-global-is-not-defined)
41-
- [Footnote / Package History](#footnote--package-history)
19+
* [Installation](#installation)
20+
* [Importing](#importing)
21+
* [Standalone Component](#standalone-component)
22+
* [NgModule](#ngmodule)
23+
* [Usage](#usage)
24+
* [Component](#component)
25+
* [value: string (required)](#value-string-required)
26+
* [size: string | number (optional)](#size-string--number-optional)
27+
* [darkColor: RGBAColor (optional)](#darkcolor-rgbacolor-optional)
28+
* [lightColor: RGBAColor (optional)](#lightcolor-rgbacolor-optional)
29+
* [style: { \[klass: string\]: any; } (optional)](#style--klass-string-any--optional)
30+
* [styleClass: string (optional)](#styleclass-string-optional)
31+
* [errorCorrectionLevel: string (optional)](#errorcorrectionlevel-string-optional)
32+
* [centerImageSrc: string (optional)](#centerimagesrc-string-optional)
33+
* [centerImageSize: string | number (optional)](#centerimagesize-string--number-optional)
34+
* [margin: number (optional)](#margin-number-optional)
35+
* [scale: number (optional)](#scale-number-optional)
36+
* [maskPattern: number (optional)](#maskpattern-number-optional)
37+
* [Directive](#directive)
38+
* [Demo](#demo)
39+
* [Angular compatibility matrix](#angular-compatibility-matrix)
40+
* [Known / Common Issues](#known--common-issues)
41+
* [Reference Error 'global' is not defined](#reference-error-global-is-not-defined)
42+
* [Footnote / Package History](#footnote--package-history)
4243

4344
<!-- tocstop -->
4445

4546
## Installation
47+
4648
Add as a dependency to your angular application:
4749

48-
npm install ng-qrcode --save
50+
```
51+
npm install ng-qrcode --save
52+
```
4953

5054
### Importing
55+
5156
This library ships with [standalone components](https://angular.dev/reference/migrations/standalone)
5257

5358
How you consume it depends on whether you have migrated to standalone components (the default since Angular v19)
5459

5560
#### Standalone Component
5661

5762
Add the `QrCodeComponent` or `QrCodeDirective` to your `@Component` declarations `imports` array. Eg:
63+
5864
```typescript
5965
import { QrCodeComponent } from 'ng-qrcode';
6066

@@ -71,9 +77,11 @@ export class AppComponent {
7177
// ...
7278
}
7379
```
80+
7481
#### NgModule
7582

7683
If you're still using `NgModule` / non-standalone components, then you can add `QrCodeComponent` or `QrCodeDirective` to your `@NgModule` declarations `imports` array. Eg:
84+
7785
```typescript
7886
import { QrCodeComponent } from 'ng-qrcode';
7987

@@ -89,50 +97,59 @@ There is also a deprecated `QrCodeModule` that can be imported.
8997
## Usage
9098

9199
### Component
100+
92101
```angular17html
93102
<qr-code value="Hello world!"
94103
size="300"
95104
errorCorrectionLevel="M" />
96-
```
105+
```
106+
107+
#### value: string (required)
97108

98-
#### value: string (required)
99109
The value to encode in the QR code, eg: a url
100110

101111
#### size: string | number (optional)
112+
102113
An optional size in pixels to render at
103114

104115
**Default:** automatic size based on the value provided (recommended)
105116

106117
#### darkColor: RGBAColor (optional)
118+
107119
An RGBA Hex string to use as the color for the dark / filled modules.
108120
If an invalid value is passed, the default will be used.
109121

110122
**Default** black ("#000000FF")
111123

112124
#### lightColor: RGBAColor (optional)
125+
113126
An RGBA Hex string to use as the color for the empty space.
114127
If an invalid value is passed, the default will be used.
115128

116129
**Default** white ("#FFFFFFFF")
117130

118-
#### style: { [klass: string]: any; } (optional)
131+
#### style: { \[klass: string]: any; } (optional)
132+
119133
Inline style object, passed to the inner canvas element as `[ngStyle]`
120134

121135
#### styleClass: string (optional)
136+
122137
CSS Class, passed to the inner canvas element
123138

124139
#### errorCorrectionLevel: string (optional)
125-
Controls the amount of redundant information included to make the QR code
140+
141+
Controls the amount of redundant information included to make the QR code
126142
more likely to scan correctly if it is dirty / damaged
127143

128144
**Default:** "M"
129145

130-
Valid values: "L", "M", "Q", "H" - where "L" is the lowest
146+
Valid values: "L", "M", "Q", "H" - where "L" is the lowest
131147
amount of redundancy, and "H" is the highest
132148

133149
See: https://www.npmjs.com/package/qrcode#error-correction-level for further details
134150

135151
#### centerImageSrc: string (optional)
152+
136153
A URI suitable to use an a [Image](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image) src
137154
property to load and render in the center of the QR code.
138155

@@ -141,35 +158,42 @@ the side of a higher error correction level, anecdotally when the size is less t
141158
of the size of the code, with at least "M" error correction, it is generally still scannable.
142159

143160
#### centerImageSize: string | number (optional)
161+
144162
An optional size in pixels to render the center image.
145163

146164
**Default:** 60
147165

148166
#### margin: number (optional)
167+
149168
An optional amount of margin to be rendered within the canvas element. Defaults to 4,
150169
where the unit is the size of one "dot" in the QR code.
151170

152171
#### scale: number (optional)
172+
153173
Only used when size not provided. Represents the number of pixels per module/dot. Defaults to 4.
154174

155175
#### maskPattern: number (optional)
176+
156177
Mask pattern used. Defaults to selecting the best based on content.
157178

158179
### Directive
180+
159181
If the provided component is not flexible enough for you, there is also a [directive](projects/ng-qrcode/src/lib/qr-code.directive.ts)
160-
provided that is used by the [component](projects/ng-qrcode/src/lib/qr-code.component.ts) under the hood, which provides finer
182+
provided that is used by the [component](projects/ng-qrcode/src/lib/qr-code.component.ts) under the hood, which provides finer
161183
grain control.
162184

163185
# Demo
164-
**[See running demo here](https://mnahkies.github.io/ng-qrcode/)**
165186

166-
A demo app is included in the repository under `projects/ng-qrcode-demo` which can be
187+
**[See running demo here](https://mnahkies.github.io/ng-qrcode/)**
188+
189+
A demo app is included in the repository under `projects/ng-qrcode-demo` which can be
167190
run locally using `ng build && ng serve`
168191

169192
# Angular compatibility matrix
193+
170194
See table below for a history of versions and their Angular compatibility.
171195

172-
From version 16 onwards the library major version will match the Angular
196+
From version 16 onwards the library major version will match the Angular
173197
major version.
174198

175199
| Angular Version | ng-qrcode Versions |
@@ -187,10 +211,10 @@ major version.
187211
| ^7 / ^8 | ^3 |
188212
| ^7 | ^2 |
189213

190-
191214
# Known / Common Issues
192215

193216
## Reference Error 'global' is not defined
217+
194218
Essentially in some cases Angular will bundle a version of the buffer library that is not
195219
compatible with web browsers if the 'global' object is not defined.
196220

@@ -202,8 +226,8 @@ https://github.com/mnahkies/ng-qrcode/issues/2#issuecomment-563414305
202226
Pre-version 2.0.0 this package was developed by [emin93](https://github.com/emin93) and used the `qrious`
203227
npm package to generate the QR Codes.
204228

205-
The source for this was lost, and this repository is a re-write, first released
229+
The source for this was lost, and this repository is a re-write, first released
206230
as v2.0.0 that uses the `qrcode` npm package to generate QR Codes.
207231

208-
v2.0.0 should be backwards compatible, aside from a rename of the exported NgModule from
232+
v2.0.0 should be backwards compatible, aside from a rename of the exported NgModule from
209233
QRCodeModule -> QrCodeModule for consistency.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"scripts": {
1919
"postinstall": "husky",
2020
"clean": "rm -rf ./dist ./coverage",
21-
"docs:generate": "markdown-toc -i --bullets=- ./README.md",
21+
"docs:generate": "node ./scripts/generate-toc.mjs",
2222
"start": "ng serve",
2323
"build": "ng build --project ng-qrcode --configuration production",
2424
"build-for-publish": "ng build --project ng-qrcode --configuration production && cp ./README.md ./CHANGES.md ./LICENSE ./dist/ng-qrcode/",
@@ -72,8 +72,9 @@
7272
"karma-jasmine": "~5.1.0",
7373
"karma-jasmine-html-reporter": "^2.1.0",
7474
"lint-staged": "^16.2.4",
75-
"markdown-toc": "^1.2.0",
7675
"ng-packagr": "^20.3.0",
76+
"remark": "^15.0.1",
77+
"remark-toc": "^9.0.0",
7778
"typescript": "~5.9.3"
7879
},
7980
"lint-staged": {

0 commit comments

Comments
 (0)