Question

I want to be able to highlight a section of a web page (which could be any web page I happen to be viewing) and copy it to the clipboard then save it to my local disk as markdown. I need an efficient way to do that. I'm on Kubuntu 12.04 and I want to use PySide. (I don't have any experience with Python, Qt or any related tools, but I googled around and found PySide highly recommended and I completed a Hello World tutorial so far.)

My current cumbersome method is:

  1. highlight section and copy to clipboard
  2. open Libre Office Writer
  3. paste into Writer
  4. save Writer doc as HTML
  5. open terminal
  6. cd to the directory where I saved the HTML
  7. pandoc -s -r html /home/me/a/b/mydoc.html -o /home/me/a/b/mydoc.md

Obviously, I need a better method!

Here's my original question:
https://unix.stackexchange.com/questions/78395/save-html-from-clipboard-as-markdown-text

That pointed me to this possible answer:
getting HTML source or rich text from the X clipboard

The above is what motivated me to do this in Python.

I need a KDE/PySide version of the answer above that also incorporates the pandoc conversion to markdown step. It seems simple enough except for replacing the gtk.Clipboard commands with their equivalent KDE Clipboard commands. I have no idea about that.

Was it helpful?

Solution

This can be done via recent versions of xclip which support the -t text/html (target selection) and pandoc to convert html to markdown.

See the details: Save HTML from clipboard as markdown text - Unix & Linux Stack Exchange

Thanks to @mountainx for asking again on the Unix stackexchange, which provided this solution, as noted in a comment above.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top