Editorial Workflows

Wrap Multiple Selections

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: Given multiple saved text selections (type "n" to break the repeat loop), the workflow wraps each non-contiguous selection inside user-specified characters.

Shared by: @viticci

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Set Variable ?
Variable Name
sel
Value
Set count (generate text with specified number of lines) ?
Run Python Script ?
Source Code
import editor
import console
import workflow

count = workflow.get_input()
s = workflow.get_variable('sel')
console.clear()

for line in count:
	x = raw_input('Save More Text?\n\nSelect some text and enter \'y\' or \'n\':')
	if 'y' in x:
		s += '\n' + str(editor.get_selection())
		workflow.set_variable('sel', s)
	if 'n' in x:
		break
Generate Text ?
Text
sel
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
Find / Replace ?
Find
(
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Find / Replace ?
Find
)
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Sort Lines ?
Sort Order
  • Ascending (A → Z)
  • Descending (Z → A)
Set Variable ?
Variable Name
sel
Value
Input
Request Text Input ?
Title
Insert Left
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
Set Variable ?
Variable Name
left
Value
Input
Request Text Input ?
Title
Insert Right
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
Set Variable ?
Variable Name
right
Value
Input
Generate Text ?
Text
sel
Repeat… ?
Repeat with
  • Every Line
  • Every Match of Regular Expression:
Match Group
0 (entire match)
Reverse
ON
Run Python Script ?
Source Code
import editor
import workflow

range = workflow.get_input()
sel = range.split(',')

left = workflow.get_variable('left')
right = workflow.get_variable('right')

editor.set_selection(int(sel[0]), int(sel[1]))
original = editor.get_selected_text()
editor.replace_text(int(sel[0]), int(sel[1]), left + original + right)
…End Repeat