Webpage snippet to Markdown with formatting and links

I want to capture a section of a webpage in Markdown. For example, I want the top answer of this question https://unix.stackexchange.com/questions/2464/timestamp-modification-time-and-created-time-of-a-file

I’ve selected the text which includes formatting, codeblocks, and urls.

I’ve tried:

  • safari DT clipper to markdown (regular and clutter-free) - which doesn’t clip the selected text but instead clips the last answer and not even the whole page. This doesn’t seem like correct behavior but it could be the formatting of the webpage
  • copy and paste into the sorter to Markdown - loses the formatting and the urls
  • copy and paste into the sorter to rich text - This maintains formatting and urls. If I then right click and convert this to markdown, then the new file loses the formatting and the urls.

What is the recommended way to capture this to Markdown with the formatting and the urls?

Maybe not exactly the answer you are looking for but it works: If you use the fantastic PopClip you could install its Copy as Markdown extension. This will, unlike the also existing Clip to DEVONthink extension (and DT’s Markdown service), keep formatting and links, even images.

I’d love to see this (at least as an option) in PopClip’s Clip to DEVONthink extension and in DEVONthink’s Markdown service. And a real Convert to Markdown and not just to plain text too.

2 Likes

Thanks, I’m hoping to find another workaround within DT or even DTTG.

@houthakker posted a very nice macro in the Keyboard Maestro Forum Convert HTML to Markdown in buffer for pasting?.

You could copy manually and paste as markdown using this macro. Should be easy to add a copy action or to use his code independent from Keyboard Maestro if you don’t use it.

1 Like

Unfortunately, I don’t have keyboard maestro. Any other recommendations? Thanks

I think his code can be used without Keyboard Maestro. I’ll check this

Unfortunately it’s not as simple as I thought as the Safari AppleScript command do javascript does not report results back to AppleScript. Maybe @houthakker can point to a solution?