Skip to content

Commit b30f7bd

Browse files
nucclaude
andcommitted
docs: end-user install + commit prebuilt dist
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>
1 parent 5c0ebc4 commit b30f7bd

4 files changed

Lines changed: 54 additions & 36 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
node_modules/
2-
dist/
32
.DS_Store
43
*.log

README.md

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,61 @@
11
# MarkEdit-wikilinks
22

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).
44

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.
66

7-
## Features
7+
## Installation
88

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.
1738

1839
## Not yet supported
1940

2041
- `#header` and `^block-id` fragments — stripped, not navigated.
2142
- Inline embed rendering — `![[image.png]]` is highlighted but not displayed as an image.
2243
- Vault index caching — the recursive search rebuilds per click. Fast enough for hundreds of files; large vaults may want a session-scoped index.
2344
- Autocomplete for link targets.
45+
- User-configurable settings.
2446

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
31-
```
32-
33-
The compiled bundle lands at:
34-
`~/Library/Containers/app.cyan.markedit/Data/Documents/scripts/markedit-wikilinks.js`
47+
## Building
3548

36-
To uninstall: `yarn uninstall`.
37-
38-
### Sandbox / folder access
39-
40-
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.
4450

4551
## Architecture
4652

4753
```
48-
main.ts wires three pieces into MarkEdit
54+
main.ts wires four pieces into MarkEdit
4955
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
5259
```
5360

5461
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:
5764
- play nicely with code folding and syntax-aware selection,
5865
- let the click handler use `syntaxTree.resolveInner(pos)` instead of re-matching against document text.
5966

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
6170

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.
6372

6473
## License
6574

dist/markedit-wikilinks.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "markedit-wikilinks",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Obsidian-style [[wikilinks]] for MarkEdit.",
55
"keywords": [
66
"markedit",

0 commit comments

Comments
 (0)