I'm writing a pluma plugin (in python) to automate HTML markup of a selected text.
According to (the poor and scarce) documentation, the selected text in the editor should be found in os.environ["PLUMA_SELECTED_TEXT"].
However, when I select some text, run my plugin and examine the environment there is no variable such as "PLUMA_SELECTED_TEXT".
I do find 'PLUMA_CURRENT_LINE' but it contains only the last line of the selected text.
Here is the plugin itself (with debugging stuff...)
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import re
print(os.environ)
try:
ptext = os.environ["PLUMA_SELECTED_TEXT"]
except KeyError:
ptext = "SELECTION NOT FOUND"
print(ptext)
#ptext = re.sub('\n','<br/>\n',ptext)
#ptext = "<p>\n%s\n</p>\n"%ptext
#print(ptext)
Anyone ran into this?
I found the solution, for the benefit of whoever runs into this.
The selected text is actually sent to the script as STDIN so this needs to be read.
Hence the code looks like that: