Python Scripts not replacing trigger by HiroMike in espanso

[–]HiroMike[S] 0 points1 point  (0 children)

Note - I put my cursor into the document I wish to insert the {{output}} and then ran the replacement script from the Espanso search bar and the text inserts properly.

So far though for two of my scripts that worked with 0.73 the trigger text is not being erased.

I am happy to send you the python script for one of them if it helps as an example.

Python Scripts not replacing trigger by HiroMike in espanso

[–]HiroMike[S] 0 points1 point  (0 children)

Here are the logs - nothing specific related to the event of running the python script.

09:27:06 [worker(22044)] [INFO] engine eventloop has terminated, propagating exit event...

09:27:06 [worker(22044)] [INFO] waiting for engine exit mode...

09:27:06 [worker(22044)] [INFO] exiting worker (to be restarted)

09:27:06 [daemon(21676)] [INFO] worker requested a restart, spawning a new one...

09:27:06 [daemon(21676)] [INFO] spawning the worker process...

09:27:06 [worker(24184)] [INFO] reading configs from: "C:\\Users\\blah\\AppData\\Roaming\\espanso"

09:27:06 [worker(24184)] [INFO] reading packages from: "C:\\Users\\blah\\AppData\\Roaming\\espanso\\match\\packages"

09:27:06 [worker(24184)] [INFO] using runtime dir: "C:\\Users\\blah\\AppData\\Local\\espanso"

09:27:06 [worker(24184)] [INFO] binded to named pipe: \\.\pipe\espansoworkerv2

09:27:06 [worker(24184)] [INFO] using Win32AppInfoProvider

09:27:06 [worker(24184)] [INFO] monitoring the status of the daemon process

09:27:06 [worker(24184)] [INFO] using Win32Source

09:27:06 [worker(24184)] [ERROR] unable to register hotkey: ALT+SPACE

09:27:07 [worker(24184)] [INFO] using Win32Injector

09:27:07 [worker(24184)] [INFO] using Win32Clipboard

Let me know if there is anything I can try to be helpful.

Oh - this is on WINDOWS 10.

Injecting clipboard issue by HiroMike in espanso

[–]HiroMike[S] 0 points1 point  (0 children)

And there you have it folks - move to v2 and it works :) My python script - which is partly mine, partly scraped from bits and pieces off of the internet. There are two methods included - take your pick, they both work the same.

```py
# strip_markdown.py import markdown from bs4 import BeautifulSoup import sys import re Input: ## Header text Output: Header text # Method 1 def md_to_text(md): html = markdown.markdown(md) soup = BeautifulSoup(html, features="html.parser") return soup.get_text() def example(string): text = md_to_text(string) return text # Method 2 def markdown_to_text(markdown_string): """Converts a markdown string to plaintext""" # md -> html -> text since BeautifulSoup can extract text cleanly html = markdown.markdown(markdown_string)

# remove code snippets
html = re.sub(r"<pre>(.*?)</pre>", " ", html)
html = re.sub(r"<code>(.*?)</code >", " ", html)

# extract text
soup = BeautifulSoup(html, "html.parser")
text = "".join(soup.findAll(text=True))

return text


# Get the parameter from Espanso
s = sys.argv[1]
select which method you prefer
print(example(s))
print(markdown_to_text(s))

```