remark-mdat 3.0.2 → 3.1.0
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/dist/index.js +5 -2
- package/package.json +4 -4
- package/readme.md +5 -1
package/dist/index.js
CHANGED
|
@@ -54,7 +54,7 @@ function saveLog(file, level, source, message, lineOrNode, maybeColumn) {
|
|
|
54
54
|
source
|
|
55
55
|
};
|
|
56
56
|
const vFileMessage = file.message(message, options);
|
|
57
|
-
vFileMessage.fatal = level === "
|
|
57
|
+
vFileMessage.fatal = level === "info" ? void 0 : level === "error";
|
|
58
58
|
}
|
|
59
59
|
function vFileMessageToMdatMessage(vFileMessage) {
|
|
60
60
|
return {
|
|
@@ -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 (`//`, `#`, `/*`)
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remark-mdat",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "A remark plugin implementing the Markdown Autophagic Template (MDAT) system.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mdat",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"gray-matter-es": "^0.2.1",
|
|
47
47
|
"hast-util-from-html": "^2.0.3",
|
|
48
48
|
"json5": "^2.2.3",
|
|
49
|
-
"lognow": "^0.8.
|
|
49
|
+
"lognow": "^0.8.4",
|
|
50
50
|
"picocolors": "^1.1.1",
|
|
51
51
|
"remark": "^15.0.1",
|
|
52
52
|
"remark-gfm": "^4.0.1",
|
|
53
|
-
"type-fest": "^5.
|
|
53
|
+
"type-fest": "^5.10.0",
|
|
54
54
|
"unified": "^11.0.5",
|
|
55
55
|
"unist-util-visit": "^5.1.0",
|
|
56
56
|
"vfile": "^6.0.3",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@arethetypeswrong/core": "^0.18.5",
|
|
62
|
-
"@kitschpatrol/shared-config": "^8.
|
|
62
|
+
"@kitschpatrol/shared-config": "^8.10.0",
|
|
63
63
|
"@types/node": "~24.13.4",
|
|
64
64
|
"@vitest/coverage-v8": "^5.0.1",
|
|
65
65
|
"bumpp": "^12.3.0",
|
package/readme.md
CHANGED
|
@@ -118,7 +118,11 @@ remark().use(remarkMdat)
|
|
|
118
118
|
|
|
119
119
|
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
120
|
|
|
121
|
-
HTML comments using code-style notation (`<!-- // ... -->`, `<!-- # ... -->`, `<!-- /* ... */ -->`) are ignored and will not be treated as mdat keywords.
|
|
121
|
+
HTML comments using code-style notation (`<!-- // ... -->`, `<!-- # ... -->`, `<!-- /* ... */ -->`) are ignored and will not be treated as mdat keywords.
|
|
122
|
+
|
|
123
|
+
Comments whose first word is not a valid mdat rule in the context of the loaded configuration are also ignored.
|
|
124
|
+
|
|
125
|
+
A keyword consists of letters, numbers, `_`, `$`, `-`, and `.`, and cannot start with `/`, `*`, `#`, `-`, or `.`.
|
|
122
126
|
|
|
123
127
|
A `Rule` value can take several forms:
|
|
124
128
|
|