Editorial Workflows

CM Review

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: Workflow to process Critic Markup in document. Based on Macdrifter's [original workflow](http://www.editorial-workflows.com/workflow/6096637357195264/JyzjRq99yLM) with several changes:

- it will run in loop until all marks are processed or "cancel" tapped
- it processes comments and highlights (which can be accepted:preserved or rejected:erased)
- if some text selected it will be processed in the first loop (useful for dealing with individual marks in a longer text)

WARNING: To run in loop it uses subworkflow action which can fail if workflow's name is changed.

UPDATE: fixed bug which caused false repeats of the last loop

Shared by: @jakubowiak

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Selected Text ?
Entire Line(s)
OFF
Empty Selection Output
  • No Output
  • All Text
  • Closest Word
Folded Text
  • Include
  • Replace with:
Get All Critic Marks ?
Source Code
#coding: utf-8
import workflow
import editor
import re


action_in = workflow.get_input()
reg_pattern = r'((?s)\{([\+\+|\-\-|\~\~|\>\>])(.*?)([\+\+|\-\-|\~\~|\<\<])[ \t]*(\[(.*?)\])?[ \t]*\})'

# full_text = editor.get_text()
full_text = action_in
match_string = ''



reg_obj = re.compile(reg_pattern)

for m in reg_obj.finditer(full_text):
    match_string += str(m.group()) + '\t' + str(m.start()) + ':' + str(m.end()) + '\n'


#TODO: Generate the output...
action_out = action_in

workflow.set_output(match_string)
Remove Whitespace ?
  • Trim leading/trailing whitespace
  • Remove empty lines
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Stop ?
Stop
  • This Workflow
  • Repeat Block
Show HUD Alert
OFF
Message
Stopped
…End If
Select from List ?
Title
List (Lines)
Input
Multiple Selection
OFF
Show in Popover
OFF
If… ?
Run the block if
Selected Text
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Select Range ?
Range (from:to)
Input
Relative to
  • Entire Document
  • Current Selection
…End If
If… ?
Run the block if
Selected Text
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Select Range ?
Range (from:to)
Input
Relative to
  • Entire Document
  • Current Selection
…End If
Set Variable ?
Variable Name
matchPos
Value
Input
Show Alert ?
Title
Critic Markup
Message
Accept or Reject Selected Text
Button 1
Accept
Output Value
accept
Button 2
Reject
Output Value
reject
Button 3
(don't show)
Output Value
Show Cancel Button
ON
If Accept ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
accept
If Deletions ?
Run the block if
Selected Text
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
((?s)\{([\-\-])(.*?)([\-\-])[ \t]*(\[(.*?)\])?[ \t]*\})
Replace Selected Text ?
Replacement Text
…End If
If Additions ?
Run the block if
Selected Text
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
\{(\+\+)(.*?)(\+\+)[ \t]*(\[(.*?)\])?[ \t]*\}
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import re
import editor

selection = editor.get_selected_text()

reg_pattern = r'(?s)\{(\+\+)(.*?)(\+\+)[ \t]*(\[(.*?)\])?[ \t]*\}'

reg_obj = re.compile(reg_pattern)

clean_string = re.sub(reg_obj, '\\2', selection)

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in

workflow.set_output(clean_string)
Replace Selected Text ?
Replacement Text
Input
…End If
If Replace ?
Run the block if
Selected Text
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
\{(\~\~)(.*?)(\~\~)[ \t]*(\[(.*?)\])?[ \t]*\}
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import re
import editor

selection = editor.get_selected_text()

reg_pattern = r'''(?s)\{\~\~(?P<original>(?:[^\~\>]|(?:\~(?!\>)))+)\~\>(?P<new>(?:[^\~\~]|(?:\~(?!\~\})))+)\~\~\}'''


reg_obj = re.compile(reg_pattern)

clean_string = re.sub(reg_obj, r'\g<new>', selection)

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in

workflow.set_output(clean_string)
Replace Selected Text ?
Replacement Text
Input
…End If
If Highlight ?
Run the block if
Selected Text
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
\{(\=\=)(.*?)(\=\=)[ \t]*(\[(.*?)\])?[ \t]*\}
Show HUD ?
HUD Text
Selected Text - left as is
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"
…End If
If Comment ?
Run the block if
Selected Text
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
\{(\>\>)(.*?)(\<\<)[ \t]*(\[(.*?)\])?[ \t]*\}
Show HUD ?
HUD Text
Selected Text - left as is
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"
…End If
…End If
If Reject ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
reject
If Deletions ?
Run the block if
Selected Text
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
((?s)\{([\-\-])(.*?)([\-\-])[ \t]*(\[(.*?)\])?[ \t]*\})
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import re
import editor

selection = editor.get_selected_text()

reg_pattern = r'''(?s)\{\-\-(?P<value>.*?)\-\-[ \t]*(\[(?P<meta>.*?)\])?[ \t]*\}'''

reg_obj = re.compile(reg_pattern)

clean_string = re.sub(reg_obj, r'\g<value>', selection)

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in

workflow.set_output(clean_string)
Replace Selected Text ?
Replacement Text
Input
…End If
If Additions ?
Run the block if
Selected Text
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
\{(\+\+)(.*?)(\+\+)[ \t]*(\[(.*?)\])?[ \t]*\}
Replace Selected Text ?
Replacement Text
…End If
If Replace ?
Run the block if
Selected Text
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
\{(\~\~)(.*?)(\~\~)[ \t]*(\[(.*?)\])?[ \t]*\}
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import re
import editor

selection = editor.get_selected_text()

reg_pattern = r'''(?s)\{\~\~(?P<original>(?:[^\~\>]|(?:\~(?!\>)))+)\~\>(?P<new>(?:[^\~\~]|(?:\~(?!\~\})))+)\~\~\}'''


reg_obj = re.compile(reg_pattern)

clean_string = re.sub(reg_obj, r'\g<original>', selection)

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in

workflow.set_output(clean_string)
Replace Selected Text ?
Replacement Text
Input
…End If
If Highlight ?
Run the block if
Selected Text
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
\{(\=\=)(.*?)(\=\=)[ \t]*(\[(.*?)\])?[ \t]*\}
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import re
import editor

selection = editor.get_selected_text()

reg_pattern = r'(?s)\{(\=\=)(.*?)(\=\=)[ \t]*(\[(.*?)\])?[ \t]*\}'

reg_obj = re.compile(reg_pattern)

clean_string = re.sub(reg_obj, '\\2', selection)

action_in = workflow.get_input()

#TODO: Generate the output...
action_out = action_in

workflow.set_output(clean_string)
Replace Selected Text ?
Replacement Text
Input
…End If
If Comment ?
Run the block if
Selected Text
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
\{(\>\>)(.*?)(\<\<)[ \t]*(\[(.*?)\])?[ \t]*\}
Replace Selected Text ?
Replacement Text
…End If
…End If
Move Caret ?
Direction
  • Backward
  • Forward
  • Start/End of Document
  • Start/End of Line
  • Number of Characters:
1
Sub-Workflow ?
Workflow
Can Stop Main Workflow
ON