Editorial Workflows

Critic 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: This workflow provides a review service for Critic Markup syntax (http://criticmarkup.com).

Displays a list of all Critic Markup ADDITION, DELETION, and SUBSTITUTION marks. Selecting one will move the selection and offer an Accept or Reject option.


::: Made by Macdrifter.com
::: Version 1.0

Shared by: Macdrifter.com

Comments: Comment Feed (RSS)

@jakubowiak — 26 May 2014
Changing str() to unicode () in the first script allows to work with unicode texts.

Also, it would be great if the workflow could be repetitive, so it would run until the last change is accepted or rejected, or the workflow cancelled.

+ Add Comment

Workflow Preview
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()
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)
Select from List ?
Title
List (Lines)
Input
Multiple Selection
OFF
Show in Popover
OFF
Select Range ?
Range (from:to)
Input
Relative to
  • Entire Document
  • Current Selection
Set Variable ?
Variable Name
matchPos
Value
Input
Show Alert ?
Title
Critic Markup
Message
Accept or Reject
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
…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
…End If