Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can rich text or HTML source code be obtained from the X clipboard? For example, if you copy some text from a web browser and paste it into kompozer, it pastes as HTML, with links etc. preserved. However, xclip -o for the same selection just outputs plain text. I'd like to pull the HTML out and into a text editor.

share|improve this question
    
It does appear to obtain the HTML source itself: things like the class properties of <div> elements are preserved. –  intuited May 23 '10 at 3:08
    
improve the title of your question to match what you really want: the source code of the website / rich text... –  akira Jul 6 '10 at 10:42
    
@akira: Thanks for your suggestion. It would have been more polite to phrase it as such. –  intuited Jul 6 '10 at 15:12
    
not polite, just more to the point :) –  akira Jul 6 '10 at 18:39

2 Answers 2

up vote 1 down vote accepted

With some help from the answer to the stackoverflow.com fork of this question, I built a ghetto command-line client to pull this info.

Usage

clipcli [-h] [-f FILE] [-d] [-l] [TARGET]

positional arguments:
  TARGET                display the contents of this target

optional arguments:
  -h, --help            show this help message and exit
  -d, --debug           enable debug tracing
  -f FILE, --file FILE  the file to which output will be directed
  -l, --list            list available targets

Example:

$ clipcli text/html
some text with <em>emphasis</em>

The way this works, even the availability of different targets, seems to depend a lot on the application which is providing the clipboard data. There's a bit more info at the stackoverflow question.

share|improve this answer

Does xclip -o -selection secondary or xclip -o -selection clipboard work for you?

These could be abbreviated to

xclip -o -se s 

and

xclip -o -se c
share|improve this answer
    
No, that still gives a textual rendering of the page rather than the HTML source. –  intuited May 23 '10 at 2:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.