Right now (version 0.1) writes markdown links with Alt text as the text by default.
A bookmark block looks like:
{
"type": "bookmark",
//...other keys excluded
"bookmark": {
"caption": "",
"url": "https://website.domain"
}
}
markdownify_block()
right now builds the markdown string as
md_text = f"[Alt text]({_content['url']})"
Version 0.1 was focused on paragraph
and heading_*
blocks mostly so this was overlooked.
Option 1 (rejected)
was to use a bookmark
's caption as the Alt text
. This would require that we add captions to all bookmarks which is not something that's commonplace.
Option 2
is to "clean" the URL and use that as the Alt text
. For example, "https://github.com/stedolan/jq/issues/124#issuecomment-17875972"
would become "github.com/stedolan/jq/issues/124"
.
from urllib.parse import urlparse
# ...
_url = _content['url']
_, netloc, path, *_ = urlparse(_url)
md_text = f"[{netloc + path}]({_url})"
This way we're not obfuscating the link's destination.
Option 3 (maybe in the future)
We could ping the URL and extract the page's title and/or other info. This option may be cool to implement down the line but not right now.
enhancement