Skip to content

Commit

Permalink
fix #8
Browse files Browse the repository at this point in the history
davisriedel committed Feb 20, 2024
1 parent ab22ce4 commit 4b349ec
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 8 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
@@ -102,7 +102,13 @@ export default class Linkify extends Plugin {
evt.target.className.includes("cm-link linkified")) {
let m = this.matchRule(evt.target.innerText);
if (m != null) {
window.open(m.link);
// try to match internal link
const internalLinkMatch = m.link.match(/^\[\[([^|\]]*)(?:\|[^|\]]*)?\]\]$/);
if (internalLinkMatch != null) {
this.app.workspace.openLinkText(internalLinkMatch.at(1), "");
} else {
window.open(m.link);
}
}
}
}
@@ -149,8 +155,7 @@ export default class Linkify extends Plugin {
// Converts matching text in the HTMLElement into links.
markdownPostProcessor(el: HTMLElement) {
if (el.firstChild instanceof Node) {
let walker = document.createTreeWalker(
el.firstChild, NodeFilter.SHOW_TEXT, null);
let walker = document.createTreeWalker(el.firstChild, NodeFilter.SHOW_TEXT, null);
let nodes: Node[] = [];
let node: Node;
while (node = walker.nextNode()) {
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"name": "linkify",
"version": "1.0.13",
"description": "Turns strings into links.",
"main": "main.js",
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
@@ -12,13 +12,13 @@
"author": "",
"license": "MIT",
"devDependencies": {
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
"builtin-modules": "^3.2.0",
"@types/node": "^20.11.19",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"builtin-modules": "^3.3.0",
"esbuild": "0.13.12",
"obsidian": "latest",
"tslib": "2.3.1",
"typescript": "4.4.4"
"tslib": "2.6.2",
"typescript": "5.3.3"
}
}

0 comments on commit 4b349ec

Please sign in to comment.