You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mirror the MarkEdit-preview README structure: lead with the prebuilt
dist file so end users don't need a Node toolchain. The yarn-based
build flow becomes a "Building" section for contributors.
- Remove dist/ from .gitignore so the prebuilt bundle ships with the repo.
- Commit dist/markedit-wikilinks.js (6.35 kB) for direct raw-download install.
- Rewrite README with How to Use table (syntax + click behavior), explicit
resolution order, sandbox/folder-access note, and architecture notes
including the preview integration.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+43-34Lines changed: 43 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,54 +1,61 @@
1
1
# MarkEdit-wikilinks
2
2
3
-
Obsidian-style `[[wikilinks]]` for [MarkEdit](https://github.com/MarkEdit-app/MarkEdit).
3
+
Obsidian-style `[[wikilinks]]` for [MarkEdit](https://github.com/MarkEdit-app/MarkEdit) that leverages [markedit-api](https://github.com/MarkEdit-app/MarkEdit-api).
4
4
5
-
A small CodeMirror extension that adds wikilink syntax highlighting and Cmd-click navigation, with Obsidian-style vault-wide resolution.
5
+
A small CodeMirror extension that adds wikilink syntax highlighting and click-to-follow navigation, with Obsidian-style vault-wide resolution. Renders in both the editor and the [MarkEdit-preview](https://github.com/MarkEdit-app/MarkEdit-preview) pane.
6
6
7
-
## Features
7
+
## Installation
8
8
9
-
-**Highlights**`[[Note Name]]`, `[[Note|Alias]]`, and `![[Embed]]` as real syntax nodes — implemented via a Lezer inline parser so it composes correctly with the rest of MarkEdit's Markdown grammar and stays inert inside fenced code blocks.
10
-
-**Cmd-click in the editor** opens the linked file. Resolution mirrors Obsidian:
11
-
1. same folder as the current file,
12
-
2. vault-relative path if the target contains `/` (e.g. `[[docs/foo]]`),
13
-
3. recursive search from the vault root (the directory containing `.obsidian/`), skipping hidden and noisy folders, budget-capped at 5,000 entries per click.
14
-
-**Plain click in the [MarkEdit-preview](https://github.com/MarkEdit-app/MarkEdit-preview) pane** also follows wikilinks. The preview integration post-processes the rendered HTML (the preview plugin's `markdown-it` pipeline doesn't know `[[…]]`), turning text nodes into anchors with the same resolver, and is a no-op if MarkEdit-preview isn't installed.
15
-
-**Create-on-miss**: if nothing resolves, prompts to create `<target>.md` in the current folder.
16
-
-**Styled** via CSS classes that pick up your MarkEdit theme.
9
+
Copy [dist/markedit-wikilinks.js](dist/markedit-wikilinks.js?raw=true) to `~/Library/Containers/app.cyan.markedit/Data/Documents/scripts/`. Details [here](https://github.com/MarkEdit-app/MarkEdit/wiki/Customization#entries).
10
+
11
+
> Once installed, restart MarkEdit to apply the changes.
12
+
>
13
+
> If wikilink resolution fails because the file is in a sibling folder, you may also need to [grant folder access](https://github.com/MarkEdit-app/MarkEdit/wiki/Customization#grant-folder-access) by opening your vault root via **File → Open…** once.
14
+
15
+
## How to Use
16
+
17
+
Type any Obsidian-style wikilink in your Markdown:
18
+
19
+
| Syntax | Meaning |
20
+
|---|---|
21
+
|`[[Note Name]]`| Link to `Note Name.md`|
22
+
|`[[Note Name\|Display Text]]`| Link with custom display text |
23
+
|`[[docs/foo]]`| Vault-relative path |
24
+
|`![[Embed]]`| Embed syntax (highlighted, not yet rendered as image) |
25
+
26
+
To follow a link:
27
+
28
+
-**In the editor**: <kbd>⌘</kbd>-click on the wikilink.
29
+
-**In the [MarkEdit-preview](https://github.com/MarkEdit-app/MarkEdit-preview) pane**: plain click.
30
+
31
+
Resolution mirrors Obsidian, in this order:
32
+
33
+
1.**Same folder** as the current file.
34
+
2.**Vault-relative path** if the target contains `/` (e.g. `[[docs/foo]]`).
35
+
3.**Recursive search** from the vault root (the directory containing `.obsidian/`), skipping hidden dot-dirs and `node_modules` / `dist` / `build` / `target`, budget-capped at 5,000 entries per click.
36
+
37
+
If nothing resolves, a diagnostic dialog shows what was tried and offers to create `<target>.md` in the current folder.
17
38
18
39
## Not yet supported
19
40
20
41
-`#header` and `^block-id` fragments — stripped, not navigated.
21
42
- Inline embed rendering — `![[image.png]]` is highlighted but not displayed as an image.
22
43
- Vault index caching — the recursive search rebuilds per click. Fast enough for hundreds of files; large vaults may want a session-scoped index.
23
44
- Autocomplete for link targets.
45
+
- User-configurable settings.
24
46
25
-
## Install
26
-
27
-
```sh
28
-
yarn install
29
-
yarn build # vite build also deploys the bundle to MarkEdit's scripts/ folder
30
-
yarn reload # restart MarkEdit so the script loads
MarkEdit is sandboxed and only sees folders you've explicitly granted access to.
41
-
If `[[…]]` resolution fails with `listFiles() returned undefined` in the diagnostic
42
-
alert, open your vault folder once via **File → Open…** to grant access. See
43
-
[the MarkEdit wiki on folder access](https://github.com/MarkEdit-app/MarkEdit/wiki/Customization#grant-folder-access) for details.
49
+
Run `yarn install && yarn build` to build and deploy the script. The build also copies the bundle to MarkEdit's scripts folder, so a `yarn reload` will pick up your changes immediately.
44
50
45
51
## Architecture
46
52
47
53
```
48
-
main.ts wires three pieces into MarkEdit
54
+
main.ts wires four pieces into MarkEdit
49
55
src/parser.ts Lezer inline parser → emits WikiLink / WikiLinkEmbed / Mark / Target / Alias nodes
50
-
src/decoration.ts CodeMirror ViewPlugin → styles those nodes
51
-
src/follow.ts domEventHandlers → Cmd-click resolves and opens
56
+
src/decoration.ts CodeMirror ViewPlugin → styles those nodes in the editor
57
+
src/follow.ts domEventHandlers → ⌘-click in the editor → resolve and open
58
+
src/preview.ts MutationObserver on .markdown-body → transform text into <a> + plain-click handler
52
59
```
53
60
54
61
A real Lezer parser is used rather than a regex decoration so wikilink nodes:
@@ -57,9 +64,11 @@ A real Lezer parser is used rather than a regex decoration so wikilink nodes:
57
64
- play nicely with code folding and syntax-aware selection,
58
65
- let the click handler use `syntaxTree.resolveInner(pos)` instead of re-matching against document text.
59
66
60
-
## Contributing
67
+
The preview integration post-processes the rendered HTML inside `.markdown-body` because MarkEdit-preview's [markdown-it](https://github.com/markdown-it/markdown-it) pipeline doesn't know `[[…]]` and has no extension API for adding parsers. The observer skips text inside `<code>`, `<pre>`, `<script>`, `<style>`, and existing `<a>` elements, and disconnects during its own mutations to avoid feedback loops. It's a no-op when MarkEdit-preview isn't installed.
68
+
69
+
## Contribution
61
70
62
-
Issues and PRs welcome. Build verification runs via GitHub Actions on every push and PR.
71
+
Issues and PRs welcome. Build verification runs via GitHub Actions on every push and PR. If you change source, please run `yarn build` and commit the updated `dist/markedit-wikilinks.js` along with your changes so end users get the fix without needing a toolchain.
0 commit comments