diff --git a/plugs/core/anchor.ts b/plugs/core/anchor.ts index c60784c9..063cf46e 100644 --- a/plugs/core/anchor.ts +++ b/plugs/core/anchor.ts @@ -11,7 +11,7 @@ export async function indexAnchors({ name: pageName, tree }: IndexTreeEvent) { const anchors: { key: string; value: string }[] = []; collectNodesOfType(tree, "NamedAnchor").forEach((n) => { - const aName = n.children![0].text!; + const aName = n.children![0].text!.substring(1); anchors.push({ key: `a:${pageName}:${aName}`, value: "" + n.from, @@ -31,11 +31,13 @@ export async function anchorComplete() { if (!pageRef) { pageRef = await editor.getCurrentPage(); } - const allAnchors = await index.queryPrefix(`a:${pageRef}:@${anchorRef}`); + const allAnchors = await index.queryPrefix( + `a:${pageRef}:${anchorRef}`, + ); return { from: prefix.from + pageRefPrefix.length + 1, options: allAnchors.map((a) => ({ - label: a.key.split("@")[1], + label: a.key.split(":")[2], type: "anchor", })), }; diff --git a/plugs/core/core.plug.yaml b/plugs/core/core.plug.yaml index 657dab8b..aa77be7f 100644 --- a/plugs/core/core.plug.yaml +++ b/plugs/core/core.plug.yaml @@ -19,8 +19,8 @@ syntax: className: sb-command-link NamedAnchor: firstCharacters: - - "@" - regex: "@[a-zA-Z\\.\\-\\/]+[\\w\\.\\-\\/]*" + - "$" + regex: "\\$[a-zA-Z\\.\\-\\/]+[\\w\\.\\-\\/]*" className: sb-named-anchor functions: clearPageIndex: diff --git a/web/editor.tsx b/web/editor.tsx index a537cdc3..092a0917 100644 --- a/web/editor.tsx +++ b/web/editor.tsx @@ -201,7 +201,7 @@ export class Editor { const stateRestored = await this.loadPage(pageName); if (pos) { if (typeof pos === "string") { - // console.log("Navigating to anchor", pos); + console.log("Navigating to anchor", pos); // We're going to look up the anchor through a direct page store query... const posLookup = await this.system.localSyscall( @@ -209,7 +209,7 @@ export class Editor { "index.get", [ pageName, - `a:${pageName}:@${pos}`, + `a:${pageName}:${pos}`, ], ); diff --git a/website/CHANGELOG.md b/website/CHANGELOG.md index 8aaf8faf..1a1ea970 100644 --- a/website/CHANGELOG.md +++ b/website/CHANGELOG.md @@ -3,6 +3,16 @@ release. --- +## 0.1.4 + +- Breaking change (for those who used it): the named anchor syntax has changed + from `@anchorname` to `$anchorname`. This is to avoid conflicts with + potentialy future use of `@` for other purposes (like mentioning people). + Linking to an anchor still uses the `[[page@anchorname]]` syntax. So, you + create an anchor $likethis you can then reference it [[@likethis]]. + +--- + ## 0.1.3 - Silver Bullet now runs on Windows!