@creator-notes/cnotes 0.133.2 → 0.133.3

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "creator-notes-cli",
3
- "version": "0.133.2",
3
+ "version": "0.133.3",
4
4
  "description": "CreatorNotes CLI: create notes, build canvases, search knowledge from the terminal",
5
5
  "author": {
6
6
  "name": "CreatorNotes",
@@ -28,8 +28,22 @@ import { DISPLAY_ID_CORE } from "./display-id.js";
28
28
  const DISPLAY_ID_RE = new RegExp(String.raw `^${DISPLAY_ID_CORE}(@v\d+)?$`);
29
29
  /** An `@key` batch placeholder (only valid inside `notes create`). */
30
30
  const AT_KEY_RE = /^@[A-Za-z][\w-]*$/;
31
- /** Every inline relationship mention, well-formed or not. */
32
- const MENTION_RE = /\[([^\]]*)\]\(relationship:([^)]*)\)/g;
31
+ /**
32
+ * Every inline relationship mention, well-formed or not. The link text holds
33
+ * no "[": a stray bracket earlier in the prose would otherwise become the
34
+ * start of the link text and swallow the sentence up to a valid mention.
35
+ */
36
+ const MENTION_RE = /\[([^[\]]*)\]\(relationship:([^)]*)\)/g;
37
+ /**
38
+ * The markdown with code blocks and inline code blanked out. The parser
39
+ * reads a mention inside code as code, so a note that documents the syntax
40
+ * (`[Title](relationship:slug)`) holds no link to lint.
41
+ */
42
+ function withoutCode(markdown) {
43
+ return markdown
44
+ .replace(/^(`{3,}|~{3,})[^\n]*\n[\s\S]*?^\1[ \t]*$/gm, " ")
45
+ .replace(/(`+)[\s\S]*?\1/g, " ");
46
+ }
33
47
  /** Extract the target token from link text: the part before an optional `: Title` or `|alias`. */
34
48
  function targetOf(linkText) {
35
49
  const cut = linkText.search(/[:|]/);
@@ -51,7 +65,7 @@ function isValidTarget(target, allowAtKey) {
51
65
  */
52
66
  export function lintMentionMarkdown(markdown, allowAtKey) {
53
67
  const issues = [];
54
- for (const m of markdown.matchAll(MENTION_RE)) {
68
+ for (const m of withoutCode(markdown).matchAll(MENTION_RE)) {
55
69
  const raw = m[0];
56
70
  const linkText = m[1];
57
71
  const type = m[2].trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.133.2",
3
+ "version": "0.133.3",
4
4
  "description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
5
5
  "type": "module",
6
6
  "bin": {