-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discuss about converting block links to markdown #347
Comments
What Block links do in HTML is just enlarge the clickable area. I think we can safely convert them into Markdown with easy understand format. Here's my thoughts about these convertions: Image block linksHTML: <a href="/link.html">
<div>
<img src="a-picture.png" alt="alt-text" title="title-text">
<div>
</a> To convert these image block links, we can just put the link below the image, like this: Markdown: ![alt-text](a-picture.png "title-text")
[link-text](/link.html)
Note that we padding the whole content with two line breakers (the markdown render of Github may ignore these lines, So you might not seeing them) so that it won't become a inline image. And about the "link-text" we can use either alter-text or title-text if it's exist. Or a hard-coded one like: "picture link" if none of them is exist. As markdown supports image links, we can of cause convert it to common markdown format, like block links of multiple lines of textHTML: <a href="/link.html">
<div>
<p>line A</p>
<p>line B</p>
<p>line c</p>
</div>
</a> This case is very common in some clickable cards on web page, such as: online shopping item cards, contact info cards etc. We can't simply put the link below the text content in this case. Instead, we can wrap these lines with two links, one at the beginning, one at the end. link this: Markdown: [↓↓↓](/link.html)
line A
line B
line C
[↑↑↑](/link.html)
Note that we also padding the whole content with two link breakers, and we using three downward arrows and three upward arrows as link text. other block links?
What's on your mind? please comment below. |
@Golddouble About the block links of multiple lines of text, discuss here. |
Before I say anything about "block links of multiple lines of text" I would like to ask, how you managed to convert the "image block links" into clean Markdown. I think of it like this:
Is that how it works? If so, couldn't you now simply also mark ...
... and after convert them in a good looking Markdown file? |
Actually, we modify the html before pass it to Turndown. It's kind of like preprocess the html. We decide what the final format is, then modify the html so it'll not contains block links and feed it to Turndown to get the result. It shouldn't be hard to write the code, but hard to figure out all situations. And we need to decide what markdown format each situation will be converted to. I met a new case today: <a href="/link.html>
<h2>a section header</h2>
</a>
and it get converted to: [
## a section header
](/link.html) I think it should be converted to: ## [a section header](/link.html) but I don't remember that markdown can support header links, and I tried it on some online markdown editors, they did know how to render this markdown. |
I've published a new version(v0.4.39) that contains preprocess of block links. It should handle the cases that mentioned above. It's not perfect, we will enhance it when we encounter new problems. |
Thank you. I will let you know, when I encounter new problems.
I use markdown in Obsidian. And Obsidian also renders ## . So no problem for Obsidian either. |
I can reproduce this problem, will fix it in next version. |
Discuss about converting block links to markdown
Block links are links that wrap a block (image, multiple line text etc.). As there's not coressponding format in markdown. We need to discuss about how we convert these block links.
The text was updated successfully, but these errors were encountered: