Skip to content

Relative links in markdown files resolve against temp directory instead of source file location #19

@mralexhollis

Description

@mralexhollis

When a markdown file containing relative links is opened in MDLook, clicking those links navigates to a temp directory rather than the linked file.

Steps to reproduce:

  1. Create two markdown files in the same directory, e.g. index.md and other.md
  2. Add a relative link in index.md: other
  3. Open index.md in MDLook (Read mode)
  4. Click the link

Expected behaviour:
MDLook opens other.md from the same directory as index.md.

Actual behaviour:
MDLook attempts to resolve the link relative to a temp directory, so the file is not found.

Root cause (suspected):
MDLook likely renders markdown by generating a temporary HTML file and loading that into WebView2. If the WebView2 Source URL is set to the temp file's path rather than the original file's directory, relative links will resolve against the wrong base path. Setting the navigation base URL to the directory of the source .md file should fix this.

Context:
Relative links between markdown files are a standard documentation pattern (used by GitHub, VS Code, Obsidian, etc.). Having them work correctly would make MDLook viable for multi-file documentation sets and wikis.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions