Skip to content

Commit 61a6ef4

Browse files
committed
fix #284
1 parent 5cb9c58 commit 61a6ef4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/sourceViewObserver.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ export default class SourceViewObserver {
9090
const filePath = this.plugin.app.workspace.getActiveFile()?.path;
9191
if (!activeLeaf || filePath === undefined) return;
9292

93-
const regex2Find = /(?<=[[]{2})[^\]]*(?=[\]]{2})/gm;
93+
const regex2FindLinks = /[[]{2}[^\]]*(?=[\]]{2})/gm;
9494
const view = activeLeaf.leaf.view.containerEl;
9595
const editor = activeLeaf.editor;
9696
const oldText = editor.getValue();
97-
const linkHref = oldText.match(regex2Find);
97+
const linkHref = oldText.match(regex2FindLinks)
9898
if(!linkHref || linkHref.length == 0) return;
9999

100100
const tempSourceLinks = view.getElementsByClassName('cm-hmd-internal-link cm-link-alias') as HTMLCollectionOf<HTMLAnchorElement>;
@@ -130,7 +130,10 @@ export default class SourceViewObserver {
130130
for (let i = 0; i < sourceLinks.length; i++) {
131131
const tempLink = linkHref[i];
132132
if (typeof tempLink != 'string') continue;
133-
const parsedLink = parseLinktext(tempLink.split('|')[0]);
133+
134+
// substring used remove [[ from internal link
135+
// because iOS doesn't support positive lookback regex
136+
const parsedLink = parseLinktext(tempLink.substring(2).split('|')[0]);
134137
const annotationid = parsedLink.subpath.startsWith('#^') ? parsedLink.subpath.substring(2) : null;
135138
const file: TFile | null = this.plugin.app.metadataCache.getFirstLinkpathDest(parsedLink.path, filePath);
136139

0 commit comments

Comments
 (0)