yorkxin / copy-as-markdown

A browser extension to copy tabs and links as Markdown
MIT License
529 stars 81 forks source link

Copy Page Selection should resolve relative links to absolute URLs #136

Closed yorkxin closed 4 months ago

yorkxin commented 4 months ago

Summary

When using Copy Selection as Markdown (introduced in #132 ), links still use relative links.

Since the result Markdown code is intended to be used in external documents, it is necessary to resolve relative links.

Reproduction Steps

  1. Go to https://www.iana.org/help/example-domains
  2. Select texts including links.
  3. Right Click and choose "Copy Selection as Markdown"

Expected Behavior

Actual Behavior

Reproducible Environment

yorkxin commented 4 months ago

The Turndown library doesn't seem to provide such a feature that resolves relative paths to absolute URLs.

It might be easier to just traverse through all the <a> and <img> tags, then convert URLs to absolute ones.