question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Relative URLs in readme markdown starting with `./` render broken

See original GitHub issue

Relative URLs in readme markdown starting with ./ should link to files within the package, but incorrectly deno.land renders them as if they are deno.land/x packages.

Here is an example readme with broken relative URLs (the top logo SVG, and various links to package modules):

https://deno.land/x/ruck@v1.0.0

Similar to a past issue (that was apparently fixed) for relative URLs that don’t start with ./:

https://github.com/denoland/dotland/issues/765

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
M4rteagacommented, Apr 19, 2022

It seems that in DisplayFile.tsx when rendering a markdown file the baseUrl prop is missing.

https://github.com/denoland/dotland/blob/46462c8a3c3ca830d49dfa110f26d3231231d334/components/FileDisplay.tsx#L114-L127

However in Markdown.tsx the baseUrl prop is optional but later is used to call the gfm function.

https://github.com/denoland/dotland/blob/46462c8a3c3ca830d49dfa110f26d3231231d334/components/Markdown.tsx#L4-L16

As part of the solution, I tried to add the baseUrl prop, but it still doesn’t work

baseUrl = {props.baseURL}

Conclusion

It seems that the problem is related to the gfm function that treats the markdown. This is a dependency linked to crowlKats/deno-gfm repo. There are some custom changes to the links. A think here is where the problem is.

https://github.com/crowlKats/deno-gfm/blob/663b1cc026ac881b2fe8928f157db0126ee08dba/mod.ts#L29-L34

 link(href: string, title: string, text: string) {
    if (href.startsWith("#")) {
      return `<a href="${href}" title="${title}">${text}</a>`;
    }
    return `<a href="${href}" title="${title}" rel="noopener noreferrer">${text}</a>`;
  }
0reactions
stabaicommented, Jul 30, 2022

I might be misunderstanding the code, but it looks like maybe the operation done here also needs to be done on the baseURL passed to FileDisplay:

https://github.com/denoland/dotland/blob/fe5cec62951471a242a719a386fd20d33e4c5de1/components/DocView.tsx#L43

Read more comments on GitHub >

github_iconTop Results From Across the Web

Relative link in readme broken if readme viewed automatically ...
The repo contains a README.md file. Within this README.md file I have a link so another .md file which is located in the...
Read more >
Relative urls in readme.md files only work half the time ... - Jira
I've confirmed that the problem with relative links only works if the readme is rendered at a specific commit. If it is rendered...
Read more >
Relative links in markup files - The GitHub Blog
Product. Relative links in markup files. We show rendered markup in several places on GitHub, most notably including a project's main README ......
Read more >
GitLab Flavored Markdown (GLFM)
The text is rendered with a set of styles. These styles are called GitLab Flavored Markdown. For example, in Markdown, an unordered list...
Read more >
Links and Cross References | DocFX website - NET
Please note that the file path in include syntax is handled differently than Markdown link. You can only use relative path to specify...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found