Editorial Workflows

Lucky Link

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Replaces the selected word(s) with a Markdown link, pointing to the first Google result. E.g. when you select "Markdown", it is replaced with "[Markdown](http://daringfireball.net/projects/markdown)".

Shared by: catlegsworktoo

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Run Python Script ?
Source Code
#coding: utf-8
import editor
import console

def main():
	text = editor.get_selected_text()
	if not text:
		console.hud_alert('Nothing Selected', 'error')
		return
	import requests
	import urllib
	url = 'https://www.google.com/search?q=%s&btnI' % (urllib.quote(text, ''),)
	try:
		r = requests.head(url)
		link_url = r.headers['location']
		md_link = '[%s](%s)' % (text, link_url)
		editor.insert_text(md_link)
	except:
		console.hud_alert('Something went wrong', 'error')

main()