Skip to content

markdown links are not workingΒ #112

@gooseleggs

Description

@gooseleggs

I have been using this plugin in for a while, but decided that I wanted to move to Markdown links instead of Wikilinks. This broke this plugin. Since this plugin does not seem to have been updated for a while, I have not created a PR.

However, I have modified the main.js file (with the help of ChatGPT). Replace the getLinkFile with this one. It seems to work in my instance, but your mileage may vary...

     getLinkFile(link) {
      const markdownFiles = this.app.vault.getMarkdownFiles();

      // 1. Decode URL-encoded characters (e.g. %20)
      let linkPath = decodeURIComponent(link.link);

      // 2. Remove .md extension if present
      if (linkPath.toLowerCase().endsWith(".md")) {
        linkPath = linkPath.slice(0, -3);
      }

      // 3. Normalise path (Obsidian paths never start with '/')
      linkPath = linkPath.replace(/^\/+/, "");

      return markdownFiles.find(f =>
        // Exact path match (folder/note)
        f.path === `${linkPath}.md` ||

        // Match by filename only (wikilinks without folder)
        f.path.endsWith(`/${linkPath}.md`) ||

        // Match root-level notes
        f.name === `${linkPath}.md`
      );
    }

From what I can see, the difference in the links between WikiLinks and Markdown lists are two fold. Markdown links:

  1. are URL encoded, ie spaces become %32
  2. have .md at the end of link.link
    The change to the above function addresses both of these, while still working with Wikilinks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions