• I was having the same issue! but I figured it out, you have to add a "wait to return" to make sure the pythonista code finishes running before the shortcut does. Hopefully it was the same issue if you haven't figured It out yet.

  • @uj_jonas said:

    @Phuket2 keeps importing editor without using it

    Favoriting for this 😆

  • Your best bet is to create an appex module, which lets you use the share module to open the file.

    You could use pyrtf to read the file, or there are some objc methods that can convert rtf to text.

    it might help if you describe what app you are starting from, and whether you just need text extracted, or care about formatting?

  • Jon - thanks, you set me on the right track -- the app I want to paste into (MarginNote) accepts rich text only if it's formatted as an Apple Web Archive type. Here's how I ultimately got it to work for Python 2.7, thanks to this guide on coercing HTML into an archive type:

    from objc_util import * import os import base64 theDefinition = '<html><head></head><body>''<font size="5">' + '<b>Hello</b> <i>world!2</i>' + '</font></body></html>' theData = base64.encodestring(theDefinition) theData = str(theData) theArchive = """<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>WebMainResource</key> <dict> <key>WebResourceData</key> <data> """ + theData + """ </data> <key>WebResourceFrameName</key> <string></string> <key>WebResourceMIMEType</key> <string>text/html</string> <key>WebResourceTextEncodingName</key> <string>UTF-8</string> <key>WebResourceURL</key> <string>about:blank</string> </dict> </dict> </plist>""" thePasteBoard = ObjCClass('UIPasteboard') thePasteBoard = thePasteBoard.generalPasteboard() theType = "Apple Web Archive pasteboard type" thePasteBoard.setValue_forPasteboardType_(theArchive,theType)
Internal error.

Oops! Looks like something went wrong!