remark-mdat 3.0.3 → 3.1.1

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.
Files changed (3) hide show
  1. package/dist/index.js +6 -3
  2. package/package.json +10 -8
  3. package/readme.md +22 -13
package/dist/index.js CHANGED
@@ -30,12 +30,12 @@ function setLogger(logger) {
30
30
  }
31
31
  //#endregion
32
32
  //#region src/lib/mdat/mdat-log.ts
33
- function saveLog(file, level, source, message, lineOrNode, maybeColumn) {
33
+ function saveLog(file, level, source, message, lineOrNode, maybeColumn = 0) {
34
34
  let line;
35
35
  let column;
36
36
  if (lineOrNode === void 0 || typeof lineOrNode === "number") {
37
37
  line = lineOrNode ?? 0;
38
- column = maybeColumn ?? 0;
38
+ column = maybeColumn;
39
39
  } else {
40
40
  line = lineOrNode?.position?.start.line ?? 0;
41
41
  column = lineOrNode?.position?.start.column ?? 0;
@@ -138,9 +138,11 @@ function parseCommentNode(node, parent) {
138
138
  const HTML_COMMENT_OPEN_REGEX = /^\s*<!-{2,}\s*/v;
139
139
  const HTML_COMMENT_CLOSE_REGEX = /\s*-{2,}>\s*$/v;
140
140
  const WHITESPACE_REGEX = /\s/v;
141
+ const KEYWORD_REGEX = /^[\p{L}\p{N}_$][\p{L}\p{N}_$.\-]*$/v;
141
142
  /**
142
143
  * Parse any comment string into structured data. Comments using code-style
143
- * notation (`//`, `#`, `/*`) are ignored and return `undefined`.
144
+ * notation (`//`, `#`, `/*`) and comments whose first word is not a valid
145
+ * keyword (e.g. commented-out Markdown) are ignored and return `undefined`.
144
146
  *
145
147
  * @returns A CommentMarker or undefined if the node is not a recognized
146
148
  * comment.
@@ -155,6 +157,7 @@ function parseComment(text) {
155
157
  const type = rawKeyword.startsWith("/") ? "close" : "open";
156
158
  let keyword = rawKeyword;
157
159
  if (type === "close") keyword = keyword.slice(1);
160
+ if (!KEYWORD_REGEX.test(keyword)) return;
158
161
  let options = {};
159
162
  if (parenIndex !== -1) {
160
163
  const lastParen = commentBody.lastIndexOf(")");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "remark-mdat",
3
- "version": "3.0.3",
4
- "description": "A remark plugin implementing the Markdown Autophagic Template (MDAT) system.",
3
+ "version": "3.1.1",
4
+ "description": "Remark plugin implementing the Markdown Autophagic Template (MDAT) system.",
5
5
  "keywords": [
6
6
  "mdat",
7
7
  "markdown",
@@ -12,7 +12,8 @@
12
12
  "mdast-util",
13
13
  "syntax-tree",
14
14
  "remark",
15
- "remark-plugin"
15
+ "remark-plugin",
16
+ "npm-package"
16
17
  ],
17
18
  "homepage": "https://github.com/kitschpatrol/remark-mdat",
18
19
  "bugs": "https://github.com/kitschpatrol/remark-mdat/issues",
@@ -59,18 +60,19 @@
59
60
  },
60
61
  "devDependencies": {
61
62
  "@arethetypeswrong/core": "^0.18.5",
62
- "@kitschpatrol/shared-config": "^8.10.0",
63
+ "@kitschpatrol/shared-config": "^8.12.1",
63
64
  "@types/node": "~24.13.4",
64
- "@vitest/coverage-v8": "^5.0.1",
65
+ "@vitest/coverage-v8": "^5.0.3",
65
66
  "bumpp": "^12.3.0",
66
- "publint": "^0.3.24",
67
+ "publint": "^0.3.25",
67
68
  "shx": "^0.4.0",
69
+ "skills": "^1.7.0",
68
70
  "tsdown": "^0.23.0",
69
71
  "typescript": "~6.0.3",
70
- "vitest": "^5.0.1"
72
+ "vitest": "^5.0.3"
71
73
  },
72
74
  "engines": {
73
- "node": ">=24.16.0"
75
+ "node": "^24.16.0 || >=26.3.0"
74
76
  },
75
77
  "scripts": {
76
78
  "bench": "vitest bench --run",
package/readme.md CHANGED
@@ -4,25 +4,18 @@
4
4
 
5
5
  <!-- /title -->
6
6
 
7
- <!-- badges({
8
- custom: {
9
- "Bundle Size": {
10
- image: "https://img.shields.io/bundlephobia/minzip/remark-mdat?label=Size",
11
- link: "https://bundlephobia.com/package/remark-mdat",
12
- },
13
- }
14
- }) -->
7
+ <!-- badges({ bundleSize: true }) -->
15
8
 
16
9
  [![NPM Package remark-mdat](https://img.shields.io/npm/v/remark-mdat.svg)](https://www.npmjs.com/package/remark-mdat)
17
10
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit)
18
11
  [![CI](https://github.com/kitschpatrol/remark-mdat/actions/workflows/ci.yml/badge.svg)](https://github.com/kitschpatrol/remark-mdat/actions/workflows/ci.yml)
19
- [![Bundle Size](https://img.shields.io/bundlephobia/minzip/remark-mdat?label=Size)](https://bundlephobia.com/package/remark-mdat)
12
+ [![Bundle Size remark-mdat](https://img.shields.io/bundlephobia/minzip/remark-mdat?label=Size)](https://bundlephobia.com/package/remark-mdat)
20
13
 
21
14
  <!-- /badges -->
22
15
 
23
16
  <!-- description -->
24
17
 
25
- **A remark plugin implementing the Markdown Autophagic Template (MDAT) system.**
18
+ **Remark plugin implementing the Markdown Autophagic Template (MDAT) system.**
26
19
 
27
20
  <!-- /description -->
28
21
 
@@ -87,16 +80,28 @@ This plugin powers the higher-level [`mdat` package](https://github.com/kitschpa
87
80
 
88
81
  ## Getting started
89
82
 
83
+ <!-- dependencies -->
84
+
90
85
  ### Dependencies
91
86
 
92
- This library is ESM only and requires Node 24.16.0+. It's designed to work with Remark 15. `remark-mdat` is implemented in TypeScript and bundles a complete set of type definitions.
87
+ - [Node.js](https://nodejs.org/) 24.16.0 or newer (specifically `^24.16.0 || >=26.3.0`)
88
+
89
+ <!-- /dependencies -->
90
+
91
+ This library is ESM only. It's designed to work with Remark 15. `remark-mdat` is implemented in TypeScript and bundles a complete set of type definitions.
92
+
93
+ <!-- install -->
93
94
 
94
95
  ### Installation
95
96
 
97
+ Add it to your project:
98
+
96
99
  ```sh
97
- pnpm add remark-mdat
100
+ npm install remark-mdat
98
101
  ```
99
102
 
103
+ <!-- /install -->
104
+
100
105
  ## Usage
101
106
 
102
107
  ### API
@@ -118,7 +123,11 @@ remark().use(remarkMdat)
118
123
 
119
124
  The plugin accepts an optional `Options` object with a `rules` field. `Rules` is a `Record<string, Rule>` where each key is a keyword matching an HTML comment in the Markdown file (e.g. `title` matches `<!-- title -->`).
120
125
 
121
- HTML comments using code-style notation (`<!-- // ... -->`, `<!-- # ... -->`, `<!-- /* ... */ -->`) are ignored and will not be treated as mdat keywords. Rule keywords cannot start with `/`, `*`, or `#`.
126
+ HTML comments using code-style notation (`<!-- // ... -->`, `<!-- # ... -->`, `<!-- /* ... */ -->`) are ignored and will not be treated as mdat keywords.
127
+
128
+ Comments whose first word is not a valid mdat rule in the context of the loaded configuration are also ignored.
129
+
130
+ A keyword consists of letters, numbers, `_`, `$`, `-`, and `.`, and cannot start with `/`, `*`, `#`, `-`, or `.`.
122
131
 
123
132
  A `Rule` value can take several forms:
124
133