Nobody mentioned yet klembord. It works on Linux and Windows, and supports HTML clipboard format.
Installation
pip install klembord
Usage
import klembord
klembord.init()
# Case 1
klembord.set_with_rich_text('', 'Normal text, <i>Italic text</i>, <b>Bold text</b>, Normal text')
# Case 2
klembord.set_with_rich_text('', 'This is a <a href="https://github.com/OzymandiasTheGreat/klembord">link</a>')
Short explanation
The set_with_rich_text
takes two arguments. The first argument is the plain text alternative, which is used if you paste the content somewhere that does not support rich text formatting (such as Notepad). The second argument is the html formatted clipboard, which supports for example <a>
, <i>
and <b>
HTML tags.
Example output
When pasted to a rich text editor, the output from the example above would look like this:
