aeryn.online
photography, painting, digital, glitch, experimental, story-telling, writing, poetry, mixed media, love, universal patterns, apps, algorithms
2017-02-19-2238.jpg

"log"

a log by aeryn


 

scoredashify script

20170617_2226.png

A python slugify script I found and modified to create url slugs according to my own preference.

I don't understand python or regex very well, but it converts spaces to underscores, leaves alpha-numeric characters alone, and everything else becomes a dash.

I've made it into a service on my Mac so I can highlight text, run the service and paste the scoredashified text.

I wonder if I can use this script on my iPad. I have Editorial and Workflow apps, both run scripts I think.

# Based on Django's slugify text utility
# Use Automator's Run Shell Script action
# Set Shell to: /usr/bin/python;
# Set Pass input to: to stdin
# Add a keyboard shorcut (ctrl+alt+cmd+d)

import sys
import re
import unicodedata

slug_character = '_'

for value in sys.stdin:
    value = unicodedata.normalize('NFKD', value.decode('UTF-8')).encode('ascii', 'ignore').decode('ascii')
    value = re.sub('[^\w\s-]', '-', value).strip()
    value = re.sub('[\s]+', slug_character, value)
    print value,