Editorial Workflows

ASCII Punctuation

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: Gets rid of non-ascii punctuation (“”—•‘’…−), replaces with ascii equivalents (the dot turns into a hyphen). Mainly to keep stuff from breaking when moving from, e.g., Microsoft word to HTML, without having to muck around with encoding. Not guaranteed to work with all input encodings, but I haven't managed to break it yet.

EXAMPLE INPUT: This has some “st—up•id ‘char−acters’, in its’ string…”

EXAMPLE OUTPUT: This has some "st-up-id 'char-acters', in its' string..."

Shared by: Paul Gowder (paul-gowder.com)

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

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

text = editor.get_text()	

drek = {'“': '"', '”': '"', "’": "'", "‘": "'", '—': '-', '−': '-', '…': '...', '•': '-', '–':'-'}

def clean(text):
  for key in drek.keys():
    text = text.replace(key, drek[key])
  return text

fixed = clean(text)

editor.replace_text(0, len(text), fixed)